Integrating External Knowledge Base Retrieval into Application Orchestration Platforms
This article describes a general architecture for decoupling application orchestration from knowledge base retrieval in retrieval-augmented generation (RAG) applications. It covers API integration, deployment and port planning, embedding and reranking model configuration, knowledge base creation, assistant orchestration, and practical optimization methods for improving retrieval recall and answer quality.
Retrieval-augmented generation (RAG) has become a common way to connect private data with large language model (LLM) generation. Application orchestration platforms often include built-in knowledge base management and retrieval, enabling teams to upload documents, split them, generate embeddings, and build a question-answering pipeline quickly. In practice, however, many teams encounter a common issue: built-in retrieval can be inconsistent for complex documents, long-tail semantics, and fine-grained questions. As a result, final answers may omit information, miss the point, or include incomplete context.
The cause is rarely a single component. It is usually the combined effect of multiple factors in the retrieval pipeline: poor document parsing, inappropriate chunking granularity, a mismatch between the embedding model and the business corpus, improper recall count and threshold settings, missing reranking, and overly long context assembly that dilutes key information. A common engineering practice is therefore to decouple application orchestration from knowledge base retrieval. The orchestration platform handles workflows, prompts, model invocation, and conversation management, while an external knowledge base service handles document parsing, index construction, vector retrieval, and reranking. The two are integrated through standard APIs. This preserves the flexibility of the orchestration platform and uses a more specialized retrieval service to improve recall quality.
This article presents a general technical approach for integrating an application orchestration platform with an external knowledge base service to implement retrieval-augmented generation. It provides practical guidance on deployment, configuration, retrieval, orchestration, and optimization. In environments such as Baidu AI Cloud, general-purpose services such as container platforms, object storage, caching, logging, and monitoring can host the relevant components; however, the focus remains on the general architecture and implementation method.
Overall Architecture and Call Flow
The core idea is that the application orchestration platform does not directly handle complex retrieval. Instead, it sends the user question to the external knowledge base service, which returns relevant document chunks. The platform then passes those chunks as context to the LLM to generate the answer. A typical flow is:
- Document ingestion: Upload private documents to the external knowledge base service.
- Parsing and chunking: Select a parsing method based on document type; perform text extraction, layout restoration, segmentation, and metadata tagging.
- Embedding and indexing: Generate vectors with an embedding model, write them to the retrieval index, and retain original chunks and source information.
- Retrieval recall: After a user asks a question, the external knowledge base service performs vector search, keyword search, or hybrid search.
- Reranking and filtering: Optionally enable a reranking model to sort candidate chunks by relevance and filter low-quality results by threshold.
- Context assembly: Concatenate highly relevant chunks using a template, control length, and attach metadata such as source and time.
- Answer generation: The application orchestration platform calls the LLM to generate the final answer based on the context and prompt.
From an interface perspective, the external knowledge base service must expose a retrieval API to the orchestration platform. The API typically accepts parameters such as query text, knowledge base ID, recall count, and similarity threshold, and returns a list of chunks. An illustrative request is:
POST /v1/retrieval{"kb_id": "knowledge_base_demo","query": "What is the background information of the target person?","top_k": 8,"score_threshold": 0.35,"rerank": true}
An illustrative response is:
{"chunks": [{"content": "Relevant document chunk content...","score": 0.82,"source": "doc_001","metadata": {"section": "Person background"}}]}
The above interface is only a general illustration. Actual implementation should follow the public documentation of the selected knowledge base service and should not invent parameters or capabilities. On the orchestration platform side, configure the external knowledge base connection, including service address, API port, authentication method, timeout, and retry policy, and run a connectivity test before saving.
Service Deployment and Port Planning
An external knowledge base service usually consists of multiple components, commonly including an application service, a retrieval index service, a relational database, object storage, a cache service, and a visualization/analysis component. During deployment, focus on network connectivity, port exposure scope, data persistence, and resource quotas.
First, port planning should be clear. A knowledge base service generally provides a web management entry point and an API service port, which may be exposed separately. When integrating with the application orchestration platform, use the API port, not the management page port. After deployment, check port mappings through the container runtime to confirm that the API port is reachable from the network where the orchestration platform runs. For cross-host or cross-network access, also check security groups, firewalls, and reverse proxy configuration.
Second, authentication and isolation must be in place. The external knowledge base API should not be exposed directly to the public internet. At minimum, protect it with internal network access, API keys, gateway authentication, or mutual TLS. In multi-tenant or multi-business scenarios, enforce permission isolation by knowledge base or tenant to prevent different teams from reading each other’s data.
Third, persistence and backup cannot be ignored. Original documents, parsing results, vector indexes, and metadata all require persistent storage. Object storage is suitable for original documents, a relational database is suitable for metadata and configuration, and the retrieval index service handles vector and text indexes. Define a backup strategy and verify the recovery process.
Fourth, resource allocation and observability should be planned together. Parsing and embedding are resource-intensive tasks, so configure CPU, memory, and concurrency based on document scale. Logs, metrics, and tracing should cover ingestion, parsing, indexing, retrieval, and reranking to help diagnose issues such as “no recall”, “parsing failure”, and “timeout”.
Model Configuration and Knowledge Base Creation
After deployment, configure the embedding model, reranking model, and LLM. The embedding model determines the semantic matching capability between document vectors and query vectors; choose a model that matches the business language and document domain. The reranking model performs a second sort of initial recall results and can significantly improve ranking quality when there are many candidate chunks or semantically similar results. The LLM generates the final answer, and its summarization ability, instruction-following behavior, and context window affect answer style and completeness.
When creating a knowledge base, you typically set the knowledge base name, embedding model, parsing method, and chunking strategy. For parsing, general parsing is suitable for text-based documents with simple structure. For complex documents containing tables, layouts, or scanned pages, choose a parsing method that emphasizes layout restoration or OCR. The chunking strategy should set chunk length and overlap based on document structure. Chunks that are too short lose context; chunks that are too long dilute semantics and consume the context window. Sample and validate before batch processing.
After documents are uploaded, run parsing and embedding. The system generally supports single-file processing and batch processing. For batch processing, pay attention to task queues and failure retries to avoid individual parsing failures blocking overall progress. After parsing, spot-check whether chunk content is complete, heading hierarchy is preserved, tables and lists are readable, and metadata includes fields such as source, section, and update time.
Retrieval Configuration and Assistant Orchestration
Once the external knowledge base service is configured, return to the application orchestration platform for assistant orchestration. The chat window usually includes panels such as assistant settings, prompt engine, and model settings.
In assistant settings, the key steps are to enter the assistant name and bind the specified knowledge base. After binding, the assistant can call external knowledge base retrieval when handling user questions. If the platform supports multiple knowledge bases, choose a single knowledge base or combined retrieval based on business boundaries to avoid interference from irrelevant knowledge.
In the prompt engine, configure prompts, context templates, and reranking options. If no reranking model is available, leave reranking disabled initially and observe results by adjusting recall count and threshold. If a reranking model is available, enable it when there are many candidate chunks to improve context relevance. Prompts should explicitly require the model to “answer only based on the given context” and “state that information is insufficient when it cannot be determined”, and should control context length to prevent key chunks from being truncated.
In model settings, select the LLM as the inference model and set parameters such as temperature and maximum output length. Higher temperature produces more diverse answers; lower temperature produces more stable answers. For knowledge base question answering, a lower temperature is usually recommended so that answers stay close to retrieved content. After configuration, run conversation tests.
Effect Differences and Optimization Recommendations
There may be differences between using the external knowledge base service directly for retrieval and integrating it through the application orchestration platform before generation. Common reasons include different prompts on the orchestration platform, different context concatenation order, different LLM summarization capabilities, different temperature and maximum output length, different recall counts and thresholds, whether reranking is enabled, and different context truncation strategies. Therefore, do not compare only final answers; troubleshoot at each layer.
Optimize in the following order. First, check parsing and chunking quality to ensure key information enters the index completely. Second, adjust recall count and similarity threshold and observe whether recalled chunks cover the answer. Third, enable reranking and compare ranking results. Fourth, optimize the context template and place highly relevant chunks earlier. Fifth, lower temperature and limit output length. Sixth, build a fixed question set for regression testing and record recall rate, hit rate, and answer completeness.
From an engineering perspective, also consider timeout and retry, rate limiting and degradation, caching, and access control. The retrieval API should have a reasonable timeout and return explainable errors on failure. Cache results for high-frequency questions. Perform access auditing for sensitive knowledge bases. Only through continuous observation and iteration can the RAG pipeline of “application orchestration platform + external knowledge base service” run stably and balance accuracy and maintainability.
