Enterprise Knowledge Base Q&A Architecture: Selection and Integration Practices
This article explains how to choose and integrate an enterprise knowledge base Q&A system. It focuses on architecture capabilities rather than interface features, covering application orchestration, document retrieval, layered design, document ingestion, chunking, metadata, retrieval and generation, API contracts, deployment and networking, security governance, evaluation, and a practical rollout path.
1. Start with the Problem: Choose Architecture Capability, Not Just a Software Interface
When enterprises build a knowledge base Q&A system, they often first ask which option is easier to deploy or which interface is more usable. These factors affect prototype efficiency, but they do not by themselves determine answer quality in production.
A usable enterprise-grade system needs to accomplish at least four tasks:
- Convert text, tables, heading hierarchies, and source information in documents into searchable data.
- Find relevant evidence for a question while handling boundaries across versions, departments, and permissions.
- Generate answers based on evidence, and clarify the question or explicitly refuse to answer when information is insufficient.
- Connect Q&A results to business workflows while meeting audit, monitoring, and continuous update requirements.
Therefore, technology selection should focus on two types of capabilities: application orchestration, which handles interaction and business execution; and document processing and retrieval, which supplies evidence. These capabilities can be handled by one system or split into separate services.
Whether to split them depends on real requirements and maintenance cost, not on the number of components. For small-scale scenarios with simple document structures and clear permission boundaries, an integrated solution is usually easier to maintain. For scenarios with many scanned files, complex tables, and diverse business workflows, a layered architecture makes it easier to optimize weak areas.
2. Application Orchestration and Document Retrieval Solve Different Problems
2.1 Application Orchestration Layer: Bring Q&A into Business Workflows
The application orchestration layer mainly handles the processing path of user requests, including question classification, parameter extraction, knowledge base routing, external service calls, answer generation, and result display.
For example, if a user asks whether a certain expense can be reimbursed, the system may first need to confirm the expense type, then query the applicable policy, and finally generate an answer based on the user’s region and organizational scope. If the user further asks to submit an application, the request should enter a business workflow with permission checks and confirmation steps, rather than directly executing an action.
The advantage of this capability is that workflows are visible, modules are reusable, and business logic is easy to adjust. However, it also has boundaries: a well-designed workflow does not mean the underlying documents can be parsed correctly. If table relationships are already lost during ingestion, later orchestration usually cannot recover the original meaning.
For open-ended tasks, an AI agent can help select tools. For high-risk steps such as permission checks, expense approvals, and data modifications, explicit execution rules should be preferred to avoid letting the model decide critical actions on its own.
2.2 Document Retrieval Layer: Give the Model Reliable Evidence
The document retrieval layer handles file ingestion, content parsing, chunking, index construction, retrieval, and reranking.
Its core goal is not to split documents as finely as possible, but to preserve semantic and structural integrity as much as possible. For example:
- Policy clauses need to retain applicable scope, exceptions, and effective dates.
- Tables need to retain headers, units, and the correspondence between rows and columns.
- Scanned documents need text recognition, and recognition quality information should be recorded when possible.
- Long documents need to be associated with section headings to prevent local fragments from losing context.
The weakness of the retrieval layer is usually limited business interaction capability. It can return evidence, but it is not necessarily suitable for handling complex conversational states, approval branches, and multi-system collaboration.
In addition, strong document parsing capability does not necessarily mean faster online responses. Parsing usually happens offline. Online latency is also affected by index size, filtering conditions, reranking models, network calls, and generation length, and must be evaluated through actual load testing.
3. Combined Architecture: Clear Division of Labor Matters More Than Simple Stacking
A common layered approach is:
User request
→ Identity authentication and permission check
→ Application orchestration
→ Knowledge base routing and retrieval service
→ Evidence set after permission filtering
→ Answer generation and citation validation
→ Return to user
Document ingestion follows another path:
Document ingestion
→ File and format check
→ Content parsing
→ Structured chunking
→ Metadata enrichment
→ Index construction
→ Quality acceptance
→ Publish searchable version
This design separates offline processing from online Q&A, preventing complex parsing tasks from directly consuming the execution time of Q&A requests.
However, layering also introduces additional costs: interfaces between services need compatibility maintenance, network failures need handling, permission semantics need unification, and cross-service monitoring needs to be established. Therefore, one should not split services too early just to pursue a “complete” architecture. A combined architecture is more valuable only when document processing or business orchestration truly needs to evolve independently.
3.1 Recommended Responsibility Boundaries
The application orchestration layer is responsible for:
- Managing session and request state;
- Deciding whether retrieval is needed;
- Selecting the knowledge scope according to business rules;
- Organizing evidence and generation instructions;
- Controlling confirmation steps for business operations.
The retrieval layer is responsible for:
- Managing document versions and index status;
- Executing permission filtering based on trusted identity;
- Returning relevant fragments and their sources;
- Providing retrieval diagnostic information;
- Maintaining index consistency after document updates and deletions.
It is not recommended to let both layers maintain separate, unrelated full knowledge indexes. Otherwise, version drift, deletion inconsistency, and permission rule conflicts are likely to occur.
4. Document Ingestion: The First Gate for Answer Quality
4.1 Inventory Documents First, Then Choose a Parsing Strategy
Before implementation, collect statistics on file formats, the proportion of scanned files, table complexity, update frequency, and whether sensitive information is included. This information determines the parsing approach and resource allocation.
Text-based documents can prioritize extracting body structure. Scanned documents usually require optical character recognition. Table-heavy materials need special checks for cross-page tables, merged cells, and header associations. Content that cannot be reliably restored should enter manual review or be marked as low-trust material, rather than directly entering the formal knowledge base.
4.2 Chunking Should Follow Semantics, Not Fixed Length
Fixed-length chunking is simple to implement, but it may separate clauses from exceptions or separate table headers from data. A more reasonable approach is to chunk according to sections, paragraphs, clauses, and table boundaries, then adjust fragment size based on model context limits.
Moderate overlap can reduce information loss at boundaries, but excessive overlap increases duplicate retrieval and storage costs. The specific length should not copy a uniform value; it should be validated with a representative question set.
4.3 Metadata Determines Whether Knowledge Can Be Used Correctly
Each searchable fragment should be associated with the following information as much as possible:
- Document identifier and fragment identifier;
- Title, section, and page number;
- Document version, effective time, and expiration status;
- Department, region, and business category;
- Permission scope and source location.
Version and effective time should not be display-only fields. For policies, prices, or operating procedures, they should participate in filtering or ranking to prevent old versions from entering answers based only on textual relevance.
5. Retrieval and Generation: From “Relevant” to “Answerable”
5.1 Limit Scope First, Then Judge Relevance
Enterprise retrieval is not about finding similar sentences across all documents. The system should first limit the visible scope based on identity, tenant, department, business category, and time conditions, then perform relevance retrieval.
Keyword retrieval is suitable for IDs, terms, and exact names. Vector retrieval is suitable for synonymous expressions and semantic similarity. The two can be combined, and reranking can reduce weakly relevant results. However, hybrid retrieval is not necessarily better than a single retrieval method; effectiveness still needs to be evaluated based on business data.
Cross-knowledge-base routing also requires tradeoffs. Selecting only one knowledge base may miss evidence, while retrieving from all knowledge bases increases cost and noise. It is better to first narrow the scope with business rules, then retrieve from a small number of candidate bases. For questions that require cross-department synthesis, controlled multi-base queries can be allowed.
5.2 Returning Fragments Does Not Mean the Answer Has Been Found
Highly relevant results may only discuss a similar topic and fail to cover key conditions in the user’s question. Therefore, before generation, the system should also check:
- Whether the core facts required by the question are included;
- Whether the applicable scope or exceptions are missing;
- Whether multiple sources conflict with each other;
- Whether a newer version exists;
- Whether the user needs to provide additional conditions.
Retrieval scores are usually meaningful only under specific retrieval methods and configurations. They should not be treated directly as answer confidence, and scores from different knowledge bases should not be mixed and compared without calibration.
5.3 Citations Must Be Traceable to Specific Evidence
A citation is not just attaching a file name to an answer. A more reliable approach is to link to a specific fragment, section, or page number and confirm that the evidence supports the corresponding conclusion.
When materials are insufficient, the system should clearly state that “current materials are insufficient to make a judgment” or ask a specific clarifying question. For conflicting policies, the system should show the conflict and version information instead of letting the model merge them into a seemingly complete conclusion.
6. Interface Integration: Define the Contract First, Then Connect Services
Interface design should prioritize business semantics, not just network connectivity. A request should include at least the query text, available knowledge scope, trusted authorization information, and an identifier associated with the request. A response should include evidence content, source location, document version, and necessary status information.
The following is only an illustrative data structure and is not the real interface of any product:
Retrieval request:Query textAuthorized knowledge scopeBusiness filter conditionsResult limitRequest tracing identifierRetrieval response:Evidence listDocument identifierFragment identifierFragment contentSource locationDocument versionRetrieval relevance informationRetrieval statusDiagnostic information
User identity and permissions should not be filled in arbitrarily by the browser and then trusted directly. They should be verified and passed by a trusted backend.
Error behavior also needs to be defined: whether to degrade after a timeout, how to notify when an index is not complete, whether partial results are returned when some knowledge bases fail, and whether retries will repeatedly trigger operations with side effects. Pure retrieval requests are usually easier to retry safely. Requests that modify data or submit workflows require idempotency control.
7. Deployment and Networking: Port Conflicts Are Only the Surface Problem
7.1 Understand the Direction of Port Mapping
Container port mapping is usually expressed as “host port:container internal port”. For example:
8080:80
This means that when accessing port 8080 on the host, the request is forwarded to port 80 inside the container. To avoid multiple services competing for the same host port, the value on the left side of the mapping can usually be adjusted while keeping the internal service listening port unchanged.
Note that modifying the mapping does not automatically change the service’s internal listening configuration. Also, ports 80 and 443 are common web service port conventions, but this does not mean that services running on these ports necessarily have the corresponding protocol or security capabilities.
7.2 Separate External Access from Internal Calls
User access entry points, service-to-service calls, and management interfaces should be separated as much as possible:
- The external entry point uniformly handles encrypted transmission, authentication, and access control;
- Internal services communicate over a controlled network;
- Databases, index services, and management interfaces are not directly exposed to the public internet.
When the application service and retrieval service run in different containers, “localhost” inside one container usually points to that container itself, not the host or another container. Internal calls should use the correct service address, and network isolation, name resolution, and access permissions should be verified.
7.3 Manage Offline Tasks and Online Requests Separately
File parsing, recognition, and index construction may consume substantial CPU, memory, and storage resources. Offline load should be controlled through task queues, concurrency limits, and resource quotas to prevent bulk ingestion from causing online Q&A timeouts.
Capacity planning should look beyond average response time. It should also observe tail latency, error rate, and queue waiting time during peak periods.
8. Security Governance: Permissions Must Span the Entire Chain
A knowledge base Q&A system may leak information at multiple stages, including retrieval, caching, logging, and citation display. Therefore, security controls cannot stop at the final answer stage.
First, permission constraints should be enforced during retrieval to prevent unauthorized fragments from entering the model context. Second, cache keys need to consider tenant, knowledge scope, permission changes, and document versions to prevent different users from mistakenly using the same cached result.
Document content may also contain instructions that try to induce the model to change behavior. The system should treat retrieved content as data to be analyzed, not as high-priority execution commands. When calling tools, exporting data, or modifying records, independent authorization checks must be retained.
Document deletion is not just deleting the original file. Indexes, caches, and derived data also need to be handled. Logs should reduce unnecessary sensitive content and set access permissions and retention periods according to organizational requirements.
9. Acceptance and Evaluation: Validate with Business Questions, Not Just Demos
It is recommended to build an evaluation set that covers real tasks, including:
- Questions that can be answered directly from a single fragment;
- Questions that require combining multiple sections;
- Questions involving complex tables;
- Questions with conflicts between old and new versions;
- Questions with no answer or insufficient information;
- Permission boundary requests;
- Document content containing malicious instructions.
During evaluation, retrieval and generation should be observed separately. On the retrieval side, check whether target evidence is recalled and whether there is too much noise. On the generation side, check whether facts are accurate, whether citations support conclusions, and whether refusals are reasonable.
Performance testing should cover concurrent requests, bulk ingestion, dependency timeouts, and service restarts. Cost evaluation should not only count model calls; it should also include parsing, index storage, reranking, logging, backups, and manual review costs.
After every change to chunking rules, retrieval strategies, or models, regression tests should be run to prevent local optimization from breaking other scenarios.
10. Implementation Path: Close the Loop First, Then Expand
A relatively safe implementation order is:
Phase 1: Choose a business domain with clear boundaries and verifiable materials, and build a small-scale knowledge base and evaluation set.
Phase 2: Complete the minimum closed loop of document ingestion, retrieval, answering, and citation, focusing on validating the evidence chain rather than the number of interface features.
Phase 3: Add identity authentication, permission filtering, version management, monitoring, backups, and failure recovery.
Phase 4: Decide whether to split document processing and application orchestration services based on actual bottlenecks, and gradually add cross-knowledge-base routing and business workflow capabilities.
The core of enterprise knowledge base Q&A is not finding a component that handles all requirements, but establishing clear responsibility boundaries, a trusted evidence chain, and a sustainable quality validation mechanism. Only when these foundations are stable will workflows and AI agent capabilities become real business gains, rather than a complex shell that amplifies underlying knowledge problems.
