UKPLab / sentence-transformers

Multilingual Sentence & Image Embeddings with BERT
https://www.SBERT.net
Apache License 2.0
14.53k stars 2.41k forks source link

How to set the no. of epochs for fine-tuning SBERT? #2278

Open gadregayatri opened 11 months ago

gadregayatri commented 11 months ago

Hello, I am fine-tuning an biencoder SBERT model on domain specific data for semantic similarity. There is no loss value posted by the fit function from the package. Any idea how to know if the model is overfitting or underfiting the dataset after each epoch? This could help me in deciding the appropriate no. of epochs required for fine-tuning.

Thank you.

tomaarsen commented 5 months ago

Hello!

I intend to add loss logging in the future, but until then, you can add a SentenceEvaluator that displays the performance on some other development dataset, e.g. STS Benchmark. A lot of examples rely on this for evaluation during and after training. See e.g. this snippet: https://github.com/UKPLab/sentence-transformers/blob/b00b329ffb27e3f48d841781224a9676deed5833/examples/training/nli/training_nli_v2.py#L104-L116