Enterprise RAG Architecture: From Prototype to Production-Ready Systems

    This article examines why a working RAG prototype often fails in enterprise settings and what it actually takes to ship one. Using a benchmark of 30 synthetic contracts across 10 projects, it compares baseline RAG, knowledge pre-compilation, and a controlled-schema hybrid approach. It breaks down the strengths and risks of pre-compiled intermediate layers and structured navigation, then proposes a layered architecture that assigns deterministic work to structured fields and relational tables, fuzzy recall to vector search, and citations to source text. It also covers ingestion and retrieval design, permission filtering, evaluation metrics, and common pitfalls.

    1. The Starting Problem: “It Runs” Is Not “It Ships”

    Knowledge base pre-compilation and automated knowledge graphs are both getting a lot of attention in the community right now. One approach focuses on processing knowledge ahead of time into a reusable intermediate layer; the other emphasizes letting agents navigate a structured map instead of scanning raw files from scratch every time. Both look like reasonable ways to upgrade an enterprise retrieval-augmented generation (RAG) system. In real scenarios like contracts, tendering, and after-sales support, though, the answer is more complicated.

    Here is the core judgment: the optimal solution for a personal knowledge base is usually not the optimal solution for an enterprise knowledge base. There are parts worth borrowing. Traditional RAG does lack a knowledge pre-compilation layer, and that idea is worth absorbing. Agents also do not need to start from raw documents every time, so structured navigation matters too. But what enterprise RAG is really missing is not another flashy component. It is five foundational engineering capabilities:

    • Controlled schema (field definitions that are governed and validatable)
    • Structured fields (amounts, timelines, and acceptance criteria that can be compared precisely)
    • Source citations (every conclusion traceable to a clause location)
    • Permission boundaries (different roles see different scopes)
    • Repeatable evaluation (the same question set can be re-run as a regression check)

    This article uses one unified benchmark to compare baseline RAG, a small-sample knowledge pre-compilation approach, and a controlled-schema hybrid approach on the same set of questions. It also discusses where models, vector stores, structured fields, relational tables, and high-frequency summary pages each belong.

    2. Benchmark Design: Why 30 Contracts

    No matter how long a single document is, the questions tend to concentrate on four things: parsing, chunking, retrieval, and citation. What actually pushes a system to its limits is the relationships across a batch of files.

    Contract scenarios have this characteristic naturally. A master contract, technical agreement, supplementary agreement, acceptance form, and after-sales agreement are not isolated from one another. They stack up layer by layer around the same project. One level deeper, there are business fields like amount, timeline, acceptance criteria, penalty percentage, and warranty period, and later-signed documents often revise earlier clauses.

    The benchmark is therefore designed as 30 synthetic contracts covering 10 projects, with 3 to 5 related documents per project, and it deliberately plants three types of difficulty:

    1. Cross-document revisions: a supplementary agreement overrides the master contract’s amount and timeline, testing whether the system cites invalidated clauses.
    2. Field-level conflicts: the acceptance form and after-sales agreement describe the warranty period inconsistently, testing conflict detection and flagging.
    3. Permission differences: different roles can only see some projects, testing whether filtering happens before retrieval.

    3. Breaking Down the Two Approaches

    3.1 Knowledge Pre-Compilation: Moving Repeated Reasoning Forward

    The core idea is to compute high-frequency reasoning results ahead of time into intermediate pages (project overviews, clause indexes, FAQ summaries). Retrieval hits the intermediate layer first, then drills down to the source text. The benefits are lower latency and cost, plus better answer consistency. The risk is that once the intermediate layer goes stale, it keeps contaminating answers, so it must be bound to versioning and invalidation policies.

    3.2 Structured Navigation: Let the Agent Read the Table of Contents First

    The core idea is to return the document tree, section structure, and entity relationships first, so the agent decides which document to read and which section to open, instead of stuffing the context with candidate fragments all at once. The benefits are better context utilization and explainability. The risk is that the navigation structure itself needs maintenance, and a wrong structure amplifies errors.

    4. The Hybrid Approach: Layered Responsibilities

    The recommended approach is to layer by a “determinism first” principle: the higher the layer, the more structured and validatable it is.

    Layer Contents Main Responsibility
    Structured field layer Amounts, timelines, warranty periods, etc. Precise filtering and numeric comparison
    Relational table layer Project-document-revision chains Version tracing, conflict localization
    Vector retrieval layer Semantic recall of passages Fuzzy questions, natural language phrasing
    Summary page layer High-frequency project Q&A summaries Lower latency, consistent answers
    Source layer Clause text and positions Citation traceability, final authority

    Illustrative ingestion validation logic (pseudocode):

    1. def ingest(doc, project_id):
    2. fields = extract_fields(doc) # controlled schema validation
    3. assert schema.validate(fields), "invalid fields"
    4. rel = link_revision(doc, project_id) # build revision relationships
    5. chunks = split_with_anchor(doc) # chunk while keeping clause anchors
    6. index.upsert(chunks, meta={
    7. "project": project_id,
    8. "version": doc.version,
    9. "acl": doc.acl, # push permission labels down with the index
    10. "fields": fields,
    11. })
    12. return rel

    On the retrieval side, permission filtering should also be pushed ahead into the recall stage rather than trimming after generation:

    1. def retrieve(query, user):
    2. cand = vector.search(query, filter={"acl": user.groups})
    3. rows = rel_table.path(cand, project=user.projects)
    4. return rerank(cand, rows, prefer="latest_version")

    5. Evaluation and Common Pitfalls

    The evaluation set should fix the questions, fix the criteria, and fix the thresholds, support one-click re-runs, and retain historical results. It should focus on four metrics: field accuracy, citation traceability rate, stale-clause mis-citation rate, and unauthorized hit count.

    There are three common pitfalls. First, treating the intermediate layer as the authoritative source, which cements errors. Second, doing only semantic recall without field constraints, which almost guarantees wrong answers on numeric questions. Third, mixing the evaluation set with tuning samples, which inflates metrics but degrades immediately after launch.

    6. Conclusion

    Knowledge pre-compilation and structured navigation are valuable references, but the reliability of an enterprise knowledge base comes from a foundation of controlled schema, structured fields, source citations, permission boundaries, and repeatable evaluation. Put the model in charge of generation and extraction, the vector store in charge of fuzzy recall, relational and field tables in charge of deterministic judgment, and summary pages in charge of high-frequency acceleration. When each layer does its own job, you get an engineering path that can actually evolve.