RAG Pipelines
Overview
A RAG (Retrieval-Augmented Generation) pipeline combines two steps:- Retrieve relevant documents from a vector store
- Generate an answer using a Large Language Model (LLM) conditioned on those documents
- a high-level API with
RAGPipeline(simple and explicit) - a low-level Builder API (fully composable and customizable)
- loaders (knowledge sources)
- readers (document processors)
- embeddings
- vector stores
- LLMs
How RAG works in RAGLight
At runtime, a RAG pipeline follows this flow:Option 1: RAGPipeline (simple API)
RAGPipeline is the recommended entry point if you want:
- a clear, batteries-included RAG setup
- minimal boilerplate
- fast prototyping
Basic example
What happens during build()
Calling pipeline.build() triggers:
- resolution of knowledge sources
- document ingestion
- chunking and embedding
- storage in the vector store
Querying the pipeline
- the query is embedded
- the vector store retrieves top-k chunks
- chunks are injected into a prompt
- the LLM generates an answer
Option 2: Builder API (advanced)
The Builder API exposes all RAG components explicitly. Use it when you want:- fine-grained control over each component
- custom ingestion workflows
- advanced experimentation
Building a RAG pipeline step by step
Ingesting documents manually
With the Builder API, ingestion is explicit:- control when ingestion happens
- reuse the same vector store across pipelines
- debug indexing issues
Querying the RAG pipeline
RAGPipeline.
Choosing between RAGPipeline and Builder
| Use case | Recommended approach |
|---|---|
| Quick prototype | RAGPipeline |
| Minimal code | RAGPipeline |
| Fine-grained control | Builder API |
| Custom ingestion | Builder API |
| Advanced experimentation | Builder API |
Common parameters
Regardless of the API, the following parameters matter:k: number of retrieved chunks- embedding model and provider
- vector store backend
- LLM provider and model
- system prompt
Summary
- RAG pipelines retrieve documents before generating answers
- RAGLight offers a simple (
RAGPipeline) and an advanced (Builder) API - Both approaches share the same core logic
- Choose simplicity or control depending on your use case