An embedding turns a word, phrase, or document chunk into a numerical vector. Similar meanings occupy nearby positions in a high-dimensional vector space, while dissimilar meanings are farther apart, making semantic search more useful than keyword matching. section 6.3.2
A retrieval pipeline uses embeddings to connect user questions with relevant content:
- Preprocess documents by converting files, adding metadata, and dividing text into coherent semantic chunks. section 6.3.2
- Generate an embedding for each chunk and store the vectors in a vector database. section 6.3.2
- Embed the user’s question, compare vectors with cosine similarity or another method, and retrieve the closest matches. section 6.3.2
- Benchmark embedding and indexing combinations against accuracy, relevance, latency, throughput, and resource-use goals. section 6.5.4
Embedding a healthcare chatbot’s knowledge
For PharmaBot, medical articles, research papers, and health guidelines are chunked and embedded, then indexed with a selected solution such as FAISS or Elasticsearch. Queries such as “Can I take ibuprofen with my blood pressure medication?” are tested with embedding models including BERT, Sentence-BERT, or GPT-3 embeddings. The configurations are compared using measures such as recall, precision, F1 score, relevance, and latency. section 6.5.4
Figure 6.9 RAG uses a vector database during build time and run time.
Use the RAG architecture figure to see how vector databases support embedding and retrieval during build time and run time. section 6.3.2














































