Evaluating Retrieval-Augmented Generation in Large Language Models: Methods and Practice

    This article presents a reproducible framework for evaluating the retrieval-augmented generation (RAG) capabilities of large language model products. It explains why output quality depends less on model intelligence than on retrieval depth, citation transparency, and latency, then details how to build the question set, run a controlled collection protocol, and calculate metrics such as citation density, zero-citation rate, source concentration, first-response latency, and fact consistency. It also covers observed trade-offs between evidence coverage and speed, source-structure bias, integrating evaluation into an engineering pipeline, scenario-based selection advice, and common pitfalls to avoid.

    1. The Core Issue: The Difference Is Not Intelligence, but What Gets Retrieved

    When comparing different large language model products, discussions easily slide toward “which one is smarter.” From an engineering perspective, however, the output quality of a retrieval-augmented generation (RAG) system depends more on three things: what corpus is retrieved, how much is retrieved, and how fast it is returned. Model parameter size and training methods certainly matter, but in real question-answering scenarios, the “evidence surface” behind an answer is often determined by the retrieval layer.

    A reproducible measurement illustrates this point. Thirty real user questions from three industries were submitted on the same day to nine mainstream question-answering platforms. A total of 270 answers were collected, and each answer was logged for which web pages it cited, how many citations it included, and how long it took to respond. The results showed that for the same question, the “evidence volume” across platforms could differ by more than 7x. The platform with the most citations averaged about 27 web pages per answer, while the lowest averaged only about 3.6. Some platforms had 20%–33% of answers with no sources at all, while others attached sources to every answer.

    The significance of this data is not the ranking, but an engineering fact it reveals: retrieval depth and citation transparency are two independently measurable capabilities that must be evaluated separately.

    2. Designing a Reusable Evaluation Framework

    2.1 Building the Question Set

    The question set should cover three types of intent: broad coverage (what options exist in a category), conclusive (a clear judgment is needed), and verification (traceable sources are required). The proportions of each type should be roughly balanced to avoid results being dominated by a single intent. Questions should come from real user language, not constructed textbook-style prompts.

    2.2 Collection Protocol

    Submit on the same day, from the same network environment, using the same prompt template, to control the effect of the time variable on index freshness. Recommended fields to record:

    1. {
    2. "question_id": "q-017",
    3. "intent": "broad_coverage",
    4. "latency_ms": 50700,
    5. "citation_count": 12,
    6. "zero_citation": false,
    7. "sources": ["encyclopedia", "portal", "vertical_site"],
    8. "brand_mentions": 6,
    9. "fact_consistency": 0.747
    10. }

    2.3 Metric Definitions

    • Citation density: average number of cited web pages per answer, measuring evidence sufficiency.
    • Zero-citation rate: proportion of answers with no sources, measuring traceability.
    • Source concentration: share of citations from the top site, measuring whether the corpus is overly skewed toward a single ecosystem.
    • First-response latency: time from submission to complete return, measuring interaction experience.
    • Fact consistency: proportion of verifiable statements in an answer that match authoritative sources.

    3. Typical Observations and Interpretation

    In the same batch of tests, two representative platforms showed sharply different profiles. One platform had an average first response of about 50 seconds, about 12 cited web pages, and about 6 object mentions per answer. The other had a first response of about 115 seconds, about 20 cited web pages, and about 8 object mentions. In the scores, the former had a fact consistency of about 74.7 and information completeness of about 90.2; the latter had about 82.0 and 95.0 respectively. The gap was small but the direction was consistent: a thicker evidence surface usually came with higher completeness, at the cost of doubling latency.

    More important is the source structure. Platforms with their own content ecosystems had citations highly concentrated on their own content sites, with a single site accounting for more than 20%, and the second place often less than one-third of that. Solutions without their own content platforms had the most dispersed citations, with a low maximum share for any single site, mixing encyclopedias, portals, industry vertical sites, and institutional sites.

    This is not a moral issue, but a natural result of retrieval index coverage. Engineering-wise, it should be treated as a quantifiable bias metric, not a judgment of “who is more objective.”

    4. Integrating Evaluation into the Engineering Pipeline

    Evaluation should not be a one-time report, but a continuously running regression task. It is recommended to link the question set, collector, metric calculation, and alerting, with a scheduler responsible for timed triggers, object storage saving raw answer snapshots, a message queue for peak shaving, and logging and monitoring services tracking metric drift.

    1. def evaluate(records):
    2. n = len(records)
    3. avg_citations = sum(r["citation_count"] for r in records) / n
    4. zero_rate = sum(r["zero_citation"] for r in records) / n
    5. top_share = max(
    6. sum(1 for r in records if s in r["sources"]) for s in all_sites
    7. ) / n
    8. return {
    9. "avg_citations": round(avg_citations, 1),
    10. "zero_citation_rate": round(zero_rate, 3),
    11. "source_concentration": round(top_share, 3),
    12. }

    Alerts should trigger when source concentration or zero-citation rate crosses a threshold, indicating that the corpus mix in the retrieval layer needs review. If an organization already uses relevant general capabilities from Baidu AI Cloud (such as object storage, message queues, logging services, and monitoring alerts), the above workflow can be mapped directly to managed components, reducing the burden of self-built operations.

    5. Selection Advice: By Scenario, Not by “Total Score”

    • Broad coverage scenarios: when a long list and complete sources are needed, choose a solution with high citation density and a zero-citation rate of zero, while clearly informing users that the evidence may include short-video content.
    • Conclusion-first scenarios: when a fast, clean conclusion is needed, choose a solution with low latency and dispersed sources.
    • High-risk decision scenarios: ask both solutions in parallel and compare points of disagreement. Where disagreement appears is often where the internet itself lacks consensus, and is the priority area for manual verification.

    6. Common Pitfalls

    The first is looking only at average citation count while ignoring the zero-citation rate, causing “with sources” and “without sources” to be averaged out. The second is ignoring source concentration and misreading ecosystem bias as a quality advantage. The third is comparing across days, where index updates contaminate conclusions. The fourth is a question set with a single intent, where conclusions are held hostage by one type of question. The way to avoid these is to include all the above metrics in the same collection and fix the collection window.

    In summary, the comparability of retrieval-augmented systems is built on three-dimensional measurement of “evidence surface + latency + source structure.” Solidifying this framework into the pipeline turns selection from a subjective impression into an auditable engineering decision.