Custom batches in sentence-transformers for MultipleNegativesRankingLoss
Hugging Face Forums [Unofficial]
April 29, 2026
Thank you a lot for your answer, I’ll read it carefully and try to implement it. Since it appears to be (at least partially) LLM-generated, I hope you don’t mind a couple of clarifying questions (I’m new to hf, and I am not sure what’s the ai-generated content policy here):
Did you review the solution yourself? If so, are you familiar with the
sentence-transformerslibrary?Which LLM did you use to generate the answer? I’ve asked ChatGPT 5.4 several times about this issue, but it consistently suggests writing a custom training loop that bypasses
SentenceTransformerTrainerand its additional features.
Thanks again!
Discussion in the ATmosphere