Architecture Selection and Integration Practices for Enterprise Knowledge Base QA Systems

    This article explores architectural choices and integration practices for building production-ready enterprise knowledge base QA systems. It covers application orchestration, knowledge processing, deployment, and governance to address challenges like document understanding, access control, and operational cost, helping developers make informed decisions between integrated and layered architectures.

    1. Clarifying the Problem: Enterprises Need More Than Just “Answers”

    When building a knowledge base QA system, enterprises typically aim to solve issues like policy querying, product documentation retrieval, IT operations knowledge reuse, and customer service assistance. During the prototyping phase, as long as uploaded files yield seemingly reasonable answers, the system is often considered complete. However, once deployed in a production environment, challenges usually emerge in the following areas:

    First, whether documents can be correctly understood. Scanned files, cross-page tables, complex layouts, and multi-column text may lose critical relationships during the parsing stage. Even with a stronger generation model later, it is hard to recover damaged evidence.

    Second, whether retrieval results are accurate and complete. Users might use abbreviations, colloquialisms, or historical names, while the knowledge base uses formal terminology. Some questions also require combining multiple documents.

    Third, whether answers can be integrated into business processes. Enterprise applications might need to identify user identity first, then query the knowledge base, call business APIs, and finally return results in a specific format.

    Fourth, whether permissions and operational costs are controllable. Data from different departments cannot be mixed, outdated content must be invalidated after updates, and model invocation costs, retrieval latency, and maintenance complexity must be managed.

    Therefore, the fundamental unit of architecture selection should be “capabilities and business requirements,” rather than a feature list of a specific framework.

    2. Splitting the System into Two Types of Capabilities Before Selection

    2.1 Application Orchestration Layer: Executing Business Tasks

    The application orchestration layer primarily handles the flow control after a user request enters the system, including question classification, conditional branching, model invocation, external API access, context organization, and result output.

    For instance, if an employee asks, “Can this expense be reimbursed?” the system cannot merely search policy clauses; it may also need to consider the employee’s department, expense type, date of occurrence, and approval status. Here, knowledge retrieval is just one step in the process.

    Key evaluation criteria for this layer include:

    • Whether the workflow is easy to understand, debug, and maintain;
    • Whether it can manage invocation configurations for different models;
    • Whether it supports input validation, timeout handling, and exception branching;
    • Whether external service calls have clear permission boundaries;
    • Whether it can log the processing steps a request goes through.

    For enterprise tasks with clear paths and stable rules, explicit workflows should be prioritized. Agents should only be considered when task steps are genuinely hard to predetermine, and their tool scope, execution limits, and sensitive operation permissions should be restricted. Flexibility does not automatically equate to reliability.

    2.2 Knowledge Processing Layer: Providing Credible Evidence

    The knowledge processing layer transforms raw materials into retrievable evidence, typically covering file ingestion, parsing, chunking, indexing, retrieval, reranking, and source location.

    Its core value is not “how many file formats are supported for upload,” but whether the parsed results retain the original semantics. For example, in an expense standard table, there is a correspondence between “region,” “personnel category,” and “quota.” If chunking only retains the values and loses the headers, the system might provide incorrect answers.

    When evaluating this layer, focus on:

    • Whether text sequence, heading hierarchy, and paragraph relationships are correct;
    • Whether tables retain headers, units, footnotes, and cross-page associations;
    • Whether OCR for scanned files meets business requirements;
    • Whether retrieved chunks can be traced back to their original position;
    • Whether file updates, withdrawals, and permission adjustments can be synchronized to the index;
    • Whether it can explain “why this content was retrieved.”

    These two types of capabilities can be provided by a single system or combined via APIs. However, combination itself is not the goal; adding system complexity is only worthwhile when it addresses a proven capability gap.

    3. Integrated or Layered Integration: Deciding Based on Constraints

    3.1 When to Choose an Integrated Architecture

    If materials are mostly clearly structured text, business processes are relatively simple, and the team size is limited, an integrated architecture is usually easier to close the loop. It reduces the workload of inter-service API adaptation, configuration synchronization, and troubleshooting.

    However, “integrated” does not mean “no evaluation needed.” You should still assess document parsing effectiveness, retrieval quality, permission mechanisms, and observability to avoid mistaking “easy deployment” for “production-ready.”

    3.2 When to Choose Layered Integration

    When an enterprise simultaneously needs complex document processing and complex business processes, the application orchestration layer can be separated from the knowledge processing layer.

    Its value is mainly reflected in three aspects:
    First, document processing can be optimized independently without rewriting user-facing business processes.
    Second, knowledge services can be centrally managed, allowing multiple business applications to reuse governed retrieval capabilities.
    Third, it facilitates independent scaling. Batch document parsing and online QA have different resource usage characteristics; splitting them allows for separate capacity planning.

    The corresponding costs must also be accounted for: cross-service calls increase latency and failure points; identity and permissions need to be passed across layers; citation formats need to be unified; and version upgrades may cause API compatibility issues. A “more modular” architecture diagram does not automatically mean it is more suitable for the enterprise.

    3.3 Use Real Samples Instead of Feature Impressions

    It is recommended to first build a set of representative test materials, including plain text, scanned files, complex tables, multi-version policies, and access-restricted documents.
    Then, prepare a set of business questions covering direct lookups, multi-document synthesis, conditional judgments, unanswerable questions, and unauthorized queries. Test candidate architectures separately and record failure reasons.

    If the main issues occur during the parsing stage, prioritize improving knowledge processing; if the evidence is correct but business steps frequently fail, optimize orchestration; if the issue is just unclear prompt expression, there is no need to rush to replace the entire system.

    A general enterprise knowledge base QA architecture can be represented as:
    User Request
    → Identity Authentication & Access Control
    → Application Orchestration Layer
    → Knowledge Retrieval Service
    → Evidence Filtering & Context Organization
    → Generation Model
    → Citation Validation & Result Return

    Document processing follows another pipeline:
    File Ingestion
    → File Validation & Version Registration
    → Document Parsing
    → Chunking & Metadata Enrichment
    → Index Construction
    → Publish Searchable Version

    Separating offline ingestion from online QA prevents bulk file parsing from directly consuming online request resources. For time-consuming tasks, asynchronous queues and background execution mechanisms can be used, but retry limits, failure logs, and duplicate task identification must be configured to prevent the same file from being processed repeatedly.

    5. Document Parsing and Chunking: Don’t Treat “Text Recognition” as the Finish Line

    5.1 Classify First, Then Choose a Processing Strategy

    Different materials should be handled differently:

    • For structured text, leverage existing heading, paragraph, and list relationships.
    • For scanned files, perform OCR first, paying attention to skew, blurriness, and background interference. OCR results should be sampled for verification, especially for high-risk fields like amounts, dates, and ID numbers.
    • For tables, retain row/column semantics, units, and footnotes. Simply concatenating all cells into a string easily causes loss of information relationships.
    • For complex layouts, confirm the reading order is correct to avoid mixing left/right columns, headers/footers, and main text.

    OCR and layout analysis can both produce errors, so parsed output should not be directly treated as a trusted fact.

    5.2 Chunking Should Balance Semantic Integrity and Retrieval Precision

    Chunks that are too small may lose applicable conditions and exception clauses; chunks that are too large may introduce a lot of irrelevant content, reducing retrieval and generation efficiency.

    A more robust approach is to chunk primarily by chapter, paragraph, or complete clause, and then adjust the length based on model context and actual retrieval performance. For context-dependent fragments, parent headings or related paragraphs can be attached, but uncontrolled repetition should be avoided.

    Each chunk should also carry metadata such as document ID, version, source location, validity period, and access scope. This information is not only used for displaying citations but also forms the basis for subsequent permission filtering, version governance, and issue tracking.

    6. Retrieval Service Integration: APIs Need to Pass More Than Just the Question

    When the application orchestration layer calls the knowledge service, it should not just send a natural language question. It also needs to pass the authenticated user context, allowed knowledge scope, and necessary business conditions.

    A conceptual contract can be established as follows:
    Request information includes: question text, request trace ID, authorized knowledge scope, metadata filter conditions, and expected return size.
    Response information includes: evidence text, document ID, version, source location, relevance info, and service status.
    These are just internal protocol design elements and do not represent actual API fields of any existing system.

    Relevance scores are typically only used for ranking under a specific retrieval configuration and cannot be directly interpreted as the “probability of a correct answer.” After changing the retrieval method or reranking model, old thresholds must be re-validated.

    6.1 Multi-Knowledge Base Routing Should Avoid Missed Hits

    The system can select the knowledge scope based on the question’s topic, but automatic routing may misjudge. For questions involving multiple departments or policy types, parallel retrieval within the authorized scope can be performed first, followed by merging candidate evidence.

    Regardless of the routing method, permissions must be enforced on the server side. Relying solely on prompts to instruct the model “not to read unauthorized materials” is insufficient.

    6.2 Retrieval Failures Should Not Be Disguised as Business Answers

    API timeouts, index unavailability, and “the knowledge base genuinely has no answer” are different scenarios and should be handled separately.
    During service failures, limited retries can be attempted, or a clear “temporarily unavailable” message returned; when evidence is insufficient, the system should state it cannot confirm and suggest providing more conditions. For compliance, financial, or production safety issues, the system should not automatically switch to baseless answers after a retrieval failure.

    7. Container Deployment and Port Planning

    When multiple services are deployed on the same host, a common issue is host port conflicts. Port publishing can generally be understood as:
    Host Port → Container Internal Port
    For example:
    8081 → 80
    8444 → 443
    Here, the host access port is changed, while the internal container service can still listen on its original port. Whether it can actually be accessed depends on the service listening address, network policies, and proxy configuration.
    80 and 443 are common ports for plaintext and encrypted web services, but the port number itself does not enable encryption. Encrypted access still requires correct certificates and service configuration.

    7.1 Distinguish External Access from Inter-Service Access

    Browsers access the external entry point; services within the same controlled container network can usually communicate via internal service addresses and container listening ports without going through host public ports.
    The local loopback address in a container usually points to the container itself and cannot simply be used as the address of other containers or the host. Before integration, check that the caller can resolve and access the target service.

    7.2 Only Expose Necessary Entry Points

    It is recommended to set up a unified external access entry and implement access control for management pages and service APIs separately. Database, search engine, and backend management ports should not be directly exposed for debugging convenience.
    After modifying ports, also check callback addresses, file download URLs, and external access configurations to avoid situations where the page loads but API requests or citation links are unavailable.

    8. Establish an Evaluation and Governance Loop Before Launch

    8.1 Layered Evaluation, Not Just the Final Answer

    • Parsing layer: Check text accuracy, table relationships, and source location.
    • Retrieval layer: Check whether correct evidence enters candidate results and whether unauthorized or invalidated content is mixed in.
    • Generation layer: Check whether the answer is supported by evidence, whether limiting conditions are omitted, and whether citations match.
    • System layer: Check end-to-end latency, failure rate, resource consumption, and concurrent stability. Strong complex document parsing capability does not necessarily mean faster online response; performance must be verified under actual data, hardware, and load.

    8.2 Establish Clear Rules for Content Updates

    Documents should have stable identifiers and a version management mechanism. During updates, prevent old and new versions from being treated as valid simultaneously; during deletion and permission revocation, cover the index, cache, and downloadable original files.
    For scenarios requiring index rebuilding, build and validate the new version first, then switch the online query pointer, retaining necessary rollback capabilities to reduce service risks during the update process.

    8.3 Guard Against Malicious Instructions in Knowledge Content

    Uploaded documents and retrieval results should be treated as external data, not system instructions. Even if a file demands “ignore permission rules” or “call a specific API,” it should not be granted execution rights.
    Business tool calls should have independent authorization, and sensitive operations should require confirmation. Logs also need desensitization to avoid writing full question text, internal evidence, and access credentials unconditionally into logging systems.

    9. Conclusion: Validate the Bottleneck First, Then Decide the Architecture

    There is no universally optimal solution for enterprise knowledge base QA that operates independently of business conditions.
    When materials are simple, processes are stable, and operational resources are limited, a more compact architecture is preferable. When complex document processing and complex business orchestration coexist, and the team can handle API governance and operations, layered integration has more room to add value.
    The truly reliable path is: first define business boundaries and acceptance criteria, then use real materials to validate parsing, retrieval, and generation, and finally decide whether to split services based on the failure distribution. Building a solid foundation in evidence quality, access control, API contracts, and production operations determines the system’s long-term value more effectively than simply stacking more components.