RAG Over Messy Enterprise Knowledge: What the Tutorials Skip

Carson Rodrigues

Carson Rodrigues / November 09, 2025

8 min read––– views

fderagenterprise

Every RAG tutorial starts the same way: take a clean markdown file, split it every 500 tokens, embed the chunks, cosine-similarity your way to victory. Then you get into a real enterprise deployment and discover the knowledge base is 4,000 PDFs — half of them scanned, a third of them outdated, several of them contradicting each other — plus a SharePoint graveyard and a wiki whose search nobody trusts.

I've built retrieval pipelines behind customer-facing AI products, where a wrong answer isn't a bad demo — it's a support escalation or worse. This post walks the pipeline end to end, focusing on the decisions the tutorials skip.


Ingestion: where 60% of the quality is decided

Nobody wants to hear this, but retrieval quality is mostly determined before you embed a single token. Garbage chunks retrieved perfectly are still garbage.

The unglamorous work that pays off:

  • Parse structure, not just text. A PDF extractor that flattens a pricing table into a word soup has already lost the answer. Use layout-aware parsing for tables, headers, and lists; fall back to OCR only when you must, and tag OCR-derived content so you can weight it lower.
  • Kill the boilerplate. Headers, footers, legal disclaimers, and navigation chrome repeated on every page will dominate your similarity scores. Strip them at ingest, or your top-5 results will be five copies of the confidentiality notice.
  • Capture metadata like your life depends on it. Document title, section path, author, last-modified date, source system, access permissions. Every one of these becomes a filter, a ranking signal, or a citation later. Metadata you don't capture at ingest is metadata you re-crawl for in three months.
  • Resolve duplicates and versions. Enterprises never have one policy document; they have the 2023 version, the 2024 revision, and a draft someone exported to PDF. Detect near-duplicates at ingest and keep only the canonical one — or your model will confidently cite the retired policy.

On one deployment, the single biggest quality jump came not from a better embedding model but from deleting a third of the corpus. Curation is a feature.


Chunking: respect the document, not the token counter

Fixed-size chunking is what you do when you know nothing about the data. Once you do know the data, chunk along its structure:

  • Split on headings first, token counts second. A chunk that starts mid-sentence in section 4.2 and ends mid-table in 4.3 answers no question well.
  • Keep tables and code blocks atomic. A half-table is worse than no table — the model will read the surviving half as the whole truth.
  • Prepend the breadcrumb. A chunk that says "the limit is $50" is useless without knowing it came from Refunds → Enterprise plan → Exceptions. Prefixing each chunk with its heading path is the cheapest retrieval improvement I know:
[Refund Policy > Enterprise Plan > Exceptions]
For enterprise accounts, refund requests beyond 30 days
require approval from the account manager. The limit is $50
per line item unless...
  • Size for the question, not the document. Policy lookups want tight chunks (200–400 tokens). Narrative docs tolerate bigger ones. When in doubt, chunk small and let the retriever fetch neighbors — expanding context at query time is easy; un-mixing a bloated chunk is not.

Retrieval: hybrid or you will get burned

Pure vector search fails in embarrassing, predictable ways on enterprise data. The query "error QB-1147" embeds near nothing useful, because embedding models treat part numbers, error codes, SKUs, and internal project names as noise — and enterprise queries are full of exactly those.

So: hybrid retrieval — dense vectors plus keyword/BM25 — fused and then reranked. In practice:

  1. Run vector and keyword search in parallel.
  2. Fuse the result lists (reciprocal rank fusion is simple and hard to beat).
  3. Apply metadata filters before or during retrieval — the user's permissions, the product line, the date range. Filtering after retrieval means your top-k was spent on documents you then throw away.
  4. Rerank the top ~50 with a cross-encoder down to the 5–8 you actually put in context.

The reranker matters more than people expect. First-stage retrieval is recall-oriented and sloppy; the reranker is where precision comes from. It's also where you inject business logic — boost the current policy version, demote the OCR-derived chunks, prefer the customer's own tenant docs over generic ones.


Citations are the product, not a garnish

In an enterprise setting, an answer without a source is a liability. The person asking is going to act on it — approve a refund, quote a policy to a customer — and when it's challenged, "the AI said so" is not a defense.

What I build now, every time:

  • Every retrieved chunk carries a stable ID and source URL through the whole pipeline, into the prompt, and out into the response.
  • The model is instructed to cite per-claim, not per-answer — inline markers that map back to chunk IDs.
  • The UI shows the excerpt, not just a link. Letting the user see the exact supporting passage converts "do I trust this bot?" into "do I trust this document?" — a much easier question.
  • No retrieval, no answer. If nothing relevant came back above a confidence floor, the correct output is "I couldn't find this in the knowledge base," with an escalation path. An eloquent unsupported answer is the worst possible outcome, because it's the one nobody catches.

Citations also give you your best eval signal for free: spot-check whether the cited passage actually supports the claim. That one check catches most hallucination in RAG systems.


Keeping the index fresh, or: RAG is a data pipeline

The demo indexes once. The product re-indexes forever. Enterprise knowledge changes daily — policies update, products launch, people edit the wiki — and a stale index is quietly worse than no index, because it answers confidently from the old world.

Treat freshness as a first-class requirement:

  • Incremental sync, not nightly rebuilds. Track content hashes per document; re-chunk and re-embed only what changed. Full rebuilds are how you end up with a 6-hour window where search is degraded.
  • Deletes must propagate. When legal pulls a document, its chunks must leave the index now — not at the next rebuild. Deletion is the freshness path that gets forgotten and the one with real consequences.
  • Watch staleness as a metric. Median age of retrieved chunks, percentage of queries answered from documents older than N months. When those drift, you find out from a dashboard instead of a customer.
  • Embed versioning. When you upgrade embedding models, you re-embed everything — old and new vectors don't live in the same space. Plan for that migration on day one; it's miserable to improvise.

When RAG is the wrong tool

The failure I see most often in the field isn't a bad RAG pipeline — it's a good RAG pipeline aimed at a non-RAG problem. Skip RAG when:

  • The question is analytical, not textual. "What were refund totals by region last quarter?" is a SQL question. Retrieving prose about refunds and hoping the model does arithmetic is malpractice — give the agent a query tool instead (tool design is its own discipline).
  • The corpus fits in context. If the entire knowledge base is 80 pages and rarely changes, put it in the prompt with caching and skip the whole pipeline. Long context plus prompt caching killed small-corpus RAG, and that's fine.
  • The answer must be exact and current. Account balances, inventory, order status — that's an API call, not a similarity search. Retrieval over yesterday's snapshot of live data is a bug that looks like a feature.
  • The real problem is that the docs are wrong. RAG faithfully retrieves whatever exists. If the knowledge base contradicts itself, the fix is editorial, not architectural. I've told customers this to their faces; it's never popular and always true.

RAG earns its complexity when the corpus is large, textual, changing, and the answers need grounding. Otherwise, reach for something simpler.


The takeaway

Enterprise RAG is 20% retrieval algorithms and 80% data engineering: parsing structure, curating versions, chunking along document boundaries, fusing dense and sparse retrieval, citing everything, and keeping the index honest as the world changes underneath it. Get the boring parts right and even a modest embedding model performs. Get them wrong and no amount of reranking will save you.


Related reading

Available for senior AI / contract / FDE work

Building something with AI?

Voice agents, MCP servers, LLM pipelines, agentic workflows — pick a slot, drop a message, or send your email and I'll reply within a day.

or leave your email

Replies within ~24 hours · Remote-first · global · open to relocation