Skip to main content

Knowledge Base Optimization

Strategies for optimizing knowledge base retrieval quality, including chunking, query rewriting, and re-ranking.

Optimization Overview

Knowledge base retrieval quality can be optimized at multiple stages:
User Query → Query Rewriting → Retrieval → Recall → Re-ranking → Assembly → LLM

Chunking Optimization

StrategyDescription
Smart ChunkingThe system automatically splits documents with overlapping windows. Suitable for most documents.
Custom ChunkingManually configure the chunk size and overlap to optimize retrieval.

Retrieval Optimization

Query Rewriting

Rewrites the user's query to improve retrieval match. Useful for multi-round conversations where the query may reference prior context.

Hybrid Retrieval

Combines semantic search and keyword search for better recall.

Multi-Knowledge Base Retrieval

Retrieves from multiple knowledge bases and merges results. Configure weights per knowledge base.

Re-ranking Optimization

Apply a re-ranking model to re-order the retrieved chunks by relevance:
ModelDescription
gte-rerankText re-ranking. Suitable for pure text knowledge bases.
qwen3-rerankText re-ranking with improved accuracy.
qwen3-vl-rerankMultimodal re-ranking. Required for knowledge bases containing images.

Assembly Optimization

Max Recall Count

The total number of chunks returned after re-ranking. Range: 1-20.

Max Assembly Length

The total Token count of all assembled chunks. If exceeded, chunks with lower relevance scores are dropped first.

Metadata Filtering

Filter retrieval results by metadata fields. Useful for narrowing down search scope.

Few-shot Prompting

Add example input-output pairs to the prompt to guide the model in correctly using retrieved knowledge:
# Requirements
Please extract technical specifications from the text below and present them in JSON format.

# Example
## Input: Stardust S9Pro, breakthrough 6.9-inch 1440 x 3088 pixel under-display camera design...
## Output: { "product":"Stardust S9 Pro", "screen_size":"6.9inch" }

Advanced: Custom Processing Mode

For scenarios requiring custom logic, switch to the Custom Processing mode. The model receives the file URL or raw content and autonomously decides how to process it.