Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add 'get_config_dict' method to GISTEmbedLoss for better model cards #2543

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion sentence_transformers/losses/GISTEmbedLoss.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable, Dict
from typing import Any, Iterable, Dict
import torch
from torch import nn, Tensor
from sentence_transformers.SentenceTransformer import SentenceTransformer
Expand Down Expand Up @@ -146,3 +146,9 @@ def forward(self, sentence_features: Iterable[Dict[str, Tensor]], labels: Tensor
labels = torch.arange(scores.size(0)).long().to(scores.device)

return nn.CrossEntropyLoss()(scores, labels)

def get_config_dict(self) -> Dict[str, Any]:
return {
"guide": self.guide,
"temperature": self.temperature,
}
Loading