Enterprise RAG: giving AI access to hundreds of thousands of documents without leaks
Why naive RAG fails inside a company, how to enforce access rights in vector search, and why exact source citations matter.
The idea behind RAG (Retrieval-Augmented Generation) sounds simple: instead of squeezing all of a company’s knowledge into neural network weights, the system finds the relevant fragments in an internal archive and passes them to the model along with the user’s query.
In a real corporate deployment, however, the naive approach collapses quickly. Once the volume of documents reaches hundreds of thousands of pages, two critical problems emerge: irrelevant answers caused by broken structure, and leaks of confidential information between departments. Neither is visible in a demo with ten files — and both surface in the first month of real use.
A language model is not a database
The first thing to understand: the quality of a corporate assistant depends almost entirely on the precision of retrieval, not on the size of the model. If the system retrieved the wrong section or an outdated version of an order, the most expensive model in the world will generate a confident, wrong answer.
This is easy to see: ask any system about a document you know well. A system that works gives an answer you can confirm by following a link. A system that only demos gives an answer that looks plausible — and it cannot be checked, because the link is missing or points to the wrong place.
Access rights at the retrieval stage
In a standard consumer implementation, all documents are loaded into a single vector space. If an intern asks, “What is the top-management bonus budget for next quarter?”, the basic system will obediently find a fragment of a confidential file and compose an answer.
Enterprise RAG must filter access before retrieval, not after:
- Pre-retrieval filtering: the vector query carries the user’s identifier and their list of roles. The database returns only the fragments this user is formally entitled to access in the corporate directory.
- Separate vector spaces: for the most sensitive data, dedicated indexes that physically do not intersect with the general corpus.
Checking permissions after retrieval is a common mistake: once a fragment has entered the model’s context, it has already been “read,” even if the answer is filtered on the way out.
Honesty requires saying this plainly: filtering at the retrieval stage is not a “checkbox in settings” but an architectural decision. Rights must live next to the vector index, stay synchronized with the corporate directory, and be checked on every request. If a vendor says “we’ll filter the answer,” ask what exactly happened to the fragment before the filtering.
- 01
User query
The question plus the user's roles and permissions
- 02
Filtered search
The system searches only among permitted documents
- 03
Answer with sources
File, page, quote — ready for verification
Document structure is not a detail but the foundation
The second common mistake is slicing documents into fixed-size chunks. A contract or a report cannot be cut into arbitrary 500-character segments: section headings get torn from their bodies, clause numbers get lost, and table rows get shuffled together.
What must be preserved:
- section headings as part of each fragment;
- clause and article numbers;
- integrity of table rows — price, quantity, and name must stay together;
- the document’s date and version in the fragment’s metadata.
Without this, the model loses the context of financial figures and answers “approximately,” which for accounting is the same as “incorrectly.”
A separate painful case is versions. In every company older than a year, there are at least two copies of any important regulation: the current one and the one sitting in an old folder. If the index does not distinguish versions by metadata, the system will retrieve both with equal probability — and the answer will be an “average” of the two editions. A human will not spot such an answer right away, and errors of this type destroy trust in the system faster than any leak.
That is why repository structure is not “standard pre-launch work” but part of the system itself. Change orders, effective dates, labeling of archived documents — all of this is metadata without which search answers correctly only by accident.
Verified sources
Every answer from a generative system in a business must be verifiable within seconds. A useful Enterprise RAG always returns:
- a direct link to the source file in the repository;
- the exact page or section number;
- a quote from the source on which the statement is based.
This changes the role of the system: an employee does not “ask a chatbot and believe,” but receives a working hypothesis with a reference to a document. Checking a conclusion takes one click, not half an hour of searching through shared drives.
For legal and finance teams, citations are not a convenience but a way of working. A conclusion without a reference does not belong in a memorandum; a conclusion citing a specific contract clause moves forward without additional verification. The difference is measured in days on every request.
What this gives the company
Together, access filtering, preserved structure, and exact citations turn RAG from a demo into a working tool:
- a new hire finds the right regulation in minutes instead of days;
- lawyers check positions against specific contract clauses;
- accountants see current versions of orders, not stale copies;
- confidential documents stop “seeping” between departments through shared search.
A natural side effect is tidier documents overall. For the system to work, the repository has to be cleaned up: folders structured, version owners assigned, current files separated from archived ones. Many companies put this off for years; deploying corporate search turns the cleanup into a condition of success.
Engineering effort shifts accordingly from choosing a model to preprocessing: cleaning metadata, marking up structure, and separating access rights. That is where the quality of a corporate assistant lives. So deployment should start not with “which model should we pick” but with “what is in the repository, and who is entitled to what.”