rag pipeline
**RAG (Retrieval-Augmented Generation) pipeline** is a **system architecture combining vector search with LLM generation** — retrieving relevant documents from a knowledge base and using them as context for accurate, grounded responses.
**What Is a RAG Pipeline?**
- **Definition**: Retrieve relevant context, then generate response.
- **Components**: Embeddings → Vector DB → Retrieval → LLM → Response.
- **Purpose**: Ground LLM outputs in factual, up-to-date information.
- **Benefit**: Reduces hallucinations, enables domain-specific knowledge.
- **Standard**: Used in ChatGPT plugins, enterprise AI, knowledge assistants.
**Why RAG Pipelines Matter**
- **Accuracy**: Grounded responses reduce hallucinations.
- **Freshness**: Access up-to-date information beyond training data.
- **Domain Knowledge**: Add proprietary documents to LLM knowledge.
- **Cost-Effective**: Cheaper than fine-tuning for knowledge updates.
- **Verifiable**: Can cite sources for generated answers.
**Pipeline Stages**
1. **Embed**: Convert query to vector.
2. **Retrieve**: Find top-k similar documents from vector DB.
3. **Augment**: Add retrieved context to LLM prompt.
4. **Generate**: LLM produces grounded response.
**Key Components**
- Embedding model (OpenAI, Cohere, Sentence Transformers).
- Vector database (Pinecone, Qdrant, Milvus, Chroma).
- LLM (GPT-4, Claude, Llama).
- Orchestration (LangChain, LlamaIndex).
RAG is the **standard architecture for knowledge-grounded AI** — combining retrieval precision with generative fluency.