Enterprise Knowledge Base Q&A: Architecture Selection and Implementation
This article explains how to design an enterprise knowledge base Q&A system by separating concerns into a parsing layer and an orchestration layer. It covers what each layer is responsible for, why decoupling them matters, and the practical issues that show up during deployment, such as port mapping and network planning. It also details how to integrate the two layers through stable interfaces, how to improve retrieval and generation quality, and how to handle evaluation, permissions, and operations. The goal is to help teams move from a one-time framework choice to a layered, replaceable architecture.
1. The Real Challenges of Enterprise Knowledge Base Q&A
When many teams start an enterprise knowledge base Q&A project, their first question is “which framework should we use?” In practice, however, success depends less on the framework itself and more on three things: whether documents can be understood correctly, whether retrieval results can be constrained reliably, and whether business workflows can be orchestrated flexibly. Once you break these three things apart, the selection problem shifts from “choose one of two” to “design in layers.”
A typical enterprise knowledge base often contains complex PDFs, scanned documents, tables with merged cells, slides, engineering drawings, ticket records, and database exports at the same time. These place very different demands on parsing capabilities. Meanwhile, the business side often requires multi-turn follow-up questions, permission isolation, approval workflows, ticket integration, and multi-model collaboration. These two sets of requirements follow completely different technical curves. Trying to satisfy both with a single layer usually forces a major compromise on one side.
A more reliable approach is therefore to separate the system into layers: the lower layer turns unstructured documents into high-quality, retrievable structured chunks, while the upper layer packages retrieval capabilities into Q&A and workflows that the business can consume. Layers communicate through standard interfaces, and any layer can be replaced.
2. Layered Architecture: Dividing Responsibilities Between Parsing and Orchestration
2.1 What the Parsing Layer Does
The core problem the parsing layer solves is semantic completeness. Once a PDF is cut into fragments, no downstream model can recover the damage if tables are split in half, headers and footers are mixed into the body text, or scanned pages are not deskewed. Typical capabilities of this layer include:
- Layout analysis: distinguishing titles, body text, captions, headers and footers, and multi-column layouts;
- Table structure reconstruction: recognizing merged cells and cross-page tables and outputting structured results;
- Image and scanned document processing: orientation correction, denoising, and text recognition;
- Templated chunking: applying different chunking strategies for different document types instead of one fixed window;
- Metadata preservation: storing source, page number, section, and permission labels together with each chunk.
2.2 What the Orchestration Layer Does
The orchestration layer faces the business and focuses on workflow and experience:
- Visual workflow orchestration: conditional branches, loops, parallel execution, and human confirmation nodes;
- Agent and tool invocation: wrapping retrieval, computation, and external system queries as callable tools;
- Multi-model collaboration: using different models at different nodes to balance cost and quality;
- Cross-knowledge-base routing: automatically selecting retrieval targets based on intent and permissions;
- Launch and operations capabilities: version management, canary releases, log tracing, and quality regression.
2.3 Why Decoupling Is Necessary
Decoupling delivers two direct benefits: replaceability and canary rollout. When the parsing model is upgraded, the upper-layer workflows need no changes; when orchestration workflows are adjusted, the lower-layer index does not need to be rebuilt. More importantly, permissions and auditing can be consolidated at the interface layer, avoiding a separate security implementation in every workflow.
3. Hidden Deployment Pitfalls: Ports and Network Planning
A hybrid architecture is usually deployed as two containerized services, and the most common failure is not a functional defect but a port or path conflict. In a container orchestration file, a port mapping is written as A:B, where A is the host port and B is the container port. Inside containers, port 80 commonly handles plaintext HTTP requests and port 443 handles encrypted HTTPS requests. If both services map to host ports 80 and 443, whichever starts first takes the ports, and the second one fails outright.
The recommended practice is to change only the host-side ports and keep container ports unchanged, which reduces configuration drift:
services:parser-layer: # Document parsing serviceports:- "8080:80" # Host 8080 -> container 80- "8443:443"orchestration: # Application orchestration serviceports:- "3000:80"
Beyond ports, three things need to be planned in advance. First, set up a unified reverse proxy and domain routing that distinguishes services by path prefix (such as /parse and /app), so ports are not scattered across business code. Second, let internal service-to-service communication go through container network aliases rather than host ports, reducing the exposure surface. Third, define the timeout chain clearly: parsing large files takes far longer than a chat response, so the gateway timeout must be greater than the parsing timeout; otherwise you get ghost tasks where “the frontend has already errored while the backend is still running.”
4. Integration Design: Letting the Orchestration Layer Consume Parsing Through Interfaces
The key to integration is not “the call succeeds” but “the contract stays stable.” It is recommended to abstract four actions: document upload, parsing task status query, chunk retrieval, and feedback reporting.
POST /parse/tasks # Submit a parsing task, returns task_idGET /parse/tasks/{task_id} # Query status: queued/running/failed/donePOST /retrieve # Retrieval: {"query":"...","top_k":8,"filter":{}}POST /feedback # Report hit/miss, used for quality regression
Key design points:
- Prefer asynchronous processing. Parsing is a long-running task, so it must return a task identifier and support polling or callbacks. Synchronous waiting inside the request thread is forbidden.
- Standardize filter conditions. Permission labels, time ranges, and document types should be passed explicitly as retrieval parameters rather than trimmed from results afterward, because post-filtering damages the recall quality of top_k.
- Make citations traceable. Retrieval results must carry source and location information so the frontend can show “which page and which paragraph the answer comes from,” which is a prerequisite for building trust in enterprise scenarios.
- Ensure idempotency and retries. Upload and submission should support idempotency keys to avoid duplicate parsing and index bloat caused by network jitter.
5. Retrieval and Generation: Breaking “Accurate Answers” Into Optimizable Steps
Poor Q&A quality is usually not a model problem but a lack of constraints in the retrieval pipeline. Troubleshoot in the following order:
- Chunk granularity: chunks that are too large introduce noise, while chunks that are too small lose context. Try chunking by semantic hierarchy and preserving parent-child relationships, so that when a child chunk is hit, the parent chunk can be traced back to complete the context;
- Hybrid retrieval: keyword retrieval excels at proper nouns and identifiers, while vector retrieval excels at semantic similarity; fusing the two usually outperforms a single path;
- Reranking: running a fine-grained rerank on the fused results is the most cost-effective way to improve first-result hit rate;
- Query rewriting: multi-turn conversations need coreference resolution and intent completion before retrieval;
- Refusal mechanism: set thresholds for similarity and rerank scores, and when scores fall below the threshold, clearly answer “not found in the materials” instead of forcing generation.
On the generation side, it is recommended to enforce “cite first, then answer,” and constrain the prompt as follows: answer only based on retrieved chunks, do not fill in numbers or clauses that do not appear, and output a fixed response when the question cannot be answered. For evaluation, distinguish two categories of metrics: hit rate and position metrics on the retrieval side, and faithfulness and completeness on the generation side. The two categories must be measured separately; otherwise it is impossible to locate where a problem originates.
6. Evaluation, Permissions, and Operations
The evaluation set should be sampled from real question logs and cover five categories: single-hop facts, multi-hop reasoning, table queries, negative questions, and unauthorized-access questions. Every time you adjust chunking, retrieval, or prompts, run the fixed evaluation set to produce a comparable regression report, avoiding “tuning by feel.”
Permissions must run through the entire pipeline: tag documents at ingestion, filter by user identity at retrieval time, prohibit cross-tag citations during generation, and record in audit logs “who obtained which chunks and when.” Multi-turn sessions also need context length and expiration policies to prevent sensitive content from lingering.
For operations, focus on three categories of metrics: parsing task success rate and duration distribution, retrieval latency and empty-recall rate, and refusal rate and manual correction rate on the generation side. For capacity planning, place parsing and online Q&A in separate resource pools so that bulk ingestion does not drag down online latency.
7. Implementation Roadmap and Common Pitfalls
A four-step rollout is recommended: first, use a small sample of documents to get the upload-parse-retrieve-cite loop working end to end; then add workflow orchestration and permissions; next, build an evaluation set and a canary mechanism; finally, optimize cost and capacity.
There are four common pitfalls: treating selection as a one-time decision and ignoring replaceability; optimizing only prompts without fixing chunking and reranking; implementing permissions as post-filtering on results; and having no regression evaluation after launch, so every change becomes a gamble. Hold the two bottom lines of layering and contracts, and tool-level replacements become engineering details rather than an architecture rebuild.
