How I built a RAG system that makes company documents searchable
2026-04-15 · 2 min read
The problem
A company with hundreds of policy documents, manuals and reports. Employees spent an average of 45 minutes per search. Nobody knew exactly what information lived where.
The question: can you build a system we can ask questions in plain language?
The architecture
A RAG (Retrieval-Augmented Generation) system combines two components:
- Retrieval — finding the relevant document fragments
- Generation — formulating an answer based on those fragments
# Simplified architecture
documents → chunking → embeddings → vector database
↓
user question → embedding → similarity search → context
↓
LLM → answer + source referencesStep 1: Document processing
The first challenge: turning documents in all kinds of formats (PDF, Word, Excel) into searchable text.
from langchain.text_splitter import RecursiveCharacterTextSplitter
splitter = RecursiveCharacterTextSplitter(
chunk_size=1000,
chunk_overlap=200,
separators=["\n\n", "\n", ". ", " "]
)
chunks = splitter.split_documents(documents)The chunk_overlap is crucial — without overlap you lose context at chunk boundaries.
Step 2: Embeddings and vector store
Every chunk is turned into an embedding — a numerical representation of its meaning. Similar texts get similar embeddings.
Step 3: Query pipeline
When a user asks a question:
- The question is turned into an embedding
- We find the most relevant chunks via cosine similarity
- The retrieved chunks are passed to the LLM as context
- The LLM formulates an answer and references the sources
The result
- Search time: from 45 minutes to 30 seconds
- Accuracy: 92% of answers were correct on validation
- Adoption: within 2 weeks 80% of the team used it daily
Lessons learned
- Chunk size matters. Too small = no context. Too large = too much noise. Test with real questions.
- Metadata is gold. Document name, date, author — add them to your chunks. It improves retrieval and user trust.
- Start simple. A basic RAG system already delivers enormous value. Only optimize once you know where the weak spots are.
The business value
This project shows what's possible when you combine GenAI with real company data. Not a generic chatbot, but a tool that answers specific questions about your documents, with citations.
More to read?
Subscribe to the newsletter for a monthly article on data, AI and what it means for your business.
Get in touch