Is it possible to train CosineSimilarityLoss without labels?
See original GitHub issueI’d like to rebuild a model from a certain paper that minimizes 1 - CosineSimilarity(a, b)
, but it seems to me that the implementation of CosineSimilarityLoss in this repo and the usage in the examples always require a label (i.e. -1 or 1). Is it possible to train the CosineSimilarityLoss
loss without labels, providing only positive/similar example pairs?
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Losses — Sentence-Transformers documentation
BatchAllTripletLoss takes a batch with (label, sentence) pairs and computes the loss for all possible, valid triplets, i.e., anchor and positive must have ......
Read more >Train and Fine-Tune Sentence Transformers Models
Note that Sentence Transformers models can be trained with human labeling (cases 1 and 3) or with labels automatically deduced from text ...
Read more >How to apply cosine similarity loss function in unsupervised ...
The loss requires y_true and y_pred , but as can be seen, this is unsupervised training and there is no y_true .
Read more >How to apply cosine similarity loss function in unsupervised ...
The loss requires y_true and y_pred , but as can be seen, this is unsupervised training and there is no y_true .
Read more >No means 'No': a non-improper modeling approach, with ...
We used the architecture of sentence-BERT implemented by Reimers and Gurevych (2019) which used cosine similarity loss for training.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @olastor The CosineSimilarityLoss requires a continous label, e.g. from -1 to 1 or from 0 to 1.
If you have only positive pairs, you can construct negative pairs by randomly selecting two pairs. This usually gives you a negative pair. Then you can train with ConstrativeLoss.
Else have a look at triplet loss.
Best Nils Reimers
But this is eaxatcly what you also do in the paper, right? So I am a bit unsure what your “should work” means? Maybe you use the gold scores a s “labels”?
From the paper: