RAG Framework Selection: Four Technical Factors That Actually Determine Output Quality
Choosing a RAG framework is less important than how documents are chunked, how retrieval is combined, and whether answers are constrained by sources. This article explains why framework names are not the main variable in RAG quality, how to build a fixed evaluation set for measurable and attributable results, and the four technical factors worth comparing: structure-aware chunking, hybrid retrieval, toggleable reranking, and refusal with source constraints. It also outlines the trade-offs between modular and out-of-the-box technical routes and a practical path for long-term, testable optimization.
Start With a Correction: The Framework Is Not the Main Variable
In retrieval-augmented generation (RAG) projects for knowledge bases, the most common question is “which framework delivers better results?” From an engineering perspective, the question itself is framed incorrectly. When the same set of documents is connected to both a custom retrieval pipeline and a common out-of-the-box solution, and both are evaluated with the same fixed set of questions, the score difference does not mainly come from the framework name. It comes from three things: how documents are chunked, how retrieval is combined, and whether answers are constrained by sources.
A framework is only the container that holds these three things. Changing the container frequently will not change output quality if what is loaded inside stays the same. For this reason, establish quantifiable evaluation criteria before selecting a framework; otherwise, “good results” is only a subjective impression.
Define the Evaluation Criteria: No Fixed Question Set Means No Comparability
The recommended evaluation approach is as follows: prepare an internal document set (for example, 8 documents chunked into roughly 653 text blocks), fix 36 evaluation questions, and judge them one by one. The judging rule should be strict: an answer counts as correct only if it is correct and the cited source actually exists in the original text. Partially correct answers are counted as a separate tier.
Under this criterion, a typical result is 24 correct, 6 partially correct, and 6 incorrect. This score is not flattering, but its value lies in being attributable: none of the 6 incorrect answers can be attributed to “insufficient model capability.” All of them fall at the pipeline level:
- Chunking cut off qualifying conditions, leaving incomplete semantics;
- The recall stage failed to retrieve key passages;
- The reranking stage pushed the correct passages further back.
By contrast, a framework’s built-in demo answers three questions correctly out of three because no one has strictly judged it with a fixed question set. Demo performance cannot serve as a basis for selection.
The Four Things Worth Comparing
1. Whether Chunking Follows Document Structure
Mechanical chunking by fixed character count is the most common mistake. Once tables, heading levels, and clause numbers are broken apart, even the most accurate recall can only retrieve incomplete context. The reasonable approach is to chunk along structural boundaries first and preserve metadata such as heading paths and clause numbers, so that each block can express complete semantics independently.
Illustrative structure (pseudocode):
chunk = {"text": "Clause 3.2 If the delay exceeds 30 days, Party A has the right to ...","meta": {"doc": "Contract A", "path": ["Chapter 3", "3.2"], "type": "clause"}}
2. Whether Retrieval Is Hybrid
Vector recall is good at semantic similarity, while keyword recall is good at content where not a single character can be wrong, such as model numbers, identifiers, and names. In real documents, a pure vector approach is most likely to fail on exact strings. In engineering practice, the two paths usually run in parallel and are then combined with fusion ranking.
candidates = merge(vector_search(q, k=20), keyword_search(q, k=20))
3. Whether Reranking Can Be Toggled
Reranking can significantly improve relevance in some scenarios, while in others it pushes correct passages backward. The key is not “whether reranking exists,” but whether it can be enabled, disabled, and tuned by scenario, with the question set used to verify the benefit.
4. Refusal and Source Constraints
For content that does not exist in the documents, the system should clearly answer “no supporting evidence found” and provide a traceable source passage. Without these two constraints, answers may look fluent but are in fact unusable for business.
Trade-Offs Between Two Technical Routes
One route comes with complete parts and high flexibility, at the cost of requiring developers to assemble the entire pipeline themselves and verify the default value of each stage one by one; otherwise, the default configuration leaves problems in the pipeline. The other route is ready to use out of the box, with ready-made interfaces and workflows, making it suitable for quickly validating whether a requirement is real. When you need to fine-tune chunking and recall details, it is easy to conflict with the preset logic.
Recommended practical path: first use an out-of-the-box solution to measure a baseline with the same question set and locate which stage the problems concentrate in; if you need to support the business long term and be accountable for results, then migrate to an approach that lets you control each stage. On Baidu AI Cloud, you can combine general capabilities such as object storage, log services, and monitoring and alerting to solidify question-set regression, pipeline metrics, and online tracing, making result optimization a sustainable engineering process rather than one-off parameter tuning.
