Evaluating LLM Accuracy: Prompt Design and Verification Methods
This article explores how to improve the accuracy and reliability of Large Language Model (LLM) outputs. It analyzes four key factors affecting model accuracy: task type matching, prompt design, reference material provision, and result verification. Additionally, it covers building a lightweight evaluation framework, a layered strategy for engineering implementation, common pitfalls, and an actionable checklist.
1. Why “Which Model is More Accurate” Is the Wrong Question
Large language model responses are generated probabilistically. The output quality of the same model can vary significantly depending on the question, context, and constraints. Therefore, comparing two models on just a few questions often yields non-reproducible conclusions. A more valuable question is: in a specific task, how can we make the model’s output reliable, and how can we determine if it is reliable?
In practice, accuracy is typically determined by four factors: the match between the task and model capabilities, the clarity of the prompt, whether the input contains sufficient evidence, and whether there is a verification step after output. All these factors are within the user’s control.
2. Four Key Factors Affecting Accuracy
1. Task Type Matching
Different tasks have different requirements for models. Factual Q&A relies on knowledge coverage, but since training data has a cutoff date, it may lack information on recent events. Logical reasoning and mathematical calculations require step-by-step derivation; directly asking for a conclusion is prone to errors. Code generation requires runtime verification. Creative writing focuses more on style and constraint satisfaction.
It is recommended to first determine which category the task falls into, and then decide whether internet retrieval, step-by-step reasoning, or external tools are needed.
2. Prompt Design
A clear prompt usually contains four elements: role or scenario, task objective, constraints, and output format. For example, asking the model to “answer only based on the provided materials, and mark any information not present in the materials as undetermined” is more likely to yield verifiable results than vaguely asking “what do you think about this issue?”
For scenarios requiring a fixed format, you can provide one or two sets of input-output examples for the model to follow the same structure.
3. Providing Reference Materials
Placing relevant original text, data tables, or document fragments into the context is the most direct way to reduce incorrect answers. When the knowledge base is large, a common practice is to use a retrieval module to filter relevant paragraphs first, and then let the model answer based on these paragraphs, which is the general approach of Retrieval-Augmented Generation (RAG).
The reference materials themselves must be accurate and updated timely. When materials are outdated or contradictory, the model will still output seemingly reasonable answers, which users need to identify themselves.
4. Result Verification
Even if the first three steps are done well, verification is still necessary. Common practices include: asking the model to annotate the source location for each conclusion; performing independent calculations for key figures; using another request for independent cross-checking; and introducing human review for high-risk conclusions.
3. Building a Lightweight Evaluation Framework
Determining whether an answer is accurate requires reproducible data. Below is a minimal evaluation approach: first prepare a set of representative questions, manually provide standard answer points for each question, and then use a script to run them in batches and score them.
from dataclasses import dataclass@dataclassclass TestCase:question: strreference_points: list[str] # Manually annotated answer pointsdef score_answer(answer: str, reference_points: list[str]) -> float:"""Calculates the proportion of hit points in the answer. Keyword matching is just a rough method and can be replaced with semantic matching or manual scoring."""if not reference_points:return 0.0hits = sum(1 for point in reference_points if point in answer)return hits / len(reference_points)def evaluate(ask_model, cases: list[TestCase]) -> float:"""ask_model is the function calling the model, implemented by the user: receives question text, returns answer text."""scores = [score_answer(ask_model(c.question), c.reference_points) for c in cases]return sum(scores) / len(scores) if scores else 0.0
When designing the evaluation set, it should cover both typical questions and boundary questions, such as questions with ambiguous expressions, out-of-scope questions that require refusal to answer, and easily confused concepts. The scoring dimensions should include at least factual correctness, information completeness, and traceability of evidence. Every time the prompt or reference materials are changed, they should be re-run on the same evaluation set to determine if the changes are effective.
4. Layered Strategy for Engineering Implementation
Not all outputs require the same level of review. A layered approach based on risk levels can be adopted:
- Low-risk scenarios, such as copy polishing or generating examples, can be used directly with sample checks.
- Medium-risk scenarios, such as summarization and data compilation, should require the model to attach original text evidence, and key content should be sampled for verification.
- High-risk scenarios, such as medical, legal, or financial information, must undergo human review, and the model output should only serve as a draft.
Additionally, it is recommended to record the prompt version, input materials, and output results used for each request. When an error occurs, you can trace back through each stage to find out whether the problem originated from the prompt, the materials, or a lack of verification, rather than simply attributing it to the model itself.
5. Common Pitfalls
First, treating a single response as a definitive conclusion. Asking the same question in a different way might yield a different result. Asking multiple times and comparing the results is a simple and effective verification method.
Second, only looking at whether the text is fluent. A smoothly written answer might still contain factual errors; fluency cannot replace accuracy assessment.
Third, ignoring timeliness. For questions involving recent policies, prices, versions, or news, priority should be given to the latest authoritative sources.
Fourth, over-reliance on a single solution. In critical tasks, outputs from different solutions can be cross-referenced, with authoritative materials serving as the final basis.
6. Actionable Checklist
- Is the task type clear, and is retrieval or reasoning assistance needed?
- Does the prompt include role, objective, constraints, and output format?
- Are the reference materials accurate, complete, and up-to-date?
- Does the output include evidence, and have key figures been cross-checked?
- Does the review intensity match the risk level?
- Are prompt versions and output results recorded for traceability?
