FAISS (Facebook AI Similarity Search) is a library for efficient similarity search and clustering over dense vectors. In semantic search, it indexes precomputed review embeddings and retrieves vectors nearest to a query embedding, making high-performance retrieval practical for large collections. section 4.3 section 4.6
A Bi-Encoder supports this workflow by encoding documents in advance and encoding each incoming query at search time. Similarity metrics such as cosine similarity or Euclidean distance rank the retrieved vectors; FAISS supplies indexing techniques and algorithms to optimize that retrieval step. section 4.6 section 4.3
A practical retrieval flow is:
- Encode hotel reviews and the user query as dense vectors, converting arrays to float32 before FAISS search. section 4.5
- Search for top-k similar reviews; raising k from 5 to 25 gathers broader evidence and can return reviews for multiple hotels. section 4.5
- Group returned reviews by hotel, average their distance scores, require at least two reviews, and sort the remaining hotels for recommendations. section 4.5
Exact semantic-cache lookup
A semantic cache can use FAISS IndexFlatL2 for exact nearest-neighbor search over float32 query embeddings. Store original questions and cached answers separately, then return a cached answer only when L2 distance passes a conservative threshold; this favors precision over cache-hit rate for nearly identical paraphrases. section 7.3.2
Figure 7.5 The core concept of semantic caching within an Enterprise RAG system to help reduce processing time to look up time for similar queries previously asked
Shows semantic caching as a lookup layer that replaces repeated RAG processing for sufficiently similar queries. section 7.3.2






