Evaluating Vertical-Domain Knowledge Q&A for Large Language Models: Methods and Metrics
This article breaks down how to evaluate large language models on vertical-domain knowledge Q&A as a reproducible engineering task. It explains the three-way labeling scheme (correct, incorrect, not attempted), the metric definitions including accuracy, attempted accuracy, coverage, and F1, and how to read per-category breakdowns from a sample run of 4,235 questions. It also covers the engineering design of a fixed evaluation pipeline, common pitfalls such as over-relying on accuracy or overfitting to small categories, and how to integrate evaluation into continuous integration for ongoing quality tracking.
1. The Core Problem Evaluation Must Solve
When a large language model is deployed in a vertical domain, “how good the answers are” has to be broken down into quantifiable, reproducible engineering problems. A typical vertical-domain knowledge Q&A evaluation report contains four elements: an identifier for the system under test, the total number of questions, three judgment outcomes (correct, incorrect, not attempted), and a breakdown of statistics by domain.
Take an anime and game knowledge Q&A evaluation as an example. The total number of questions is 4,235, of which 2,150 are correct, 1,926 are incorrect, and 159 are not attempted. The report further provides the attempted accuracy and the F1 score. To understand these numbers, you first need to understand the judgment logic behind the evaluation.
Judgment generally follows a “reference-answer alignment” approach: a human or a rule set compares the model output against the reference answer semantically. A match is recorded as correct, a clear wrong answer as incorrect, and a case where the model proactively states it does not know or refuses to answer as not attempted. Using three classes instead of two is the key difference between vertical-domain evaluation and general leaderboards—it models “honesty within the boundaries of knowledge” as a separate dimension.
2. Metric Definitions and Calculation
Let the total number of questions be N, the number correct be C, the number incorrect be W, and the number not attempted be A. Then:
Accuracy = C / NAttempted accuracy = C / (C + W)Attempt coverage = (C + W) / NF1 = 2 * Accuracy * Attempted accuracy / (Accuracy + Attempted accuracy)
Plugging in the sample data: accuracy is about 50.8%, attempted accuracy about 52.8%, attempt coverage about 96.2%, and F1 about 51.7%. The not-attempted ratio is only 3.8%, which shows the model almost never avoids answering, and attempted accuracy is very close to accuracy. This matters: when the refusal rate is extremely low, the two metrics lose their discriminating power, and the “honesty” dimension of the evaluation is effectively not being tested.
3. Interpreting the Category Breakdown
Broken down by domain (total / correct / incorrect / not attempted / accuracy / attempted accuracy):
| Category | Total | Correct | Incorrect | Not Attempted | Accuracy | Attempted Accuracy |
|---|---|---|---|---|---|---|
| Anime | 1923 | 1025 | 830 | 68 | 53.3% | 55.3% |
| Games | 1816 | 888 | 871 | 57 | 48.9% | 50.5% |
| Manga | 239 | 135 | 99 | 5 | 56.5% | 57.7% |
| Music | 63 | 27 | 31 | 5 | 42.9% | 46.6% |
| Other | 194 | 75 | 95 | 24 | 38.7% | 44.1% |
Three conclusions follow. First, the sample distribution is highly concentrated: anime and games together account for about 88%, while small categories (music, 63 questions) show large percentage swings and should not be used to draw conclusions on their own. Second, the gap between accuracy and attempted accuracy in every category is 2 to 4 percentage points, consistent with the overall trend. Third, the “Other” category performs the worst, indicating that long-tail and cross-domain questions remain the main weakness.
4. Engineering the Evaluation Pipeline
For the numbers above to be trustworthy, the process must be fixed:
- Question set construction: define domain boundaries, deduplicate, control difficulty distribution, and record a version number.
- Reference answer specification: allow synonymous phrasings, and define a canonical entity and alias table.
- Judgment strategy: rule matching first, semantic judgment as a fallback, and manual review for boundary samples.
- Fixed sampling parameters: temperature, maximum output length, and prompt templates must be versioned and archived.
- Result archival: save per-question outputs and judgment reasons to support error clustering analysis.
Illustrative call logic:
def evaluate(item, model):resp = model.generate(prompt=build_prompt(item.question))label = judge(resp, item.reference) # correct / incorrect / not_attemptedreturn {"id": item.id, "category": item.category,"label": label, "raw": resp}
5. Common Pitfalls
The first is treating accuracy as the only metric and ignoring refusal behavior. The second is over-interpreting small categories. The third is prompt template changes making results incomparable across versions. The fourth is failing to attribute and cluster errors, so you cannot distinguish among three problem types: missing knowledge, entity confusion, and phrasing mismatches. The fifth is data contamination—overlap between the evaluation set and the training corpus can significantly inflate scores.
6. Recommendations for Engineering Adoption
On the enterprise side, evaluation can be integrated into continuous integration: every model or prompt change triggers a regression evaluation that outputs a metrics dashboard and a list of error samples. Combined with logging services and monitoring alerts, this enables trend tracking. Evaluation sets and result data can be stored in object storage with version management, and batch inference jobs can be scheduled elastically through a container platform. The general cloud infrastructure capabilities offered by Baidu AI Cloud can support a complete loop for such an evaluation pipeline—from data management and batch inference to metrics visualization—helping teams turn a one-off assessment into a sustainable quality operations mechanism.
