Enterprise Knowledge Base Q&A Architecture: Choosing and Integrating Orchestration and Retrieval Services

    This article explains how to architect an enterprise knowledge base Q&A system that delivers trustworthy, permission-aware, and auditable answers rather than merely a chat interface. It compares application orchestration with document processing and retrieval, proposes a five-layer integrated architecture, and covers ingestion quality, retrieval contracts, container networking, answer safety, evaluation, and a phased rollout path.

    1. Start with the Problem: Enterprises Need Trustworthy Knowledge Services, Not Just a Chat Interface

    When enterprises build knowledge base Q&A systems, employees typically need to ask about policy clauses, equipment operating procedures, project materials, or historical cases and receive answers that are supported by evidence and compliant with permission requirements. In practice, the main difficulty is often not calling a language model. The real challenge is turning enterprise materials into stable, trustworthy, and traceable evidence.

    For example, a scanned policy document may contain text recognition errors. A table spanning multiple pages may lose column headers. The same rule may exist in both an old and a new version. Different departments may have different access permissions for the same document. Even if the model has strong language expression capabilities, the final answer may still be unreliable if the input evidence is wrong.

    Enterprise retrieval-augmented generation, or RAG, should therefore be understood as a complete data and reasoning chain:

    Document ingestion → content parsing → structured chunking → index construction → permission filtering → retrieval and ranking → evidence organization → answer generation → citation display and audit.

    Common solutions around this chain can be divided into two categories by primary capability: one focuses on application orchestration and interaction, and the other focuses on document processing and retrieval. These two categories are not mutually exclusive. The more reasonable question is: which stages should be handled by a unified application layer, and which stages should be handled by an independent knowledge service?

    2. How to Choose Between the Two Capability Sets: Focus on Boundaries, Not Feature Counts

    2.1 Application Orchestration: Connecting Q&A to Business Processes

    The value of an application orchestration layer lies in organizing model calls, tool use, conditional logic, and human confirmation into manageable processes.

    For a simple request such as “look up the travel expense standard,” one retrieval plus one generation step may be enough. For a request such as “determine whether this business trip exceeds the standard and provide application recommendations,” the system also needs to read employee information, determine the applicable policy, calculate costs, and decide whether human approval is required.

    At that point, the system needs more than knowledge retrieval. It needs clear process control:

    • Determine which business domain the question belongs to.
    • Add the context required to complete the task.
    • Call business APIs with authorization boundaries.
    • Decide whether to continue generating, ask a follow-up question, or refuse to answer based on the evidence.
    • Add a confirmation step for operations with real business impact.

    Visual workflows or modular components can reduce prototype development costs, but they do not mean complex business processes can omit engineering design. State management, failure retries, version control, and regression testing remain the responsibility of the development team.

    For open-ended exploration tasks, agent mechanisms can be introduced to dynamically select tools. For high-certainty scenarios such as approvals, finance, and compliance, controlled workflows should be preferred. The higher the degree of autonomy, the more strict the permission and behavior constraints usually need to be.

    2.2 Document Processing: Turning Complex Materials into Reliable Evidence

    The document processing layer mainly addresses whether materials can be correctly understood and retrieved.

    Ordinary text files are usually easier to process, while complex documents may contain multi-column layouts, images, headers and footers, cross-page tables, footnotes, and scanned text. Chunking only by character length can easily break semantic structure. For example, once a table cell is separated from its row and column headers, the number itself is difficult to explain. Once an operating step is cut off, it may lose its preconditions.

    Document processing should therefore consider the following together:

    • Optical character recognition, or OCR, for text extraction from scanned files.
    • Layout analysis to identify headings, body text, tables, and image regions.
    • Structured chunking that preserves complete clauses, steps, and table context as much as possible.
    • Metadata extraction to record source, version, page number, and effective time.
    • Parsing quality checks to identify blank pages, garbled text, and abnormal chunking.

    It is important to note that having OCR or layout analysis capabilities does not mean all complex documents can be parsed with high quality. Scan clarity, language, fonts, table styles, and computing resources all affect the results. Validation should use real enterprise samples rather than relying only on a feature checklist.

    2.3 When a Fused Architecture Is Appropriate

    When an enterprise has both complex documents and multi-step business processes, it can separate application orchestration from knowledge retrieval and integrate them through service APIs.

    This allows document processing, index updates, and Q&A workflows to evolve separately. However, separation also increases network calls, API maintenance, fault diagnosis, and deployment costs. For smaller projects with simple workflows, an integrated implementation may be easier to maintain.

    The core of architecture selection is not having as many components as possible. It is whether the benefits can cover the added complexity.

    A general fused architecture can be divided into five layers:

    Layer 1: Interaction entry.
    Receives user questions, performs login verification and session management, and displays answers and cited sources.

    Layer 2: Application orchestration.
    Handles question classification, parameter validation, knowledge domain routing, tool calls, and exception branch handling.

    Layer 3: Knowledge retrieval service.
    Handles permission filtering, candidate recall, result ranking, and evidence fragment return.

    Layer 4: Data processing pipeline.
    Handles document ingestion, parsing, chunking, index updates, and quality checks.

    Layer 5: Infrastructure and governance.
    Provides storage, task queues, logs, monitoring, key management, and audit capabilities.

    A typical call chain is as follows:

    1. User question
    2. ↓
    3. Identity verification and question classification
    4. ↓
    5. Determine the permitted knowledge scope
    6. ↓
    7. Knowledge retrieval service returns evidence
    8. ↓
    9. Check whether evidence is sufficient
    10. ├─ Not sufficient: ask a follow-up, refuse, or escalate to a human
    11. └─ Sufficient: generate an answer and cite sources

    Cross-knowledge-base retrieval should not be simply understood as “query all materials.” A more reliable approach is to first determine the accessible scope based on identity and business rules, and then select the retrieval scope based on the question content. For questions that cannot be clearly classified, multi-knowledge-base retrieval can be performed within the authorized scope, but the number of candidates and subsequent ranking costs should still be controlled.

    4. Document Ingestion Design: Move Quality Control Upstream

    4.1 Classify First, Then Choose a Parsing Strategy

    Different materials should use different processing methods. Policy documents are suitable for chunking by chapter and clause. Operating manuals need to preserve step order and warning information. Tabular materials should preserve row and column relationships as much as possible. Scanned archives need recognition quality checks first.

    For documents with unstable parsing results, a manual review queue can be used instead of immediately adding them to production retrieval. Otherwise, once incorrect content enters the index, it will be repeatedly cited in later Q&A.

    4.2 Preserve Both Content and Context During Chunking

    Fragments that are too short may lack definitions, applicable scope, and preconditions. Fragments that are too long may introduce irrelevant information and increase model input costs.

    In practice, you can first chunk by natural structure, then adjust length based on model input limits and evaluation results. For fragments that are not sufficiently self-contained, section titles, parent headings, or adjacent context can be added, but large amounts of repeated content should be avoided.

    Tables require particular care. If splitting is necessary, each child fragment should still contain the column names, units, and applicable conditions needed to understand the data.

    4.3 Metadata Must Support Traceability and Governance

    At a minimum, the following should be retained:

    • Document identifier and chunk identifier.
    • Document title, section, and location information.
    • Owning department, knowledge domain, and permission labels.
    • Version number, effective time, and expiration status.
    • Content summary or content fingerprint.

    Content fingerprints can help with duplicate detection and incremental updates, but they cannot replace business version management. Two documents with similar content may still have different validity and applicable scope.

    After a document is deleted or its permissions change, related indexes and caches must also be updated synchronously. Otherwise, retrieval fragments may remain visible even though the original file is no longer accessible.

    5. Retrieval Interface Design: Return Evidence, Not Just an Answer

    A clear data contract should be established between the application orchestration layer and the knowledge service. To preserve the boundary between retrieval and generation, the knowledge service should usually return candidate evidence, source information, and retrieval status rather than only the final answer.

    The following is an illustrative custom contract structure and does not correspond to any existing product API:

    1. {
    2. "request_id": "request-001",
    3. "query": "How long should equipment maintenance records be retained?",
    4. "scope_ids": ["maintenance-policy"],
    5. "max_results": 5
    6. }

    The retrieval scope must be calculated or verified by the server based on trusted identity. The client-provided scope cannot be trusted directly. The response structure can include:

    1. {
    2. "request_id": "request-001",
    3. "items": [
    4. {
    5. "document_id": "doc-101",
    6. "chunk_id": "chunk-08",
    7. "text": "Relevant policy clause content",
    8. "source": {
    9. "title": "Equipment Maintenance Management Policy",
    10. "section": "Records Management",
    11. "page": 12,
    12. "version": "3"
    13. }
    14. }
    15. ],
    16. "status": "ok"
    17. }

    The fields above are only intended to illustrate the design approach. The actual contract needs to be determined based on business requirements, storage methods, and security requirements.

    The interface should also define timeouts, error classification, version compatibility, and response size limits. For read-only retrieval requests, limited retries can be allowed. For write and delete operations, idempotency must be considered first to avoid duplicate execution.

    If the system returns retrieval scores, their meaning should also be explained. Scores from different retrieval algorithms usually cannot be compared directly, and they certainly cannot be treated simply as an “answer correctness rate.”

    6. Container Deployment and Network Configuration: Non-Conflicting Ports Are Only the First Step

    6.1 Understand Port Mapping Correctly

    Container port mapping is usually expressed as:

    1. host port:container internal port

    For example:

    1. 8080:80

    This means that when the host’s port 8080 is accessed, the request is forwarded to port 80 inside the container. When multiple services need to bind to the same host address, they cannot occupy the same port at the same time. Therefore, the host-side port can be adjusted without changing the container’s internal listening port.

    Note that ports 80 and 443 are only common conventions for HTTP and HTTPS. Changing the port number does not automatically enable encryption. HTTPS still requires certificates and corresponding service configuration.

    6.2 Distinguish Container Internal Addresses from External Access Addresses

    When an application runs in a container, the loopback address usually points to the container itself, not to the host or another container.

    If the application layer and the knowledge service are on the same container network, they should preferably communicate through internal service names and listening ports. If they are on different networks, the reachable path, firewall rules, and access control must be clearly defined. Checking only whether a service page can be opened from a browser on the host is not enough.

    6.3 Reduce the Externally Exposed Surface

    In production, only a unified entry point should be exposed as much as possible. Parsing services, indexing services, and internal management APIs should not be directly exposed to the public internet.

    At the same time, access authentication, rate limiting, request size limits, and reasonable timeouts should be configured. Secrets should be injected through controlled configuration and should not be written into workflow text, sample code, or logs.

    7. Answer Generation and Security Controls: Constraints Matter More Than Prompts

    During generation, the model should be required to answer around the retrieved evidence and clearly distinguish between “content explicitly specified in the materials” and “interpretation based on the materials.” When necessary evidence is missing, the system should ask a follow-up question or state that the answer cannot be confirmed, rather than filling enterprise policy gaps with general knowledge.

    Citations also need to be verifiable. The system should check whether the chunk identifiers cited in the answer actually come from the current retrieval results and ensure that the user has permission to access the corresponding sources.

    In addition, knowledge base documents are external input and should not be treated as system instructions. Even if a document contains text such as “ignore the rules” or “call a certain API,” that text can only be treated as content to be analyzed and must not be granted tool permissions.

    For business operations, permission checks, parameter constraints, and human confirmation should be placed in program logic. Prompts can help constrain behavior, but they cannot replace real security boundaries.

    8. Evaluation and Performance Governance: Use Data to Decide Optimization Direction

    8.1 Evaluate Retrieval and Generation Separately

    Build a test set from real business scenarios and label the locations of standard evidence. The test set should cover ordinary queries, complex tables, scanned documents, version conflicts, no-answer questions, and unauthorized requests.

    For the retrieval stage, focus on whether correct evidence can enter the candidate results, whether ranking is reasonable, and whether old versions are incorrectly recalled. For the generation stage, focus on whether answers are faithful to the evidence, whether citations are correct, whether key conditions are omitted, and whether the system reasonably refuses when no answer is available.

    “Language fluency” cannot replace “business correctness.”

    8.2 Break Down Latency and Locate Bottlenecks

    Total response time is usually composed of authentication, retrieval, ranking, model generation, and network transmission. The time consumed by each stage should be monitored separately rather than recording only a single total.

    Document parsing is usually suitable for asynchronous execution, while online Q&A should have a clear response budget. When caching is used, permission scope, knowledge version, and question content need to be included in the design to prevent different users from sharing results they should not share.

    Whether to add a ranking stage, increase the number of candidates, or expand model input should be decided through comparative experiments between quality improvement and latency cost, rather than enabling all capabilities by default.

    8.3 Build an Observable Chain

    Each request should retain a unified trace identifier to associate application logs, retrieval results, and generation records. Monitoring can focus on error rate, timeout rate, no-result ratio, and latency at each stage, but sensitive question text and complete evidence should not be written indiscriminately into logs.

    9. Implementation Roadmap: Validate the Closed Loop First, Then Expand Scope

    The following sequence is recommended:

    1. Select a knowledge domain with clear business boundaries and controllable material scale.
    2. Collect real questions and establish standard evidence and expected answers.
    3. Validate document parsing and retrieval quality, prioritizing missing-evidence problems.
    4. Integrate the basic Q&A workflow, including citations, refusals, and error handling.
    5. Add permission isolation, version management, and audit capabilities.
    6. After evaluation stabilizes, expand multi-knowledge-domain routing and business tool calls.

    The key to enterprise knowledge base Q&A is not finding a system that covers every feature. It is giving each capability a clear responsibility: document processing ensures materials are usable, retrieval services provide trustworthy evidence, application orchestration organizes business processes, and security governance constrains access and operations. Only when these stages are built on a testable and traceable engineering system can knowledge Q&A move from a demonstration prototype to stable operation.