Semantic Search

This is a simple web demo of semantic search (search by meaning) on food products using Solr and BERT embeddings. Happy searching!

In information retrieval, retrieved documents are ranked by relevance to the query. Fundamentally, relevance is based on the textual similarity (e.g. BM25) between an information requirement (query) and an article (document). However, a search system needs to measure the relevance of a document and a query beyond the simple textual similarity. Specifically, textual similarity at the word level does not take into consideration the actual meaning of words or the entire phrase in context. As such, we shall model the semantic similarity between two pieces of text to achieve a better search result. The traditional approach to address semantic search is to transform each sentence into a vector space such that semantically similar sentences will be close to each other. We use Sentence-BERT (SBERT) to derive semantically meaningful BERT embeddings that can be compared using cosine similarity.


The web is built on Django, SBERT, Solr, and Heroku. As the application is hosted on a free dyno, please expect repsonse delays from the server. Particularly, the delays are caused by the heavyweight PyTorch dependency and dyno sleeping (after 30 minutes of no web traffic). However, the application can be run locally for better performance and testing. The source code of the application is available in the below link on GitHub.

Search now Learn more