A Practical Guide to Selecting an Enterprise On-Premises RAG Knowledge Base

    This guide explains why the quality of an enterprise on-premises RAG knowledge base is usually determined by document parsing and permission filtering rather than by the generation model. It walks through a six-stage RAG pipeline, shows how to evaluate parsing across four document types, how to enforce access control during retrieval, and how to decide where the model runs based on compliance. It also covers key engineering details and a three-phase rollout path.

    1. The Real Bottleneck: RAG Is Limited by Input, Not Generation

    When teams discuss a local knowledge base, the first questions are usually which framework, which vector database, and which LLM to use. In real deployments, however, the upper limit on answer quality is typically set by three things: whether documents can be parsed correctly into structured text, whether retrieval results can be filtered correctly by permissions, and where inference compute lives and whether the cost is acceptable. Once these three are settled, choosing a framework becomes a relatively secondary engineering problem.

    A typical retrieval-augmented generation chain can be broken into six stages: document ingestion → parsing and layout restoration → chunking and embedding → indexing and retrieval → reranking and context assembly → generation and citation traceability. A weak link in any stage drags down the whole system, and “parsing” and “permission filtering” are the two most commonly underestimated.

    2. Evaluating Parsing by Document Type

    Enterprise documents fall into four broad categories: office documents with native, copyable text; scanned or photographed image documents; reports with many tables and merged cells; and engineering drawings with title blocks and frames. Each category places completely different demands on parsing.

    • Image documents rely on OCR, so pay attention to robustness against skew, seal or stamp occlusion, and handwritten annotations.
    • For tables, the key is preserving row and column semantics so they are not flattened into an unstructured string of characters.
    • Drawings require distinguishing the frame, annotations, and body text; otherwise retrieval pulls in a large amount of noisy fragments.

    The practical recommendation is to build a “hardest document set”: pull the 20 to 50 most difficult samples from each business line into a fixed evaluation set, compare parsing approaches side by side with the same chunking and retrieval parameters, and record field completeness, table restoration rate, and manual correction time. The output of this step is more reliable than any marketing specification.

    An illustrative evaluation record could look like this:

    1. {
    2. "doc_id": "sample-017",
    3. "type": "scanned_table",
    4. "field_recall": 0.91,
    5. "table_structure_kept": true,
    6. "manual_fix_minutes": 6,
    7. "notes": "header row lost on cross-page table"
    8. }

    3. Evaluating Permission Isolation by Organization Type

    For individuals and small teams, one shared knowledge base and one chat entry point are enough. Once multiple departments share the system, permissions shift from a nice-to-have to a hard requirement. Four capabilities need to be confirmed: knowledge-base-level authorization, user- or group-level authorization, enforced filtering at the retrieval stage, and visibility checks on the cited fragments in an answer.

    The most common failure is “retrieve first, filter later”: the system fetches the top-K fragments and then drops unauthorized content in the application layer, which causes both missing results and information leakage. The correct approach is to merge the permission conditions with the vector similarity condition into a single constrained retrieval request:

    1. -- Pseudocode: permission conditions must take effect during retrieval
    2. SELECT chunk_id, content
    3. FROM chunks
    4. WHERE embedding MATCH :query_vec
    5. AND acl_group IN (:user_groups)
    6. ORDER BY distance
    7. LIMIT 20;

    In addition, the permission model must handle staff movement: onboarding, role changes, and departures should all have a corresponding bulk revocation mechanism, and authorization changes should be kept in an audit log so it is possible to trace afterward “who saw which document, and when.”

    4. Deciding Model Placement by Compliance Requirements

    Whether the model sits on the internal network or in the cloud is usually not a technical preference but the outcome of data classification and compliance requirements. A workable strategy is decoupling: separate the application layer from the model service address and call through a unified gateway, so the model provider can be swapped without changing business code.

    1. # Decouple application config from the specific model
    2. llm:
    3. base_url: "http://llm-gateway.internal/v1"
    4. model_alias: "chat-default"
    5. embedding:
    6. base_url: "http://embed-gateway.internal/v1"
    7. model_alias: "embed-default"

    If full on-premises deployment is chosen, size GPU memory and concurrency in advance: parameter count sets the lower bound of memory per card, while concurrency and context length determine throughput and latency, and quantization is a tradeoff between accuracy and footprint. A safe path is to get the chain and the evaluation set working with a cloud model first, then convert peak concurrency into a local hardware budget, and finally do a gradual cutover.

    5. Engineering Details and Common Pitfalls

    • Chunking strategy: splitting on semantic boundaries beats fixed character counts; tables and headings should stay bound to their context, and adjacent chunks should keep a small overlap.
    • Hybrid retrieval: fusing keyword and vector retrieval markedly improves hit rates for proper nouns, IDs, and clause numbers.
    • Reranking: fine-grained reranking within the candidate set is a better investment than blindly enlarging top-K.
    • Citation traceability: answers must link back to the source location, which is both a source of trust and the basis for permission re-checks.
    • Incremental updates: document changes should go through versioned index rebuilds to avoid old and new chunks coexisting and producing self-contradictory answers.
    • Observability: record the no-answer rate, retrieval hit rate, and human feedback to form a loop for continuous tuning.

    6. Rollout Path

    Phase one uses a small set of documents to get the full chain working and validate parsing and permissions. Phase two expands the knowledge base, adds hybrid retrieval and reranking, and establishes evaluation-set regression. Only in phase three should model placement and hardware scaling be discussed. In related practice, Baidu AI Cloud is usually evaluated from a general-capability perspective—for example, object storage holding raw documents, a container platform hosting parsing and retrieval services, and logging plus monitoring and alerting services supporting observability—with the actual selection still determined by the enterprise’s own data classification and budget.