RAG Implementation Guide
From Text to Multimodal
By Madina Gbotoe | Women Defining AI | January 2026, updated November 2026
A comprehensive guide for product managers, developers, and AI practitioners building retrieval-augmented generation systems. Covers fundamentals through production deployment, with clear guidance on when to use basic vs advanced techniques.
Sections
10 Parts
Audience
PMs & Developers
Coverage
Basic → Production
Contents
Part 0: Start Here (Do You Need to Build?)
A Project Is Already a RAG System
Before writing code, check whether a tool you already have does RAG for you. Many first RAG projects never need a custom build.
- Claude Projects: Upload files and add instructions, and Claude searches them for you. Small projects are read in full; larger ones switch to retrieval automatically. Check your plan's current file limits.
- ChatGPT Projects: Same idea: upload files and add instructions. File limits vary by plan.
- Microsoft 365 Copilot: Already does RAG over SharePoint, OneDrive and email, and only shows content each user can access. Copilot Studio is the middle ground (no-code agents with your own knowledge sources). Azure AI Search is the full custom build.
Build Your Own When
- Size: Your data is bigger than the tool's limits, or changes every week.
- Permissions: Different users must see different documents.
- Placement: It has to live inside your app, site or workflow.
- Measurement: You need to measure and tune retrieval quality (Part 7).
- Privacy: Data can't leave your network (Part 9).
What You Need to Build
- An LLM API key: Anthropic, OpenAI, or a local model through Ollama. This is separate from a Claude or ChatGPT subscription and billed per token.
- A dedicated embedding model, not a chat model: Claude and GPT chat models write text; they don't produce embeddings. Use OpenAI text-embedding-3-small, Voyage AI, Cohere, or local nomic-embed-text. Anthropic doesn't make its own embedding model, so a Claude build usually pairs Claude for answers with a separate embedding provider. Use the same embedding model for storing and searching: vectors from different models don't match, and switching models means re-embedding everything.
- A place to run code: Google Colab or Replit in your browser, or your laptop with an AI coding tool (like Claude Code, Cursor or Codex).
- A place to store vectors: For a small collection, a single file on your computer (a FAISS index or NumPy file) loaded into memory; or Postgres with pgvector; or a vector database (Part 1).
- A spending cap: Set a spending limit on every API account before you write code.
- If other people will use it: They need a chat page (Streamlit or Gradio in Python, or a website) on a host like Vercel, Netlify or Replit. Never put API keys in browser code; keep them in a small backend (a serverless function or a server). Serverless functions don't keep files, so use a hosted vector store, and add login and access control for private documents.
Levels Used in This Guide
The Women Defining AI session numbers the three levels in Part 1:
- Level 1: True Minimum RAG. Keyword search, no embeddings.
- Level 2: Standard RAG. Search by meaning with embeddings.
- Level 3: Advanced RAG. Hybrid search, re-ranking and other add-ons.
Start at Level 1 or with a Project. Move up only when your tests (Part 7) show a gap.
Part 1: RAG Pipeline Overview
RAG systems range from dead simple to highly complex. Understanding the progression helps you build the right level for your use case.
True Minimum RAG (4 Components)
The absolute simplest RAG system needs only four things:
- 1.Document Loading: Get text from your files. Can be as simple as reading .txt files.
- 2.Chunking: Split text into pieces. Can be as simple as splitting by paragraph.
- 3.Search: Find relevant chunks. Can be keyword/string matching - no vectors required.
- 4.Generation: Pass retrieved chunks + query to an LLM. Get answer.
Key insight: No embeddings, no vector database, no fancy infrastructure. Keyword search over text files + LLM = RAG. Good for prototypes, tiny corpora (<50 docs), and learning how RAG works.
Standard RAG (Adds Semantic Search)
Adds embedding model and vector storage to enable semantic (meaning-based) search. Similar meanings = similar vectors.
Advanced RAG (Quality Improvements)
- Hybrid search: Combine keyword (BM25) + semantic search
- Re-ranking: Retrieve more candidates, re-score with second model
- Query expansion: Rewrite or expand queries before searching
- Parent-child retrieval: Search small chunks, return larger context
Choosing Your Level
| Use Case | Recommended Level |
|---|---|
| Prototype / learning | True Minimum (keyword search is fine) |
| Small corpus (<1K docs), exact terminology | Keyword search may be enough |
| Medium corpus, varied queries | Standard RAG with semantic search |
| Large corpus, high accuracy needed | Add hybrid search + re-ranking |
| Enterprise / production | All above + caching, guardrails, fallbacks |
Part 2: Document Preparation Fundamentals
Use Clear Headings and Structure
Organize each guide with descriptive headings, subheadings, and ordered lists. Well-structured documents chunk better.
Consistent Terminology
Use consistent names across documents. If some guides call a part "motor" and others "engine", standardize or note synonyms.
Describe Visuals in Text
For each image or diagram, ensure there is text describing it. This aids retrieval since the system can find images by description.
Maintain Metadata
Organize files with naming conventions that encode metadata. This can be ingested and used to filter or boost relevance.
Make It Readable
- Convert to Markdown when you can: Markdown keeps headings, lists and tables as plain text, so chunking can split on headings and tables stay readable to the model. Tools like Microsoft's MarkItDown and Docling convert PDFs and Word files to Markdown. Always open a few results and check tables and scanned pages.
- Add a summary page for scattered facts: If the answer to a common question is spread across several long documents, search may rank none of them high enough. One short page that lists the facts in one place, using the words people search with, often fixes it for every retrieval method. Real example: on the RAG Strategy Lab, "What certifications does Madina have?" returned "no information" from all three search methods until a one-page certifications summary was added. Afterward, all three answered correctly.
Part 3: Chunking Strategy
Chunking is arguably the most impactful decision in RAG pipeline design. Poor chunking leads to fragmented context, lost relationships, and degraded answer quality.
Chunk Size Selection
Small (100-300 tokens)
Higher precision, may lose context. Good for FAQ-style.
Medium (300-800 tokens)
Balanced tradeoff. Recommended starting point.
Large (800-1500 tokens)
More context, less precision. For narrative content.
Recommendation: Use semantic chunking with a maximum size fallback. Split first on headers/sections, then on paragraphs, with fixed-size as the last resort. Always use 10-20% overlap.
Part 4: Multimodal Content Processing
Optional UpgradeSkip this section if building text-only RAG. True multimodal RAG requires processing images, tables, and diagrams natively.
Image Processing Strategies
- Vision-Language Models: Use Claude, GPT, Gemini, or LLaVA to generate detailed descriptions
- CLIP-style embeddings: Embed images directly into the same vector space as text
- OCR for text-heavy images: Extract text from diagrams, flowcharts, screenshots
Table Processing
Tables encode relational information. Flattening to bullet points destroys row-column relationships. Use markdown tables, row-wise statements, or keep tables as atomic units.
Part 5: Embedding and Retrieval Architecture
Embedding Model Selection
- General-purpose: OpenAI text-embedding-3, Cohere embed-v3, BGE, E5, GTE
- Size variants matter: text-embedding-3-small (1536 dims) vs large (3072 dims)
- Dimension tradeoffs: 768-1536 is often the sweet spot
Hybrid Search
Combine semantic search with keyword search (BM25/TF-IDF) for best results. Use reciprocal rank fusion (RRF) to merge results.
Re-ranking
Initial retrieval (top 20-50 chunks) is fast but imprecise. Apply a cross-encoder re-ranker to re-score and select the final top-k. This significantly improves relevance.
Part 6: Prompt Engineering for RAG
Context Presentation
- Use clear delimiters (XML tags or markdown blocks)
- Include source metadata for proper citations
- Place most relevant chunks first
Instruction Framing
- Instruct model to answer based only on provided context
- Request citations to specific sources
- Specify output format expectations
Handling Conflicting Information
When chunks contain contradictory info, instruct the model to surface the conflict, prefer newer sources, or ask for clarification.
Part 7: Quality Metrics and Evaluation
A Simple Test Method (Start Here)
You don't need a framework to start. A spreadsheet works.
- Write 20 to 30 real questions: For each, record the expected answer and where it lives (the document or section that should be retrieved). The "where it lives" column is what lets you check retrieval, not just the answer.
- Mix three kinds: Easy (answer in one place), hard (answer needs two or more documents) and trap (answer is not in your data; the system should say so).
- Score four checks per question: Found it (did the right source come back in the top K results?), grounded (is every claim in the retrieved text?), correct (does it match the expected answer?) and honest (did it say it doesn't know on trap questions?).
- Rerun after every change: Same questions, before and after. That is how you know a fix worked and nothing else broke.
- Don't trust similarity scores as quality: A high similarity score means the retrieved text looked like the question, not that the answer is right. Judge correctness separately.
- Built-in option: Copilot Studio's Agent Evaluation (generally available since March 2026) accepts a CSV of questions and expected answers and grades each one, with graders for meaning, keywords, exact match and custom rules. Claude and ChatGPT Projects have no built-in equivalent, so use the spreadsheet.
Retrieval Metrics
- Hit rate@K: % of test questions with at least one relevant chunk in the top K. The simplest retrieval metric; with one relevant chunk per question it equals Recall@K.
- Recall@K: % of relevant chunks in top K
- Precision@K: % of returned chunks that are relevant
- MRR: How high does first relevant result appear?
End-to-End Metrics
- Answer correctness: Match to ground truth
- Faithfulness: Grounded in context (no hallucination)
- Answer relevance: Actually addresses the question
From Testing to Validation
Testing asks "does it work?" Validation asks "can I prove it, and keep proving it?" Match the rigor to the stakes:
- Tier 1, everyone: Rerun your test set after every change, use an AI judge to grade answers, and spot-check the judge against your own grades.
- Tier 2, people act on answers: Set a pass bar before testing (for example, "every answer cites a source"), have subject experts review a sample and sign off, and keep sampling live answers after launch.
- Tier 3, high stakes (healthcare, finance, HR, legal): Write down intended use and risk, trace each requirement to a test, and revalidate when the model, prompt or data changes. See your industry's rules and the NIST AI Risk Management Framework.
LLM answers vary run to run, and providers update models. Pin the model version and rerun your tests when it changes.
Part 8: Edge Cases and Special Considerations
Versioned Documents
Decide: keep only latest, keep all with version metadata, or deduplicate at retrieval time.
Time-Sensitive Info
Content with expiration dates should have date metadata. Consider time-weighted retrieval.
Multilingual Content
Use multilingual embedding models (multilingual-e5, mGTE) for cross-lingual retrieval.
Access Control
Store access control metadata and filter at retrieval time to prevent unauthorized disclosure.
Part 9: Local Deployment Options
When Local Deployment Makes Sense
- Data privacy: Sensitive documents that cannot leave your network
- Cost optimization: High query volumes where API costs are prohibitive
- Offline/air-gapped: No internet access
- Latency control: Eliminating network round-trips
All-in-One Tools
GPT4All (LocalDocs): Point at folder, handles everything. Simple GUI.
LM Studio: Polished GUI for local models. RAG via document upload.
AnythingLLM: Open-source RAG platform with more configuration options.
Part 10: Production Hardening
Most RAG tutorials stop at "it works." Production systems need caching, security, fallbacks, and cost controls.
Caching Strategies
- Embedding cache
- Semantic response cache
- Retrieval cache with TTL
Guardrails & Security
- Rate limiting
- Prompt injection detection
- PII detection and redaction
- Output validation
LLM Fallback Chain
- Primary → Fallback → Static
- Circuit breaker pattern
- Graceful degradation
Cost Controls
- Track token usage
- Per-user cost caps
- Model tiering
Glossary
Plain-language definitions of the terms used in this guide.
- API key
- A secret key that lets your code use an AI model. Billed per token, separate from a Claude or ChatGPT subscription. Never put one in website code.
- Chunk
- A piece of a document. RAG searches chunks, not whole files, and sends only the best few to the AI.
- Chunking
- Cutting documents into chunks before you store them. How you cut decides what gets found (Part 3).
- Context window
- How much text an AI model can read at once, measured in tokens. Retrieved chunks, your instructions and the question all have to fit.
- Embedding
- Turning text into a list of numbers that captures its meaning, so text with similar meaning ends up with similar numbers.
- Embedding model
- The model that creates embeddings. It is a different model from the chat model that writes answers (Part 5).
- Grounded
- Every claim in the answer comes from the retrieved text, not from the AI's own memory.
- Hallucination
- A confident answer the AI made up. Trap questions are the fastest way to catch it.
- Hybrid search
- Keyword search and search by meaning combined. Catches exact codes and names that meaning search can miss (Part 5).
- Keyword search (BM25)
- Finding chunks that share words with the question. BM25 is the most common way to score those matches. Level 1 RAG uses it, with no embeddings.
- LLM (large language model)
- The AI that writes the answer, such as Claude, GPT or Gemini.
- Markdown
- Plain text with simple marks for headings (#), lists and tables. Easier for RAG to split and read than PDFs (Part 2).
- Metadata
- Labels attached to each chunk, such as document title, section, page and date. Used to cite sources and filter results.
- Multimodal RAG
- RAG that also handles images and tables, not just text (Part 4).
- OCR (optical character recognition)
- Turning images of text, such as scanned PDFs, into real text that search can read.
- pgvector
- An add-on that lets a Postgres database store and search vectors. Useful if you already run Postgres.
- Project (Claude or ChatGPT)
- A workspace where you upload files and add instructions. It handles the chunking and searching for you, so it is already a RAG system (Part 0).
- RAG (Retrieval-Augmented Generation)
- Letting an AI look things up in your documents before it answers, so the answer comes from your information instead of only its training.
- Re-ranking
- A second pass where a model reorders the candidate chunks by how well they answer the question. Helps when the right chunk is found but ranked low (Part 5).
- Search by meaning (semantic or vector search)
- Finding chunks whose vectors are close to the question's vector, even when they use different words. Level 2 RAG.
- Token
- The unit AI models count text in, about three quarters of a word. 300 to 800 tokens is roughly half a page to a page.
- Top-K
- How many chunks search returns for each question. K is the number, often 3 to 5.
- Trap question
- A test question whose answer is not in your data. The right response is "I couldn't find that."
- Vector
- The list of numbers an embedding produces. Similar meanings get similar vectors.
- Vector store or vector database
- Where vectors are kept and searched. Small collections can live in memory or a single file (FAISS, NumPy). Larger ones use a database (Chroma, Qdrant, Pinecone) or Postgres with pgvector.
Ready to Build Your RAG System?
Download the complete guide for offline reference, or explore the interactive RAG Playground to see these concepts in action.