Enterprise Knowledge Base Q&A: Architecture Choices and Implementation

    \$\$This article explains how to choose an architecture for enterprise knowledge base Q&A by treating it as a capability layering problem rather than a single framework decision. It compares deep document processing with workflow orchestration, outlines a layered "orchestration plus retrieval service" design, and covers port and network planning, indexing and retrieval tuning, evaluation, security, operations, and a phased rollout.

    \$\$## 1. The Real Problem: Capability Layers, Not Either-Or

    When enterprises build knowledge base Q&A systems, the common debate is “which framework should we pick?” From an engineering perspective, this is better framed as a capability layering problem: one layer turns unstructured documents into high-quality retrievable chunks, and another layer orchestrates retrieval results into deliverable business workflows. The two layers have completely different technical challenges, iteration cadences, and team skill requirements. Forcing them into a single component tends to expose weaknesses when complex documents and complex workflows appear at the same time.

    A more reliable rule of thumb: when document formats are complex (scanned files, complex tables, reports with arbitrary layouts), prioritize strengthening the parsing and indexing layer; when the business needs multi-model collaboration, branching workflows, human review, and external tool calls, prioritize strengthening the orchestration layer. Decoupling the two through interfaces lets each evolve independently.

    2. Differentiated Positioning of the Two Capabilities

    The core value of deep document processing is parsing quality. In real enterprise corpora, PDF headers and footers, cross-page tables, text inside images, formulas, and footnotes all break chunking semantics. Mature solutions typically provide layout analysis, optical character recognition, table structure reconstruction, and multiple chunking templates, so they can select a strategy per document type and output chunks with position information for tracing back to the source.

    The core value of workflow orchestration is controllability. It provides visual node orchestration, conditional branching, variable passing, tool invocation, and human-in-the-loop points, upgrading Q&A from “one question, one answer” to multi-step tasks. In addition, cross-knowledge-base routing (automatically selecting the retrieval scope based on the question) can significantly reduce noise in multi-business-line scenarios.

    Neither capability is inherently superior; the difference shows up in workload characteristics. Parsing and vectorization are compute-intensive offline tasks that can be batched, while online Q&A is sensitive to time-to-first-token latency and concurrency stability. Architecture design should therefore deploy the offline pipeline and the online pipeline separately and scale them independently.

    3. Combined Architecture: Orchestration as the Core, Retrieval as a Service

    The recommended shape is a layered structure of “main framework + retrieval service”:

    1. Access layer: unified authentication, tenant isolation, audit logs, and rate limiting.
    2. Orchestration layer: intent recognition, multi-turn context management, tool invocation, result reranking, and response generation.
    3. Retrieval service layer: exposes common interfaces for document ingestion, parse task status queries, retrieval, and reranking.
    4. Data layer: object storage holds original files, a relational database holds metadata, a vector index holds chunks, and a cache layer holds high-frequency Q&A.

    Illustrative call flow (pseudocode, showing call order only):

    1. # 1) Offline ingestion: submit a parse task and poll its status
    2. task = client.create_parse_task(file_uri="oss://kb/hr/handbook.pdf",
    3. chunk_policy="layout_aware")
    4. while client.get_task(task.id).status == "running":
    5. sleep(2)
    6. # 2) Online Q&A: the orchestration layer triggers retrieval, then hands off to the generation node
    7. hits = client.retrieve(query=user_query, top_k=8,
    8. filters={"tenant": "hr", "acl": user.dept})
    9. context = rerank(hits, query=user_query)[:5]
    10. answer = llm.generate(prompt=build_prompt(context, user_query),
    11. temperature=0.1)

    The engineering key points: the retrieval service exposes only a stable contract, and the orchestration layer stays unaware of the underlying index implementation; permission filtering must be pushed down to the retrieval stage rather than trimmed after generation, otherwise unauthorized information can leak.

    4. Ports and Network Planning During Deployment

    Both are commonly deployed via container orchestration, and the easiest pitfall when starting them on the same host is port conflicts. In a container orchestration file, the port mapping format is “host port:container port”; for example, 80:80 forwards host port 80 to container port 80, where port 80 inside the container usually serves plain HTTP and 443 serves encrypted HTTPS.

    The guiding principle: change only the host-side port and keep the container-internal port unchanged, avoiding modifications to the application’s default configuration. For example, change 80:80 to 8080:80 and 443:443 to 8443:443:

    1. services:
    2. retrieval:
    3. ports:
    4. - "8080:80"
    5. - "8443:443"
    6. orchestration:
    7. ports:
    8. - "3000:3000"

    It is also advisable to unify the entry point at a reverse proxy layer and forward by path prefix (for example, /kb/ to the retrieval service and /chat/ to the orchestration layer), exposing only a single domain and certificate externally, while internal services communicate through container network aliases to reduce the cross-host exposure surface.

    5. Tuning Checklist for Indexing and Retrieval Quality

    • Chunking strategy: chunk by layout and heading hierarchy, keep chunk length in the hundreds-of-characters range with overlap, and split tables by row groups with the header attached.
    • Metadata design: store document type, effective date, department, classification level, and version number, then apply structured filtering at retrieval time; this greatly reduces problems like “outdated policies being recalled.”
    • Hybrid retrieval: keyword retrieval handles proper nouns and identifiers, vector retrieval handles semantic similarity, and the two result sets are fused and then reranked.
    • Reranking and thresholds: set a relevance threshold and fallback phrasing; below the threshold, clearly answer “no supporting evidence found” instead of generating freely.
    • Citation traceability: attach chunk position information to answers so business teams can verify them; this is often the key to passing review in enterprise scenarios.
    • Incremental updates: route document changes through versioned index rebuilds and keep old versions for rollback.

    6. Evaluation, Security, and Operations

    Evaluation must be independent of demo results: build a fixed question set, separately measure recall hit rate, answer accuracy, citation verifiability, and time to first token, and run a regression after every change to chunking or prompts.

    Security needs to cover: encryption of data at rest, centralized key management, least-privilege retrieval by department, full Q&A audit trails, sensitive information masking, and output content compliance checks. For operations, make parse tasks an observable queue, monitor backlog volume, retry failures, and track index latency; for capacity planning, place offline tasks in a separate resource pool so bulk ingestion does not affect online Q&A.

    Start by validating parsing quality on a small set of real corpora, then connect the retrieval interfaces and orchestration flow, then add permissions and auditing, and finally run load tests and a canary release. If the enterprise already has general-purpose cloud capabilities, it can reuse infrastructure such as object storage, container platforms, message queues, logging, and monitoring alerts, and focus effort on parsing strategy and business orchestration, the two areas that truly determine results.