๐ Key Points
- RAG relies on a four-step pipeline: Chunk, Embed, Index, Retrieve. Your AI's answer quality is entirely capped by the quality of your retrieval phase.
- Salesforce Data Cloud automates this complexity using a
Data Library, automatically building the search index and retriever for you behind the scenes. - Salesforce supports two types of indexes (Vector and Hybrid) and two types of retrievers (Standard and Ensemble).
- Trust and traceability matter: AI citations are generated at the Retriever level, allowing users to verify which document chunk the agent used.
๐ ️ The Four Steps of RAG Architecture
To understand how an Agentforce Agent answers questions based on a massive PDF or unstructured knowledge base, you must look at it as a search problem first, and an AI problem second.
- 1. Chunking: You cannot feed a 500-page manual directly into a prompt. Chunking slices the document into manageable passages. If chunks are too small, they lose vital context. If they are too large, the semantic match gets diluted.
- 2. Embedding: Each text chunk is translated into a vector (a series of numbers). This captures the meaning of the text, rather than just the literal words.
- 3. Indexing: These vectors are stored inside a
Search Indexin Salesforce Data Cloud, making them instantly searchable. - 4. Retrieving: When a user asks a question, the system embeds the question using the exact same math, ranks the stored chunks by similarity score, and dynamically injects the top-matching chunks into the AI's prompt.
THE RAG PIPELINE ================ Document Processing: ├─ ↓ CHUNK (Cut into readable passages) ├─ ↓ EMBED (Convert text into meaning-based vectors) └─ ↓ INDEX (Store vectors in a Search Index) User Query Flow: ├─ ↓ EMBED (Convert user question into a vector) ├─ ↓ RANK (Find closest math matches in the index) └─ → RETRIEVE (Inject top text chunks into AI prompt)
๐งญ 360 Card: Mastering Retrieval Quality
- Rule: Treat RAG as a search engineering problem, not a generative AI problem. You must fix the search logic before you tweak the prompt wording.
- Gain: When you debug at the retrieval layer (by adjusting chunk sizes or adding metadata filters), you eliminate AI hallucinations at the source.
- Price: Determining the optimal chunk size is a manual tuning process that requires trial and error—there is no universal "right" answer for every dataset.
- Limits: Indexing data consumes Data Cloud credits. Best practice is to test and tune your strategy on a small subset of data before indexing a massive knowledge base.
๐ก Core Q&A
Think of it as a highly advanced search pipeline capped with an AI summarization step. First, the PDF is chunked into passages because users only need specific answers, not the whole manual. These chunks are embedded as vectors (representing meaning) and loaded into a Search Index. At runtime, the user's question is embedded the exact same way. The system ranks the chunks by similarity score, and a Retriever injects the top results directly into the LLM's prompt window to formulate the final answer.
Yes. Because vector search looks for semantic proximity, a poorly tuned index can confidently return a chunk that is conceptually adjacent but factually incorrect for the specific scenario. This is exactly why Metadata Filtering is crucial—you must apply filters (e.g., product category, region) alongside vector search to narrow down the playing field before the similarity math takes over.
A Data Library is a native capability in Salesforce that dramatically simplifies the RAG process. Instead of building your own vector database and embedding pipelines manually, you simply connect your unstructured data sources (like Knowledge Articles or SharePoint docs) to a Data Library. Salesforce automatically handles the chunking, embedding, index creation, and retriever configuration for you.
Vector Search relies purely on embeddings to match the underlying meaning and context of a query, which is great for natural language questions. Hybrid Search combines Vector Search with traditional Keyword Search (lexical matching). Hybrid Search is generally more accurate because it understands the intent while still ensuring exact matches for specific product SKUs, acronyms, or proper nouns.