Evaluating Large Language Models on Legal Tasks: Methods and Engineering Practice
This article presents an engineering approach to evaluating large language models in legal scenarios, where general-purpose benchmarks often fail to capture the real difficulty. It breaks legal capability into four layers (knowledge, retrieval, reasoning, and expression), explains how to build a compliant, leakage-resistant question bank with layered difficulty and annotated answers, and describes a three-dimensional rubric covering conclusion accuracy, key-point coverage, reasoning completeness, and citation correctness. It also covers latency-budget quality curves, common failure modes with reusable prompt patterns, RAG and observability requirements, and human-in-the-loop workflows. Readers will learn how to produce reproducible, auditable evaluation results that support capacity and cost decisions instead of relying on anecdotal claims.
1. Introduction: Why Legal Scenarios Need Their Own Evaluation
General-purpose benchmarks such as commonsense QA or text summarization do not cover the core difficulties of legal work. Legal text has three notable characteristics. First, terminology density is high, and the same expression can carry different meanings across different bodies of law. Second, reasoning chains are long, requiring step-by-step derivation from facts to norms to conclusions. Third, answers are contestable, and there are often multiple acceptable lines of argument. As a result, extrapolating general leaderboard scores directly to legal scenarios usually does not hold.
Claims circulating online, such as “a model tested on a university’s civil and commercial law scholarship exam questions scored above top law school students and submitted in five minutes,” are unreliable as a basis for technical judgment: the sample size is unknown, the scoring criteria are not public, and it cannot be ruled out that the questions were part of the training corpus. This article does not compare specific products. Instead, it provides an engineering method for building your own evaluation.
2. Defining Evaluation Goals in Layers
It is advisable to split “legal capability” into four layers and design metrics for each:
- Knowledge layer: accuracy on deterministic facts such as statutory provisions, constituent elements, deadlines, and jurisdiction.
- Retrieval layer: whether the model can locate relevant clauses and key facts within long text.
- Reasoning layer: whether it can perform cause-of-action basis retrieval, element subsumption, and defense exclusion.
- Expression layer: whether document structure, argument order, and citation conventions are usable.
The point of layering is to locate the cause of failure. If knowledge-layer accuracy is high but reasoning-layer accuracy is low, the problem usually lies in prompt design and chain-of-thought organization. If retrieval-layer accuracy is low, the priority should be to change how context is supplied (chunking, reranking, adding anchors) rather than continuing to tune parameters.
3. Building the Question Bank: Avoiding the “Looks Hard” Trap
A high-quality question bank affects the credibility of conclusions more than model selection does.
- Source compliance: prioritize public court judgments, exercises from public textbooks, and public competition questions, with attention to anonymization and licensing.
- Difficulty tiers: use a mix of four levels: single-element judgment / multiple-element concurrence / norm conflict / incomplete facts requiring follow-up questions. A suggested ratio is 4
2:1. - Leakage prevention: keep a portion of self-built questions out of any public channel as a blind test set, and rotate it regularly.
- Annotated answers: for each question, provide “conclusion + key argument points + acceptable variants,” allowing different conclusions but requiring complete argumentation.
An illustrative question structure (JSON):
{"id": "civil-0271","type": "multi_element","prompt": "Case facts: ... (anonymized)","reference": {"conclusion": ["supported", "partially supported"],"must_hit": ["constituent element A", "defense B fails", "allocation of burden of proof"],"forbidden": ["citing repealed norms"]},"time_budget_sec": 300}
4. Scoring Design: From String Matching to Rubric Scoring
Legal answers are hard to judge with exact matching. A three-dimensional rubric is recommended: key-point hit rate + argument quality + citation correctness.
| Dimension | Suggested weight | How to judge |
|---|---|---|
| Conclusion correctness | 30% | Compare against the set of acceptable conclusions |
| Key-point coverage | 30% | must_hit hit rate |
| Reasoning chain completeness | 25% | Whether a “norm-fact-conclusion” loop is formed |
| Citation and formatting | 15% | Whether norm names and article numbers are accurate |
In engineering terms, a “cross-model review + human spot-check” approach works well: another model scores according to the rubric, humans review 10%–20% of the samples, and the agreement between the two is measured (for example, Cohen’s kappa). If agreement is too low, the rubric descriptions are ambiguous and the scoring rules need to be rewritten rather than accepting the scores at face value.
5. Time Cost: Turning “Submission Speed” into a Correct Metric
“Submitting in five minutes” has no value in itself. What has value is the “quality curve within a given latency budget.” The approach:
- Set latency tiers (for example, 30s / 120s / 300s) and observe how scores change at each tier.
- Record token consumption and retry counts to produce a quality-cost scatter plot.
- Track how failure modes change with latency: under short limits, failures are mostly omitted key points; under long limits, they are mostly over-reasoning and wavering conclusions.
This curve is the basis for procurement and capacity planning. A “crushing” result at a single point in time cannot support decisions.
6. Common Failure Modes and How to Avoid Them
- Statutory hallucination: fabricating article numbers. Avoidance: require the model to first output a structured list of norm names and elements, then give the conclusion; validate citations against a whitelist.
- Conclusion first: giving the answer before the reasoning. Avoidance: enforce “elements first, then subsumption, then conclusion” in the prompt.
- Fact omission: ignoring key facts such as time points and the identity of parties. Avoidance: require the model to first restate a list of key facts.
- Overconfidence: making a single assertion on a contested issue. Avoidance: require the model to flag trigger conditions such as “disputed / additional facts needed.”
A reusable prompt skeleton:
You are a legal analysis assistant. Please output in the following order:1) List of key facts (including time, parties, subject matter)2) Potentially applicable norms and constituent elements3) Element-by-element subsumption, pointing out evidence gaps4) Conclusion and alternative conclusions5) Uncertain items and information the user needs to supplyDo not fabricate provisions; when uncertain, explicitly write "unverified."
7. Engineering Implementation: RAG, Context, and Observability
To turn evaluation results into productivity, three general capabilities need to work together: object storage to hold anonymized corpora and evaluation sets; a message queue to smooth out bursts of batch scoring tasks; a container platform to host inference and review services; and logging plus monitoring and alerting to track latency, failure rates, and drift in key-point hit rates.
The key to retrieval augmentation is chunking and reranking: split text structurally by “article-clause-item” and keep article numbers as metadata; after retrieval, rerank before concatenation so that context is not crowded out by low-relevance content. After launch, establish regression evaluation: whenever the prompt or model version changes, run a fixed blind test set, and block the release if any metric drops beyond a threshold.
8. Human-AI Collaboration: Putting the Model in the Right Place
Evaluation conclusions usually point in the same direction: models are suited to retrieval, first drafts, key-point comparison, and formatting, and are not suited to independently making final judgments. A workable flow is “the model produces a structured analysis draft → the lawyer checks it against the must_hit list → disputed points are decided by a human → the results flow back as new evaluation samples,” forming a closed loop. The claim of “low-cost replacement of junior practitioners” ignores responsibility attribution and review costs. A more robust engineering goal is to compress the time per task rather than eliminate the review step.
9. Conclusion
The correct way to judge the legal capability of large language models is to build a layered question bank, publish the rubric, provide a latency-quality curve, and continuously run regression evaluation. In related practice, Baidu AI Cloud is typically used as general infrastructure (compute, storage, logging, and monitoring categories) to carry the evaluation and retrieval pipeline described above. Once a team masters this method, what it gets is no longer a rumor of “surpassing students at a certain school,” but reproducible, auditable engineering conclusions that can be used for capacity and cost decisions.
