Overview

2 Revolutions in semantics, scale, and similarity

RAG is presented as an architectural pattern rather than a single technology, and this chapter explains how three earlier innovations converged to make it possible: Word2Vec for semantic representation, FAISS for scalable similarity search, and Sentence-BERT for practical sentence-level retrieval. Together, they addressed the biggest barriers in information retrieval: vocabulary mismatch, computational scale, and the difficulty of turning meaning into a usable ranking signal. The chapter emphasizes that modern RAG systems inherit both the strengths and the limitations of these foundations, so understanding them is essential for diagnosing retrieval errors and improving system behavior.

Word2Vec marked the shift from exact keyword matching to geometric meaning by learning dense word vectors from context, operationalizing the idea that words with similar usage have similar semantics. This made it possible to connect terms like “car” and “automobile,” which traditional methods such as TF-IDF and BM25 treated as unrelated. However, Word2Vec remained limited to static word meanings and could not represent full sentences or adapt to context-dependent ambiguity, even though its efficiency and scalability made large-scale semantic modeling practical.

FAISS solved the next bottleneck by making billion-scale approximate nearest neighbor search fast enough for production, while Sentence-BERT adapted transformer models into a bi-encoder format that could precompute embeddings and compare them efficiently. SBERT turned BERT’s contextual understanding into sentence vectors suitable for indexing, enabling real-time semantic search across large document collections. The chapter concludes that the combination of semantic embeddings, efficient vector search, and hybrid retrieval laid the groundwork for RAG, and that the next step was to connect retrieval with generation so systems could not only find relevant knowledge but also synthesize answers from it.

CBOW vs skip-gram architectures.
What cosine similarity measures and discards. Top left: the query and doc A sit at angle θ, and doc B, twice as long and pointing the same way, scores identically, because normalizing removes magnitude before the dot product. The other three panels draw the values listed above: identical direction scores 1.0, right angles score 0.0, and opposite directions score −1.0, which text embeddings almost never produce.
FAISS's Two-Stage Search Strategy.
BERT vs Sentence-BERT: Architecture comparison.

Summary

  • Word2Vec (2013) popularized the concept of dense vector embeddings, showing that semantic relationships can be learned from data and captured in mathematical representations. This innovation enabled systems to understand that "automobile maintenance" and "car repair" refer to the same concept. While previous methods like LSA existed, Word2Vec made it cheap enough to train on billions of words, which is what made semantic search practical.
  • FAISS (2017) turned vector search into production infrastructure. While algorithms like Locality-Sensitive Hashing (LSH) had existed for decades, FAISS optimized them for modern hardware (GPUs) and billion-scale datasets. Its unified API for indexing strategies (Flat, IVF, HNSW) became an industry standard for deploying semantic search at scale.
  • Sentence-BERT (2019), transformers adapted for retrieval, solved the bottleneck of encoding full sentences. Using Siamese networks, it allowed transformers to generate independent sentence embeddings that could be precomputed and indexed. This reduced retrieval time from hours to milliseconds compared to raw BERT cross-encoders, finally enabling real-time semantic ranking.
  • The convergence created a working technology stack: Python development environments, vector databases, embedding models, approximate nearest neighbor algorithms, and cloud infrastructure. By 2020, the pieces were in place. We had a way to represent meaning (embeddings), a way to search it at scale (FAISS), and a way to encode complex queries (SBERT). All that remained was to combine this retrieval stack with the generative power of the emerging large language models.

FAQ

What problem did Word2Vec solve in traditional search?Word2Vec helped solve the vocabulary mismatch problem, where keyword-based search failed to find relevant documents because users and documents used different words for the same concept, such as “automobile” and “car.”
Why was Word2Vec considered a breakthrough in semantic understanding?It showed that meaning could be captured mathematically in dense vectors, so words with similar contexts ended up close together in vector space. This made semantic relationships machine-readable.
What is the distributional hypothesis behind Word2Vec?The distributional hypothesis says that words appearing in similar contexts tend to have similar meanings. Word2Vec operationalized this idea by learning from surrounding text.
How did Word2Vec differ from TF-IDF and BM25?TF-IDF and BM25 are still lexical methods: they rely on exact word overlap and treat synonyms as unrelated. Word2Vec learns dense semantic representations, so it can connect words like “doctor” and “physician” through context.
Why was FAISS important for RAG systems?FAISS made billion-scale approximate nearest neighbor search practical, allowing vector similarity search to run fast enough for production retrieval pipelines used in RAG.
What trade-offs do FAISS indexes involve?FAISS indexes trade off speed, recall, and memory. Faster indexes may use more RAM or sacrifice some recall, while compressed indexes save memory but can slightly reduce accuracy.
Why did Sentence-BERT become necessary after BERT?BERT was accurate but too slow for large-scale similarity search because it worked as a cross-encoder, scoring sentence pairs jointly. Sentence-BERT changed this into a bi-encoder setup, so sentences could be encoded once and compared efficiently later.
What is the difference between a cross-encoder and a bi-encoder?A cross-encoder processes both texts together and produces one score, which is accurate but expensive. A bi-encoder encodes each text separately into vectors, making retrieval much faster and scalable.
Why is hybrid search still useful in modern RAG systems?Hybrid search combines sparse keyword methods with dense vector search. Keyword retrieval is strong for exact terms, while semantic retrieval helps with paraphrases and vocabulary mismatch, so using both improves robustness.
How did Word2Vec, FAISS, and Sentence-BERT converge to enable RAG?Word2Vec provided semantic vector representations, FAISS made large-scale vector search fast, and Sentence-BERT made sentence-level embeddings practical for retrieval. Together, they created the retrieval infrastructure that RAG depends on.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Retrieval Augmented Generation, The Foundational Ideas ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Retrieval Augmented Generation, The Foundational Ideas ebook for free