RAG Systems
Retrieval-augmented generation with hybrid search, reranking, evaluation and agentic retrieval, grounded in your own documents and access rules.
Retrieval-Augmented Generation
RAG gives an LLM the right passages from your documents at question time. The model answers from those passages and cites them. Nothing is retrained when your content changes.
Why RAG?
- Grounded answers: responses are based on your documents, with source references
- Current: update the index, not the model
- Access control: filter by user permissions before the model sees a passage
- Data stays where you choose: run it with local models if required
- Cheaper than fine-tuning for facts that change. Fine-tuning is for style and format, not for knowledge.
RAG or long context?
Context windows of 256K to 1M tokens are now common. That changes the decision, but does not remove RAG.
Rule of thumb
Long context does not replace retrieval when:
- the corpus is larger than the window, or is a changing set of thousands of documents
- different users may see different documents
- you need to cite and audit exactly which passages were used
- cost and latency matter at scale: every query would otherwise pay for the full corpus
Models can use information in the middle of a very long prompt less reliably than at the edges. Test your own data before you trust a large window.
A Current Baseline
What we consider the default for a production system:
- Hybrid search: dense embeddings plus keyword search (BM25), merged with reciprocal rank fusion. Keyword search finds part numbers, names and error codes that embeddings miss.
- Reranking: a cross-encoder or LLM reranker reorders the top 50-100 candidates. This is usually the cheapest large quality gain.
- Chunk enrichment: each chunk is stored with its context (document title, section path, a short generated summary of where it sits). Anthropic’s Contextual Retrieval measured 35% fewer failed retrievals from contextual embeddings, 49% with contextual BM25 added, and 67% with reranking on top (top-20 failure rate from 5.7% to 1.9%, on their test sets).
- Metadata filters: tenant, permissions, date, document type, applied inside the search.
- Parsing quality: tables, scans and layouts need a proper parser or a vision model. Bad parsing cannot be fixed later in the pipeline.
Agentic Retrieval
A fixed pipeline retrieves once. Agentic RAG lets the model run the search as a tool, in a loop:
- reformulate the question and run several searches
- read results, notice gaps, search again
- choose between sources: vector index, SQL, a document store, an API
- stop when it has enough evidence
This helps with multi-part questions and vague queries. It costs more tokens and time, and it is harder to test. We use a fixed pipeline for simple lookups and the agentic loop where questions need several steps. The search tool itself is often an MCP server.
GraphRAG: Where It Fits
GraphRAG extracts entities and relations into a graph and retrieves along it. It pays off for:
- questions across many documents (“what are the main themes”, “which suppliers are linked to this incident”)
- corpora with dense, stable relations: contracts, org structures, equipment hierarchies
It is expensive to build, needs extraction quality control, and is overkill for lookup questions. Recent benchmarks find that agentic search closes part of the gap on plain RAG, while graph retrieval still helps on multi-hop questions. We start without a graph and add one when evaluation shows multi-hop failures.
Evaluation Comes First
We build the test set before tuning anything.
- Retrieval: recall@k, MRR and nDCG on questions with known source passages
- Answers: faithfulness (is every claim supported?), relevance, and refusal when the answer is not in the documents
- LLM-as-judge, calibrated against a sample that people have graded
- Regression runs on every change to chunking, embeddings, reranker or prompt
- Production traces: log query, retrieved passages and answer, and sample them for review
What We Build
- Ingestion: PDF, Word, HTML, Markdown and email, with OCR and table extraction, versioning and incremental updates
- Storage: PostgreSQL with pgvector when it is enough; Qdrant, Weaviate, Milvus or others for larger or more specialised needs
- Multilingual retrieval: German and English content in one index, with embedding models tested on your language
- Generation: cloud or local models, structured output, citations with page or section
- Security: per-user filtering, multi-tenant isolation, audit logs
- Operations: freshness monitoring, feedback capture, cost tracking
Every system is adapted to the data and the users. There is no single template.
Project Highlights
Internal Documentation Center
Case Study
Challenge: Engineers needed to find specifications, procedures and guidelines in thousands of technical PDFs.
Solution:
- PDF ingestion with text, table and diagram extraction
- Semantic search across the corpus
- Chat interface with source citations
- Role-based access to sensitive documents
Result: Lookups are significantly faster, with source references for compliance.
News & Trend Analysis
Case Study
Challenge: A client received more newsletters, alerts and updates than anyone could read.
Solution:
- Automated email ingestion from curated source lists
- Extraction, categorisation and summaries
- Daily trend report
- Searchable archive with a chat interface
- Topic tracking and alerts
Result: Executives receive a short daily briefing and can query the full history.
Use Cases
- Enterprise knowledge base: policies, procedures, internal documentation
- Customer support: manuals, FAQs, troubleshooting guides
- Legal and compliance: contracts, regulations, case law
- Research: papers, market reports, competitive analysis
- Technical documentation: API docs, specifications, standards
Integration
REST API, chat widgets, Slack or Teams bots, email assistants, n8n workflows, and MCP servers so that other agents can search your knowledge base.
Technology
| Component | Options |
|---|---|
| Embeddings | Open models (BGE, E5, Qwen embedding models), commercial APIs (OpenAI, Cohere, Voyage) |
| Search | pgvector, Qdrant, Weaviate, Milvus, Elasticsearch/OpenSearch for hybrid |
| Rerankers | Cross-encoders (BGE, Jina), Cohere Rerank, LLM rerankers |
| LLMs | Claude, GPT, Gemini, or open-weight models run locally |
| Orchestration | LlamaIndex, LangGraph, or plain code |
| Infrastructure | Docker, Kubernetes, on-premise or cloud |
Have documents that need to be answerable? Let’s discuss your RAG project.
Related Content
Codex-V Knowledge Engine
A Personal Technical Knowledge Engine Codex-V is a local-first knowledge management system for …
Building RAG Systems for Production: Lessons Learned
Retrieval-Augmented Generation (RAG) has become the standard approach for building AI systems that …
AI Agents and Skills
Agents: What Changed An agent is an LLM that runs in a loop: it decides on an action, calls a tool, …