Building and Evaluating Legal Vertical Large Models: Practical Lessons

    This article explains why general-purpose large language models struggle with legal workflows and how to build a legal vertical model instead. It covers a three-stage training path (domain intermediate training, supervised fine-tuning, and reinforcement learning post-training), evaluation metrics that emphasize task pass rate over raw accuracy, and document-centric delivery with human-in-the-loop review. A practical checklist and risk boundaries are included for teams deploying domain models in production.

    The problem general-purpose LLMs face in legal scenarios is not a lack of knowledge. It is a mismatch between their capability structure and business requirements. Legal practice depends on three core demands: traceable conclusions, revisable output, and clearly defined accountability. General models excel at fluent generation and tend to produce answers that look complete but lack a chain of evidence. Legal professionals, however, need a bundle of three things: a conclusion, its supporting basis, and a record of changes.

    The pain points usually fall into four categories:

    • High cost of hallucination: Clause citations look well-formed but do not actually exist, making review comments unusable.
    • Weak long-document handling: Contracts and evidence files often run to tens of thousands of words, and cross-section references and internal contradictions are hard to identify reliably.
    • Mismatched output format: Business teams want revisions and annotations that can be dropped directly back into a document, not a conversational suggestion.
    • Ambiguous evaluation criteria: Judging only whether an answer “sounds right” rather than whether the task is actually completed.

    The goal of building a legal vertical model, therefore, is not to make the model “talk more like a lawyer.” It is to embed the model into a deliverable workflow.

    2. Build Path: From a Lightweight Base to a Domain-Specific Model

    A route widely validated in the industry is “lightweight base + domain intermediate training + post-training alignment.” A lightweight base keeps inference cost and throughput under control, so the model can be applied in batch to document-level tasks rather than only single-turn question answering.

    Step 1: Domain intermediate training. The goal is to fill gaps in domain language distribution and foundational knowledge. Common corpora include publicly available laws and regulations, contract samples, court judgments, and compliance standards. Two things matter at this stage. First, corpus cleaning and deduplication, to avoid distribution bias caused by templated text. Second, knowledge freshness management: laws and regulatory requirements keep changing, so corpus versioning and traceability mechanisms are needed.

    Step 2: Supervised fine-tuning. This turns “knowledge” into “task capability.” Training data should cover tasks such as contract review, evidence element extraction, and compliance gap analysis, unified into structured input and output. An illustrative training sample looks like this:

    1. {
    2. "task": "contract_review",
    3. "input": {
    4. "clause": "Party B shall not engage in any competitive business in any manner during the cooperation period.",
    5. "context": ["Contract term: 3 years", "Governing law: not specified"]
    6. },
    7. "output": {
    8. "risk_level": "high",
    9. "issue": "The scope and duration of the non-compete restriction are unclear, and no compensation terms are included",
    10. "suggestion": "Define the business scope, region, and duration, and add compensation clauses",
    11. "evidence_span": "Article 7"
    12. }
    13. }

    Step 3: Reinforcement learning post-training. Reward signals for legal tasks are hard to reduce to a single metric, so practice often relies on a combined objective: correctness of the conclusion, locatability of the supporting basis, format compliance, and a penalty term for “abstaining when uncertain.” Teaching a model to say “insufficient basis” is often more valuable than forcing it to answer.

    3. Evaluation: Why Task Pass Rate Matters More Than Accuracy Alone

    A single accuracy figure hides risk. If a contract review task contains eight risk points and the model catches seven, accuracy looks high, but the review is still unusable in practice. The industry has therefore moved toward stricter criteria:

    • Task pass rate: A task counts as passed only when every sub-item is correct, which maps directly to deliverability.
    • Accuracy: Reflects the overall hit level and is used to observe the capability baseline.
    • Cross-validation across public leaderboards: Leading on multiple independent evaluation sets at the same time reduces the credibility risk of overfitting to a single benchmark.

    For engineering, it is advisable to build a regression evaluation set, turn real anonymized production samples into fixed test cases, and run them on every model iteration to form a guardrail against capability regression.

    4. Delivery Format: Bringing Capability Back into Documents

    The last mile of model capability is the interaction format. Legal professionals will not change their working habits, so a workable approach is to embed capability into office documents: use track-changes mode to suggest replacements, deletions, and insertions, use comments to explain risks and supporting basis, and let a human accept or reject them. This human-in-the-loop design satisfies accountability requirements and makes model output naturally auditable.

    The architecture can be layered and decoupled:

    1. Access layer: document parsing and structure restoration (paragraphs, clause numbering, tables).
    2. Orchestration layer: task routing that distinguishes review, extraction, comparison, and generation.
    3. Model layer: the domain model provides reasoning capability, invoked through a unified gateway.
    4. Governance layer: logging services record inputs, outputs, and evidence snippets; monitoring and alerting track failure rates and latency; object storage keeps anonymized samples and evaluation baselines.

    For batch processing, a message queue can smooth peaks and handle retries. For on-premises deployment, the model can run on a container platform, with quotas and canary releases to control risk.

    5. Practical Checklist and Risk Boundaries

    • Establish a data compliance process: anonymization, authorization, and retention periods clearly defined.
    • Enforce evidence backfilling: conclusions without a supporting basis do not enter deliverables.
    • Set confidence thresholds and a human review queue.
    • Version prompts and evaluation sets to avoid “changed the prompt, lost the capability.”
    • Define the model’s role clearly: an assistive tool, not the final issuer of legal opinions.

    In summary, the value of a legal vertical model comes from the combination of domain training, rigorous evaluation, and workflow embedding. When selecting a model, developers should prioritize task pass rate, traceability of supporting basis, and document integration capability rather than leaderboard scores alone. Baidu AI Cloud can provide infrastructure support such as a container platform, logging services, and monitoring and alerting for related general capabilities, helping enterprises deploy vertical models reliably into business systems.