Enterprise Knowledge Base Q&A: A Hybrid Architecture That Separates Orchestration from Document Parsing

    When enterprises build knowledge base Q&A systems, they face two very different sets of challenges: complex business workflows (multi-turn dialogue, intent routing, tool calls, external system integration) and complex documents (scanned PDFs, image-heavy reports, multi-level tables, irregular layouts). Frameworks strong at workflow orchestration usually have limited document understanding, while retrieval engines with deep document parsing often lack workflow and agent capabilities. This article describes a hybrid architecture that splits the system into an orchestration layer and a parsing layer, integrates them through APIs, and covers capability boundaries, API integration details, container deployment and port planning, cross-database retrieval routing, performance optimization, security and governance, and an evolution path—plus a launch checklist.

    1. Background: Two Core Requirements for Enterprise Knowledge Base Q&A

    In practice, requirements for enterprise knowledge base Q&A systems almost always fall into two main categories:

    1. Complex business workflows: multi-turn conversations, intent recognition, role-based routing, integration with external systems (tickets, approvals, database queries), and dynamically deciding the next step based on intermediate results.
    2. Complex documents: scanned PDFs, reports mixing images and text, tables with multi-level headers, text embedded in images, and contracts or technical manuals with irregular layouts.

    These two categories demand very different capabilities. Frameworks that excel at workflow orchestration are usually centered on conversations and task flows, with limited document parsing depth. Retrieval engines that excel at document understanding often lack business-facing workflow and agent capabilities. The common problem in enterprise deployments is: choose A and find parsing accuracy is poor; choose B and find workflow orchestration is difficult. Rather than patching weaknesses inside a single framework, it is better to separate responsibilities at the architectural level.

    2. Capability Split and Selection Approach

    The first step of the hybrid architecture is splitting the system into two layers with clear boundaries:

    Capability Dimension Orchestration Layer (Application Framework) Parsing Layer (Knowledge Base Engine)
    Core responsibility Conversation management, intent routing, workflows, tool calls Document ingestion, parsing, chunking, indexing, and retrieval
    Typical capabilities Multi-turn context, prompt assembly, external API tools, conditional branching OCR, layout analysis, table restoration, multi-level chunking templates
    Key metrics Task completion rate, workflow stability, response experience Parsing accuracy, retrieval recall, indexing throughput
    Data perspective User- and session-oriented Document- and knowledge-unit-oriented

    Follow these principles when selecting components:

    • Inventory documents before workflows. Tally the share of PDFs, scanned files, tables, etc. in the enterprise; parsing quality is the ceiling for answer accuracy.
    • Require open APIs. Either layer must be callable by the other through standard HTTP interfaces, avoiding lock-in via proprietary integrations.
    • Verify replaceability. The parsing layer should be pluggable so that switching or adding engines later requires no orchestration rewrites.
    • Prefer private deployment. Enterprise knowledge often contains sensitive data; both layers should support intranet deployment.

    3. Hybrid Architecture Design

    The overall data flow:

    1. User
    2. │
    3. ▼
    4. Orchestration layer (conversation management / intent routing / workflow / Agent)
    5. │ │
    6. │ Retrieval requests │ Other tool calls (database, tickets, external APIs)
    7. ▼ ▼
    8. Parsing layer retrieval API Business systems
    9. │
    10. ▼
    11. Document ingestion pipeline: upload → parse → chunk → vectorize → index

    Orchestration layer responsibilities: Accept user questions, determine which knowledge sources are needed, assemble retrieval queries, call the parsing layer to obtain relevant fragments, and generate the final answer with context; also manage multi-turn state, permission pre-checks, and output formatting.

    Parsing layer responsibilities: Focus on turning raw documents into high-quality knowledge fragments—OCR, layout restoration, table structuring, selecting chunking strategies by document type, and fusing vector search with keyword retrieval.

    This split brings three direct benefits: orchestration logic can iterate with business needs without touching the parsing pipeline; the parsing engine can scale independently to handle document floods; and the two layers are decoupled through APIs, so upgrading either one does not affect the other.

    4. Key API Integration Details

    It is recommended to wrap the parsing layer as an internal “knowledge retrieval service” exposing only a few stable interfaces:

    • POST /datasets: create a knowledge base
    • POST /datasets/{id}/documents: upload a document and trigger asynchronous parsing
    • GET /documents/{id}/status: query parsing status
    • POST /datasets/{id}/retrieval: perform retrieval, returning fragment content, source, and relevance scores

    Sample code (orchestration layer calling parsing layer retrieval):

    1. import json, urllib.request
    2. def retrieve(dataset_id, query, top_k=5):
    3. payload = json.dumps({
    4. "query": query,
    5. "top_k": top_k,
    6. "rerank": True
    7. }).encode("utf-8")
    8. req = urllib.request.Request(
    9. f"http://retrieval-svc:8080/datasets/{dataset_id}/retrieval",
    10. data=payload,
    11. headers={"Content-Type": "application/json"},
    12. method="POST",
    13. )
    14. with urllib.request.urlopen(req, timeout=10) as resp:
    15. return json.loads(resp.read())

    Four engineering concerns must be handled:

    1. Timeouts and retries: Set reasonable timeouts on retrieval calls and use exponential backoff for retryable errors. Document upload endpoints must be idempotent to avoid duplicate ingestion.
    2. Asynchronous parsing: Return a task ID immediately after document upload; the orchestration layer polls or subscribes to status updates rather than waiting in the request thread.
    3. Structured responses: Require the parsing layer to return the fragment text, document ID, page/location, and score so the frontend can support citation-based tracing.
    4. Graceful degradation: If retrieval fails, return “unable to retrieve relevant information” instead of crashing the whole conversation. Parsing failures should go to a retry queue with alerting.

    5. Containerized Deployment and Port Planning

    Both layers typically run as containers, and port planning is where mistakes most often happen.

    The port mapping format in container orchestration configs is host port:container port. For example, 80:80 maps host port 80 to container port 80; 443:443 corresponds to HTTPS. When resolving conflicts, change only the host port and keep the container’s internal port unchanged, because the application inside the container listens on a port written into its configuration—changing it has cascading effects. For example, let the orchestration layer own ports 80/443 and map the parsing engine to 8080:80 and 8443:443:

    1. services:
    2. orchestrator:
    3. ports:
    4. - "80:80"
    5. - "443:443"
    6. retrieval-engine:
    7. ports:
    8. - "8080:80"
    9. - "8443:443"

    Additional recommendations:

    • Use a reverse proxy as the unified entry point: expose only one domain externally and route internally by path to each service, rather than exposing multiple ports directly.
    • Configure health check ports for each service so the orchestration platform can probe liveness.
    • For cloud deployments, you can leverage container platforms, object storage, logging, monitoring, and alerting capabilities offered by cloud providers such as Baidu AI Cloud to manage both services and integrate them with existing enterprise permission and audit systems.
    • When ingesting large files, store document objects in object storage first and have the parsing service pull them asynchronously, reducing load on the API gateway.

    6. Cross-Knowledge-Base Retrieval and Routing

    Many parsing-oriented engines have limited support for “querying multiple knowledge bases at once,” which is a genuine enterprise need. The solution is to put routing in the orchestration layer:

    1. Intent routing: First determine which business domain the question belongs to (products, HR, finance, R&D), then target the corresponding knowledge base.
    2. Parallel retrieval + merging: For cross-domain questions, query multiple knowledge bases in parallel and merge results by score and business weights.
    3. Metadata filtering: Attach department, classification level, document type, and other filters to the query to narrow the scope at retrieval time.
    4. Permission filtering: After retrieval results are returned and before fragments are sent to the model for generation, filter them by the current user’s visibility. Permission checks must never rely on the model’s own judgment.

    7. Performance and Experience Optimization

    • Separate ingestion and querying: Parsing and index writes go through asynchronous queues, while query services are deployed independently, so large file parsing doesn’t slow down online Q&A.
    • Retrieval caching: Cache retrieval results for high-frequency questions; invalidate the cache when documents are updated.
    • Streaming output: Stream generated tokens to the client, significantly improving perceived latency.
    • Tiered retrieval: Use lightweight retrieval first to get candidates, then apply precise reranking to only the top candidates, balancing latency and accuracy.
    • Concurrency and rate limiting: Set connection pool limits and circuit breakers from the orchestration layer to the parsing layer to prevent the parsing layer from being overwhelmed.

    8. Security, Governance, and Evaluation

    Enterprise adoption can’t be judged by demos alone:

    • Citation tracing: Annotate answers with source documents and page numbers so users can verify them; this also reduces hallucination risk.
    • Audit logs: Log every retrieval’s query, knowledge base, returned fragments, and final answer to satisfy compliance traceability.
    • Evaluation set construction: Compile real business questions with standard answers covering simple facts, multi-hop reasoning, and table calculations; run regression evaluations after every chunking strategy or model configuration change.
    • Data governance: Keep indexes in sync with document version updates; set retention policies and data masking rules.

    9. Evolution Path

    Another benefit of the hybrid architecture is room to grow:

    • The parsing layer can host multiple engines by document type (e.g., a table-strength engine for contracts, a fast engine for general documents), with the orchestration layer routing between them.
    • Introduce reranking models and hybrid retrieval (vector + keyword + structured filtering) to improve recall quality.
    • Wrap retrieval as an Agent-callable tool, letting multi-step Q&A autonomously decide when to retrieve and what to retrieve.

    10. Pre-Launch Checklist

    Confirm each item before going live:

    • Parsing accuracy has been evaluated on real samples (especially scanned documents and tables)
    • Orchestration-to-parsing calls include timeout, retry, circuit breaking, and graceful degradation
    • Port planning has no conflicts, and a unified entry point is configured
    • Cross-database routing and permission filtering strategies are verified
    • The ingestion pipeline is asynchronous, with retry and alerting on failure
    • Answers include source citations, and audit logs are complete
    • An offline evaluation set and regression process have been established

    Summary: The core tension in enterprise knowledge base Q&A is the combination of “complex business workflows” and “complex documents.” A hybrid architecture that separates orchestration from parsing, integrates them via APIs, and lets each layer scale independently provides both workflow/agent flexibility and deep document understanding—an approach that balances effectiveness and maintainability in current engineering practice.