Skip to main content
All insights

Knowledge search & RAG

RAG Done Right: Turning Your Company Docs into an AI Knowledge Base

A company document knowledge base answers well when four things are right before any model is chosen: documents are parsed with their structure intact, each user can retrieve only what they are allowed to read, every answer cites the passage it came from, and a fixed set of real questions is used to check quality before and after every change. Retrieval-augmented generation (RAG) is the pattern that connects those pieces. When a knowledge base disappoints, the cause is usually ingestion or evaluation, not the model.

Ingestion decides most of the answer quality

Start by auditing the documents, not by choosing a vector database. Company files arrive as native PDFs, scans, spreadsheets, wiki pages and exports, often with inconsistent metadata. On a clinical trial question-answering platform we built for a clinical research organization, more than 10,000 trial reports existed as PDFs, scanned images and XML, with metadata that varied by vintage. Ingestion and metadata extraction shipped first because index quality gated everything else.

Keep structural information as you parse. Section headings, page numbers and positions on the page are what later let a reader jump to the source. On a document querying app for a corporate legal team, preserving page and coordinate metadata through the whole pipeline took careful design, and the one-click jump to the exact location in the PDF was the feature that earned partner trust.

Chunk to match the questions people ask

There is no universal chunk size. Collect real questions first and look at their scope: some ask about a whole agreement, others about a single clause. For the legal querying app, one chunk size either lost section context or buried clause-level detail, so we indexed at document, section and clause level and added a router that picked the granularity per question. Measured as median time to clause extraction across a thirty-deal sample, review time fell by 75%.

  • Split on structure: use headings, clauses and table boundaries before token counts.
  • Carry metadata on every chunk: source, section, page, date, owner and access group.
  • Keep exact terms searchable: product codes, clause numbers and names need keyword retrieval alongside embeddings.
  • Use filters for structured fields: trial phase, region or document type are filters, not a matter of semantic similarity.

Enforce permissions in retrieval, not in the prompt

A model cannot be trusted to withhold text it has already been given. Apply access control before passages reach it: filter by the user's groups at query time, isolate tenants, and decide where the index and the model physically run. The legal querying app ran entirely inside the client's own AWS account, including the model endpoint, because privacy was a precondition for adoption. A tax assistant we built for a tax preparation software vendor kept users' private documents in session-scoped indexes that were purged when the session ended. The clinical platform screened protected health information at ingestion, so the index was clean by construction.

Make citations a gate, not a decoration

Citations only build trust if an answer without one is not allowed to ship. In the legal tax assistant case study, the answer chain required at least one citation per claim or the system refused to answer. It draws on more than 60,000 pages of curated tax sources and returns cited answers in under three seconds at P95. During a filing-season rollout, the refusal threshold was tuned until answers without a source fell below one percent. A clear "I could not find support for that" is more useful than a confident guess.

Build the evaluation set before tuning anything

Gather real questions from the people who will use the system, record the passage that answers each one, and include questions the documents cannot answer. Score retrieval separately from the final answer so you know whether a miss came from search or from generation. Then put domain reviewers in the loop. The clinical platform ran a four-week paired-review period in which the library team checked every generated synthesis, and it moved to sponsor-facing use only after the share approved without substantive correction cleared 90%. The legal app was tested by two senior partners and four associates on closed deals for three weeks before the full team used it.

Plan for freshness, and know when not to use RAG

A knowledge base goes stale quietly. Decide who owns each source, how updates are re-ingested, and how withdrawn documents leave the index. The tax corpus took weekly updates as guidance changed, while the trial index was refreshed quarterly as new completed trials were added. Show document dates beside answers so users can judge currency for themselves.

RAG is the wrong tool when the question is really a calculation over structured records, which a database query answers more reliably; when the collection is small and stable enough for conventional search; or when documents conflict and nobody owns which version is authoritative. Fix the source first. Once the basics hold, our article on hybrid search, re-ranking and graph retrieval covers the next layer, and our guide to internal knowledge base chatbot development explains how we scope a build. If you have a document set and a list of real questions, bring them to a discovery conversation.

Related to this topic

FREE 30-MINUTE CONSULTATION

Bring the problem.
Leave with a plan.

A reply within one business day.
A written plan and a fixed quote.
100% of the code and IP is yours.
If AI is the wrong tool, we will say so.

Book your free consultation