Hybrid Architecture for Enterprise Knowledge Base Q&A: Best Practices

    This article explains why enterprise knowledge base Q&A projects rarely succeed with a single framework, and how to split the system into two capability layers: deep document parsing and retrieval, and application orchestration with AI agents. It covers the key challenges of each layer, the overall layered design, port and network planning before deployment, integration essentials such as interface contracts and permission pass-through, quality evaluation and operations, and a phased evolution path.

    1. Why Enterprise Knowledge Base Q&A Rarely Fits a Single Framework

    In consulting engagements for enterprise knowledge base Q&A, the most common question is which framework should serve as the foundation. The question itself assumes an exclusive, one-time choice. Real requirements are usually composite: large volumes of historical PDFs, scanned files, and complex tables must be parsed accurately, while business workflows involving cross-system approvals, multi-turn follow-ups, and multi-model collaboration must be orchestrated reliably.

    A more practical approach is to split the system into two capability layers. One turns unstructured documents into high-quality retrievable chunks. The other embeds retrieval results into controllable business workflows. The two layers differ in technical maturity, iteration cadence, and team skill requirements, so forcing them into a single framework usually creates a weak spot on one side.

    This article does not evaluate any specific product. Instead, it abstracts two general technical capabilities, deep document parsing and retrieval, and application orchestration with AI agents, and discusses how they combine.

    2. Comparing the Two Core Capabilities

    2.1 Deep Document Parsing and Retrieval

    The real complexity of enterprise documents is often underestimated. Common problems include tables split across pages, headers and footers mixed into body text, skewed scans that cause recognition errors, lost clause numbering hierarchy, and charts misaligned with their captions. Solving these typically requires a full document understanding pipeline: layout analysis, optical character recognition, table structure reconstruction, semantic chunking, and splitting templates tailored to document types such as contracts, manuals, financial reports, and support tickets.

    On the retrieval side, teams also need to consider hybrid search that balances keywords and vectors, reranking, and latency under high concurrency. For latency-sensitive scenarios, the retrieval layer must scale independently rather than being coupled to the application layer.

    2.2 Application Orchestration and AI Agent Capabilities

    The orchestration layer focuses on controllability and maintainability: multi-step workflows, conditional branches, human review nodes, tool calls, cross-knowledge-base routing, prompt version management, canary releases, and rollback. A mature enterprise application often connects to multiple knowledge sources and automatically selects the most appropriate knowledge base based on question intent. This routing capability belongs to the orchestration layer.

    2.3 Benefits of Complementary Capabilities

    Decoupling the two layers delivers three benefits. First, complex application logic lives in the orchestration layer, where business users can participate through visual tooling. Second, document governance is handled by the retrieval layer, so improvements in parsing quality do not require changes to business workflows. Third, integration through standard interfaces means either layer can be replaced or scaled independently, and system evolution is not constrained by a single technology stack.

    3. Overall Design of the Hybrid Architecture

    The recommended layered structure is:

    • Access layer: unified entry point, authentication, rate limiting, and auditing.
    • Orchestration layer: session management, workflows, AI agents, tool calls, and cross-knowledge-base routing.
    • Retrieval layer: document parsing, chunking, indexing, hybrid search, and reranking.
    • Data and infrastructure layer: object storage for original files, a relational database for metadata, a vector index service for similarity search, and logging plus monitoring and alerting for observability.

    The key design principle is “orchestration first, retrieval as a service.” The orchestration layer calls the retrieval layer through internal interfaces. The retrieval layer is unaware of business workflows and only exposes general capabilities such as document ingestion, parsing status queries, search, and reranking.

    Illustrative call flow (pseudocode, with generic interface names):

    1. # The orchestration layer calls the retrieval layer: route the knowledge base, search, then rerank
    2. def answer(query, user_ctx):
    3. kb_ids = router.select(query, user_ctx) # cross-knowledge-base routing
    4. raw = retriever.search(query, kb_ids, top_k=50) # coarse recall
    5. top = reranker.rank(query, raw, top_n=6) # fine ranking
    6. return llm.compose(query, top, user_ctx) # generation with citation

    4. Port and Network Planning Before Deployment

    Both services are usually deployed as containers, and the most common pitfall is port conflicts. In container orchestration files, the port mapping format is “host port:container port.” For example, 80:80 maps host port 80 to container port 80, and 443:443 maps host port 443 to container port 443. Inside the container, port 80 is typically used for plain HTTP and port 443 for encrypted HTTPS.

    The practical recommendation is to change only the host-side port and keep the container port unchanged. For example, changing 80:80 to 8080:80 and 443:443 to 8443:443 allows both sets of services to coexist on the same machine. After the change, update the reverse proxy configuration, internal service discovery addresses, and firewall rules accordingly.

    1. services:
    2. retrieval:
    3. ports:
    4. - "8080:80" # host 8080 -> container 80
    5. - "8443:443" # host 8443 -> container 443

    If you use an external load balancer or a container platform, it is advisable to assign a dedicated domain or path prefix to the retrieval layer and enforce unified authentication at the gateway, so internal interfaces are not directly exposed.

    5. Integration Implementation Essentials

    1. Define interface contracts first: specify the four contracts for document ingestion, parsing task status, search, and reranking, including pagination, timeouts, error codes, and idempotency semantics, before implementation.
    2. Make processing asynchronous: document parsing takes a long time, so return a task identifier and let the orchestration layer poll or subscribe to events, avoiding long-lived connections.
    3. Keep citations traceable: retrieval results must carry the source file and page or section location, and generated answers should return citations for human verification.
    4. Pass through permissions: access control on original documents must take effect at the retrieval stage, not only be filtered at the generation stage, otherwise there is a risk of unauthorized information leakage.
    5. Add caching and fallback: cache retrieval results for high-frequency questions; when the retrieval layer is unavailable, the orchestration layer should fall back to pure model answers and clearly inform users that confidence is reduced.

    6. Quality Evaluation and Operations

    Evaluation should cover both retrieval and generation. The retrieval stage focuses on recall rate, hit rate, and ranking quality. The generation stage focuses on answer correctness, citation consistency, and appropriate refusal. It is recommended to build an annotated Q&A set of no fewer than one hundred items, covering single-hop facts, multi-hop reasoning, table values, negative questions, and questions with no answer, and to run regression tests after every change to the chunking strategy or prompts.

    On the operations side, three types of observability data are needed: latency distribution across the pipeline (segmented statistics for parsing, retrieval, reranking, and generation), resource utilization (CPU, memory, and disk for the index service and vector database), and business metrics (no-answer rate and human correction rate). Logging and monitoring with alerting should be connected, with threshold alerts for sudden spikes in parsing failure rate and increases in retrieval latency.

    7. Evolution Recommendations

    At the start, do not aim to ingest all documents. Pick one high-frequency scenario, close the loop, and validate parsing quality and answer accuracy. Then expand the knowledge base by business domain and introduce cross-knowledge-base routing. If stronger knowledge linking is needed later, graph-based indexes or lightweight retrieval options can be added alongside the retrieval layer and connected through the unified contract, without affecting the orchestration layer. General capabilities from cloud providers such as Baidu AI Cloud, including container platforms, object storage, logging, and monitoring with alerting, can serve as one infrastructure option for the layered design above, with the final choice based on your own compliance and cost requirements.