qa-quality-eval
RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture — Balaguer et al. (2024) (arXiv:2401.08406, 2024)
What this evaluates
Evaluates the quality of generated question-answer pairs in an agricultural domain context. It probes a model's ability to produce relevant, accurate, diverse, and fluent Q&A content under varying context conditions.
Datasets
- Agricultural Q&A dataset — total ?; splits: test (-1)
Metrics
Relevance (primary) — range: [1, 5]
- LLM-judged score on a 1-5 scale assessing how pertinent the generated answer is to the question.
Coverage — range: [1, 5]
- LLM-judged score on a 1-5 scale measuring how comprehensively the answer addresses the question and covers relevant source text sections.
Diversity — range: other
- Computed using Word Mover's Distance (WMD) or KL divergence to measure semantic dissimilarity between generated questions and source text; lower scores indicate higher diversity.
Overlap — range: other
- Computed using KL divergence or WMD to measure semantic similarity between generated questions and source text; higher scores indicate more overlap.
Fluency — range: [1, 5]
- LLM-judged score on a 1-5 scale evaluating the grammatical correctness and natural flow of the generated answer.
Correctness — range: [1, 5]
- LLM-judged categorical score (e.g., Correct, Partially Correct, Incorrect) mapped to a 1-5 scale based on factual alignment with the reference answer.
Succinctness — range: [1, 5]
- LLM-judged score on a 1-5 scale penalizing verbose or overly detailed responses that go beyond the scope of the question.
Input / output format
Input: Question, generated answer, reference answer, and optional context (no context, location/state context, or external geographic context).
Output: A numerical score from 1 to 5 for each metric, accompanied by a textual explanation justifying the score.
Scoring recipe
def evaluate_qa(question, answer, reference, context, metric):
if metric in ['Overlap', 'Diversity']:
return compute_wmd_or_kl(question, context)
else:
prompt = f'Score the {metric} of this answer (1-5): Q: {question} A: {answer} Ref: {reference}'
return llm_judge_score(prompt, scale=5)
# Aggregate across all instances
final_score = mean([evaluate_qa(q, a, r, c, m) for q, a, r, c in dataset])
Common pitfalls
- LLM judges tend to penalize concise answers if they lack elaboration, as seen in the Succinctness metric where verbose but relevant answers score lower.
- Diversity and Overlap require specific distance metrics (WMD/KL divergence) rather than simple LLM scoring, which can lead to implementation inconsistencies if not strictly followed.
- Context setup variations (no context vs. external context) drastically alter prompt length and model behavior, making direct metric comparisons across setups sensitive to formatting.
Evidence (verbatim from paper)
We used several metrics (defined on Section 4.1) to assess their quality, including Relevance, Global Relevance, Coverage, Overlap, Diversity, Details, and Fluency. The LLMs assessed the Q&A pairs on various metrics, scoring each on a scale from 1 to 5. For certain metrics such as Overlap and Diversity, we incorporated intricate methods like Kullback-Leibler (KL) divergence and Word Mover's Distance (WMD) to measure the semantic similarity between the source text and the questions generated.
Citation
@misc{balaguer2024ragvsfinetuning,
title={RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture},
author={Balaguer et al. (2024)},
year={2024},
note={arXiv:2401.08406}
}
1---2name: qa-quality-eval3description: Evaluates the quality of generated question-answer pairs in an agricultural domain context. It probes a model's ability to produce relevant, accurate, diverse, and fluent Q&A content under varying context conditions. Use when the user wants to benchmark on Agricultural Q&A dataset, or asks about evaluating this task. Reports Relevance.4---56# qa-quality-eval78> RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture — Balaguer et al. (2024) (arXiv:2401.08406, 2024)910## What this evaluates1112Evaluates the quality of generated question-answer pairs in an agricultural domain context. It probes a model's ability to produce relevant, accurate, diverse, and fluent Q&A content under varying context conditions.1314## Datasets1516- **Agricultural Q&A dataset** — total ?; splits: test (-1)1718## Metrics1920- `Relevance` **(primary)** — range: [1, 5]21 - LLM-judged score on a 1-5 scale assessing how pertinent the generated answer is to the question.22- `Coverage` — range: [1, 5]23 - LLM-judged score on a 1-5 scale measuring how comprehensively the answer addresses the question and covers relevant source text sections.24- `Diversity` — range: other25 - Computed using Word Mover's Distance (WMD) or KL divergence to measure semantic dissimilarity between generated questions and source text; lower scores indicate higher diversity.26- `Overlap` — range: other27 - Computed using KL divergence or WMD to measure semantic similarity between generated questions and source text; higher scores indicate more overlap.28- `Fluency` — range: [1, 5]29 - LLM-judged score on a 1-5 scale evaluating the grammatical correctness and natural flow of the generated answer.30- `Correctness` — range: [1, 5]31 - LLM-judged categorical score (e.g., Correct, Partially Correct, Incorrect) mapped to a 1-5 scale based on factual alignment with the reference answer.32- `Succinctness` — range: [1, 5]33 - LLM-judged score on a 1-5 scale penalizing verbose or overly detailed responses that go beyond the scope of the question.3435## Input / output format3637**Input**: Question, generated answer, reference answer, and optional context (no context, location/state context, or external geographic context).3839**Output**: A numerical score from 1 to 5 for each metric, accompanied by a textual explanation justifying the score.4041## Scoring recipe4243```python44def evaluate_qa(question, answer, reference, context, metric):45 if metric in ['Overlap', 'Diversity']:46 return compute_wmd_or_kl(question, context)47 else:48 prompt = f'Score the {metric} of this answer (1-5): Q: {question} A: {answer} Ref: {reference}'49 return llm_judge_score(prompt, scale=5)5051# Aggregate across all instances52final_score = mean([evaluate_qa(q, a, r, c, m) for q, a, r, c in dataset])53```5455## Common pitfalls5657- LLM judges tend to penalize concise answers if they lack elaboration, as seen in the Succinctness metric where verbose but relevant answers score lower.58- Diversity and Overlap require specific distance metrics (WMD/KL divergence) rather than simple LLM scoring, which can lead to implementation inconsistencies if not strictly followed.59- Context setup variations (no context vs. external context) drastically alter prompt length and model behavior, making direct metric comparisons across setups sensitive to formatting.6061## Evidence (verbatim from paper)6263> We used several metrics (defined on Section 4.1) to assess their quality, including Relevance, Global Relevance, Coverage, Overlap, Diversity, Details, and Fluency. The LLMs assessed the Q&A pairs on various metrics, scoring each on a scale from 1 to 5. For certain metrics such as Overlap and Diversity, we incorporated intricate methods like Kullback-Leibler (KL) divergence and Word Mover's Distance (WMD) to measure the semantic similarity between the source text and the questions generated.6465## Citation6667```bibtex68@misc{balaguer2024ragvsfinetuning,69 title={RAG vs Fine-tuning: Pipelines, Tradeoffs, and a Case Study on Agriculture},70 author={Balaguer et al. (2024)},71 year={2024},72 note={arXiv:2401.08406}73}74```7576- arXiv: 2401.08406