Finding the right information in a sea of data can be challenging. This blog explains how enriched indexing (vector search index with enriched chunks) with Retrieval Augmented Generation (RAG) in Salesforce makes it easier. By using enriched indexing—where data is broken into meaningful chunks and tagged with additional context—these systems quickly find and deliver the most relevant information. Through a simple library analogy, you’ll discover how this approach helps AI agents provide clear and accurate answers, making it smarter and faster than traditional keyword-based search indexes.
What is an Index
Imagine, if you need to find a book about “Flu symptoms” in a library with thousands of books, you wouldn’t want to search through every book page by page. Instead, the library has a system where each book is organized by topic (e.g., medicine, baking, cooking, gardening, arts & culture, fiction) and a catalog tells you exactly where to find books about flu. This is the library’s indexing system.
Now imagine, you ask “What are the symptoms of flu?” to someone – let’s say the librarian who is experienced and knowledgeable about the index system and the books in the library. The librarian quickly looks up the most relevant books using the index in the library, and uses his knowledge to summarize or explain the answer in a way that’s easy for you to understand. In technology terms, the “books” are your data (e.g., documents, FAQs, articles) and the “index” is like a map or database that helps find the most relevant piece of information quickly. The librarian who provided the answer is an AI agent. It uses the index to find the best information, then processes it to give you a clear and specific response.
If there wasn’t an indexing system, You’d need to read through a 200-page medical book to find the answer. The system uses the index to find the specific page or section that lists flu symptoms.
Traditional search systems rely on keywords. For example, if you search for “flu symptoms,” the system might find documents with those exact words, but it won’t understand the meaning.
In a regular index, information is organized so it’s easy to find.
For example:
- Book Title: “Flu Symptoms”
- Page Number: 29
When you ask, “What are flu symptoms?”, the system looks up this index and points you to page 29.
What is Vector Search
Vector search, on the other hand, uses numerical representations (called embeddings) to capture the meaning of text. It can match your query to relevant information, even if the exact words don’t match.
Now, instead of indexing entire books or pages, the system organizes and stores embeddings (numerical representations of data) for efficient similarity search. Embeddings represent semantic meaning. The system breaks the content into chunks (smaller pieces of information). Each chunk is processed to generate an embedding that can be indexed. Each chunk is further enriched with additional details by adding context or metadata or generating summaries for each chunk to improve their relevance for retrieval. The system stores the embeddings and associated metadata in a vector index. It retrieves enriched chunks during inference and feeds them into an LLM for answer generation.
Suppose the book contains this information:
- “Flu symptoms include fever, cough, sore throat, body aches, and fatigue.”
- Chunk 1: Symptoms of flu.
- “The flu can last 1-2 weeks. It spreads through respiratory droplets when someone coughs or sneezes.”
- Chunk 2: Duration and transmission.
- “Flu vaccines can prevent severe symptoms. They are recommended annually.”
- Chunk 3: Prevention through vaccines.
Now let’s enrich each of these chunks with metadata to describe its meaning and context.
- Chunk 1 Metadata:
- Topic: Flu Symptoms
- Keywords: Fever, Cough, Fatigue
- Chunk 2 Metadata:
- Topic: Flu Transmission
- Keywords: Duration, Respiratory Droplets
- Chunk 3 Metadata:
- Topic: Flu Prevention
- Keywords: Vaccines, Annual
How Enriched Chunks Improve Indexing
Without Enriched Chunks:
If you ask, “What are flu symptoms?”, the system might give you irrelevant chunks (e.g., about vaccines or transmission) because it just searches for the word “flu.”
With Enriched Chunks:
- The system uses metadata to narrow the search to symptom-related chunks.
- It retrieves Chunk 1 (flu symptoms) instead of Chunk 2 (transmission) or Chunk 3 (prevention).
Putting It All Together with Retrieval Augmented Generation (RAG)
When you ask, “What are flu symptoms?”:
- Index Search: The system searches the enriched index for chunks tagged with “Flu Symptoms.” It retrieves Chunk 1: “Flu symptoms include fever, cough, sore throat, body aches, and fatigue.”
- AI Processing: The AI reads the chunk and rephrases it into an answer:
“The symptoms of flu include fever, cough, sore throat, body aches, and fatigue. Let me know if you’d like to learn about prevention or treatment!”
The Benefits of Vector Search with Enriched Chunks
- Speed: The system quickly narrows down results by focusing on relevant chunks and finds answers quickly
- Accuracy: Enriched metadata ensures the system retrieves the exact information you need.
- Clarity: The system processes the data to provide a clear, easy to understand conversational answer.
It’s like having an expert librarian who knows exactly where to look and gives you the perfect explanation every time. So, next time you’re searching for something complex, think of it as asking the smartest librarian in the world—who not only knows where to look but also knows how to explain it perfectly!