Created
June 13, 2025 02:05
-
-
Save rjurney/d0bae5d673ac64aeea943f51eb8af279 to your computer and use it in GitHub Desktop.
We all contrastive experience loss at some point in our lives, but which one for your problem and with what hyperparameters?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will effectively train the embedding model. MultipleNegativesRankingLoss did not work. | |
loss: losses.ContrastiveLoss = losses.ContrastiveLoss(model=sbert_model) | |
# These are default arguments for OnlineContrastiveLoss | |
loss: losses.OnlineContrastiveLoss = losses.OnlineContrastiveLoss( | |
model=sbert_model, | |
margin=0.5, # Margin for contrastive loss | |
distance_metric=SiameseDistanceMetric.COSINE_DISTANCE, | |
) | |
loss: ContextAdaptiveContrastiveLoss = ContextAdaptiveContrastiveLoss( | |
model=sbert_model, | |
margin=0.5, # Margin for contrastive loss | |
gate_scale=5.0, # Scale for the gate function | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment