RAG
RAG for Business Document Intelligence
Turning your documents into an AI knowledge base
Your company already knows the answer. It's just buried in a PDF, a wiki page or an old email. RAG lets people ask in plain words and get an answer with the source attached.
- RAG
- AI Web Applications
- AI Software Development
Every company has the same problem. The answer to "what's our warranty policy for this product line?" or "which supplier did we use for this part in 2023?" exists somewhere. It's in a PDF, a wiki page, a contract or an email thread. Finding it takes twenty minutes and a colleague who remembers where to look.
AI models are great at reading and writing, but they don't know your documents, and when they don't know something they sometimes make it up. RAG fixes that. Before the model answers, the system finds the right passages in your own documents and hands them over. The model answers from those sources and shows you where the answer came from.
The result: people ask a question in plain words, and get a clear answer with a link to the exact page.
How RAG works, in two halves
A RAG system does two separate jobs. The first happens in the background: getting your documents ready to search. The second happens every time someone asks a question.
- 01
Collect
Gather documents
From SharePoint, Confluence, file shares, databases or email.
- 02
Read
Turn them into text
Including scanned pages, tables and slides.
- 03
Split
Cut into passages
One section, table or clause at a time, never half a sentence.
- 04
Index
Make them searchable
Store each passage with its source, date and who may see it.
- 01
Ask
A person asks
“What's the return window for industrial customers?”
- 02
Search
Find candidate passages
By meaning and by exact words, only in documents this user may see.
- 03
Rank
Keep the best few
A second check puts the most relevant passages first.
- 04
Answer
Answer with sources
The model answers only from those passages and cites them, or says it doesn't know.
That's the whole idea. None of these steps is mysterious. Getting all of them right for your documents is where the real work is.
The steps that make or break quality
Reading documents properly
Real company documents are messy: scanned PDFs, Word files with tracked changes, spreadsheets that are secretly databases, and three versions of everything. If the text comes out garbled at this stage, nothing later can fix it. In our experience this is where most quality problems are born.
Splitting documents the smart way
The lazy approach is cutting every document into equal blocks of text. It's often wrong, because it cuts sentences, tables and clauses in half. Good splitting follows the document's own structure: one section, one slide, one table, one contract clause at a time.
Searching by meaning and by exact words
Modern search turns each passage into a "meaning fingerprint" (an embedding), so a question about "sending goods back" can find a passage about "returns". That's powerful, but it's weak at exact things like part numbers, names and codes. Combining meaning-based search with classic keyword search almost always gives better results on business documents.
Teaching the model to say "I don't know"
The instructions tell the model to answer only from the passages it was given, cite them, and admit when the answer isn't there. A system that refuses honestly is worth far more than one that always sounds confident.
Where RAG projects go wrong
We've put a RAG system into production and seen every one of these mistakes at least twice:
- Splitting that ignores structure. Headings, lists and tables lose their meaning, and search quality drops before it even starts.
- Relying only on meaning-based search. Part number "AX-4410" and "AX-4401" look almost the same to it. Add keyword search.
- No access control. If HR files, contracts and public FAQs sit in the same index, every passage needs to know who may see it, and every search must respect that. Otherwise the AI will happily quote a salary to the wrong person.
- No test set. Without a list of real questions and correct answers, nobody can tell whether yesterday's change helped or hurt. "It feels better" isn't a release plan.
- Set up once and forgotten. Documents change every day. Without regular refreshes, answers go stale within weeks.
The fix is never a fancier model. It's careful work on the pipeline.
RAG, fine-tuning or a huge context window?
People often ask which approach to use. Here's the short answer:
Fine-tuning
Retrain the model on your data
- Good for tone, format and vocabulary
- Poor at remembering specific facts
- Slow and costly to update
- Out of date the day documents change
Huge context window
Paste everything into the prompt
- Simple for a handful of documents
- Expensive and slow on every question
- Models miss details in very long inputs
- Doesn't scale to a whole company
RAG
Find the right passages, then answer
- Answers come with sources you can check
- Updates as soon as documents change
- Respects who may see what
- Scales to millions of passages
Most real systems combine them: RAG for facts, light fine-tuning or examples for tone and format.
What people actually see
In practice we build RAG into a simple, focused web application. Users get a question box, a clear answer with numbered citations, and a side panel showing the exact passages the answer came from, so anyone can check it in a second.
- 01
Web app
Next.js
Question box, answers with citations, source panel and feedback buttons.
- chat
- citations
- ratings
- 02
API
typed endpoint
Takes the question, the user's identity and optional filters.
- auth
- filters
- rate limits
- 03
Search
retrieval
Meaning and keyword search, then ranking, limited to what this user may see.
- hybrid search
- re-ranking
- access tags
- 04
Answer
generation
The model writes a grounded answer with citations, or says it doesn't know.
- grounding
- citations
- refusal
- 05
Feedback loop
evaluation
Experts mark answers right or wrong; that feeds the test set.
- test set
- logs
- review queue
Want the answers to trigger actions too, like opening a ticket or drafting a reply? That's when RAG becomes one tool inside an AI agent.
How to start a RAG project
The fastest route to something useful:
- Pick one valuable set of documents. Not "all of SharePoint". Choose the 200–2,000 documents behind the most questions. Quality beats coverage on day one.
- Collect 30–50 real questions from the people who'll use it. They become your test set.
- Build a first working version. Load those documents, add a simple interface and make sure those questions get correct, cited answers.
- Test, improve, then expand. Only add more documents once the answers are consistently good.
That's how we work with every client, and it's why the first real answers arrive in weeks, not quarters.
The short version
RAG is the most practical way to make your company's knowledge easy to ask about. The model is the easy part. The hard part is the unglamorous pipeline work that keeps search accurate and answers trustworthy.
Want to see what RAG could do with your documents? Our agent-powered software development service is built around exactly this. Read the RAG case study for a real example, or get in touch to talk about your documents.
Frequently asked questions about RAG
What teams ask us most when planning a RAG project.
What Is a Super Agent? DeepSeek's Router-Worker Design, Explained Honestly
A super agent is one always-on AI agent that watches your tools, hands work to isolated workers and only interrupts you when it matters. Here's how the design works, what DeepSeek's numbers really show, and how to use the idea safely.
AI Gateway: How We Route Voice, Vision, Text and Decisions Across Multiple Models
What an AI gateway is, why one model isn't enough, and how our custom AI gateway routes voice, vision, text and decisions to the right model, with security and cost control built in.
PLC to MES Interconnection for Industry 4.0: Connecting Machines with OPC-UA
How to connect PLC machines to a MES in real time over OPC-UA, and why machine interconnection is the key requirement for Italy's 2026 iperammortamento (Industry 4.0).