Embedding-based retrieval maps a query and each document or review into vector representations, then ranks candidates by vector similarity. A bi-encoder encodes the two inputs independently, unlike a cross-encoder that processes them together. section 4.3 section 4.6
The practical workflow is straightforward: encode the document collection once, store the embeddings, encode each incoming query, calculate cosine similarity or Euclidean distance, and return the highest-ranked results. Precomputation makes retrieval fast and reduces repeated computation. section 4.0 section 4.6
A minimal retrieval implementation follows these steps:
- Encode hotel reviews with a Sentence Transformers model and retain the resulting vectors. section 4.0
- Encode the query, compute dot products and vector norms, divide to obtain cosine similarities, and select the top k indices. section 4.3
- Scale storage and search with FAISS, choosing the model and distance metric according to dataset size and application requirements. section 4.6
Hotel search query
For “Hotel near the Louvre with great food nearby,” encode the query, compare it with review embeddings, and print the top five hotel names, reviews, and similarity scores. The returned results can surface relevant hotels even when their reviews do not repeat the query wording. section 4.3 section 4.0
Figure 4.4 An overview of the Bi-Encoder Model to measure the similarity between two sentences.
Use the bi-encoder architecture figure to trace how the query and comparison sentence become separate representations for similarity measurement. section 4.3



