Sitemap
TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

Member-only story

NLP For Semantic Search

Training Sentence Transformers with Softmax Loss

How the original sentence transformer (SBERT) was built

9 min readJan 12, 2023

--

Photo by Possessed Photography on Unsplash. Originally posted in the NLP for Semantic Search ebook at Pinecone (where the author is employed).

Search is entering a golden age. Thanks to “sentence embeddings” and specially trained models called“sentence transformers” we can now search for information using concepts rather than keyword matching. Unlocking a human-like information discovery process.

This article will explore the training process of the first sentence transformer, sentence-BERT — more commonly known as SBERT. We will explore the Natural Language Inference (NLI) training approach of softmax loss to fine-tune models for producing sentence embeddings.

Be aware that softmax loss is no longer the preferred approach to training sentence transformers and has been superseded by other methods such as MSE margin and multiple negatives ranking loss. But we’re covering this training method as an important milestone in the development of ever-improving sentence embeddings.

This article also covers two approaches to fine-tuning. The first shows how NLI training with softmax loss works. The second uses the excellent training utilities provided by the sentence-transformers library — it’s more abstracted, making building good sentence transformer models much easier.

--

--

TDS Archive
TDS Archive

Published in TDS Archive

An archive of data science, data analytics, data engineering, machine learning, and artificial intelligence writing from the former Towards Data Science Medium publication.

James Briggs
James Briggs

Written by James Briggs

Freelance ML engineer learning and writing about everything. I post a lot on YT https://www.youtube.com/c/jamesbriggs

No responses yet