Building Vertical Large Language Models for Legal: Architecture, Workflows, and Best Practices
This article explains why general-purpose LLMs fall short in legal practice and how to build a legal-specific model using a lightweight base model, domain continual pre-training, and RLHF with verifiable rewards. It covers real-world workflow design for contract review, evidence analysis, and compliance planning, along with evaluation methodology and deployment recommendations such as private deployment, human-in-the-loop review, and traceable outputs.
Why the Legal Industry Needs Vertical LLMs
General-purpose large language models offer broad knowledge coverage, but they typically fall short in legal practice in three ways:
- Highly specialized text. Legal language follows strict conventions in terminology, statute citation formats, and judicial document structure. General models often produce output that reads fluently but is substantively inaccurate.
- Accuracy and traceability requirements. Legal tasks demand far higher precision than general conversation—a single misquoted clause can create real risk.
- Long-chain, multi-document workflows. Real legal work often involves long, multi-document tasks. Contract review, for example, requires comparing the main agreement, attachments, and relevant regulations simultaneously. General models struggle with stability in multi-turn reasoning and structured output.
The industry-standard approach is to start from a general base model and train a legal-specific model through domain data injection and task alignment. These models are often released with open weights, allowing law firms and corporate legal teams to deploy them in private environments—balancing data compliance with cost control.
Technical Architecture: Lightweight Base Model + Domain Post-Training
A typical technical roadmap for legal-specific models follows a three-stage pattern: lightweight base model → intermediate training → reinforcement learning post-training.
Base Model Selection
Choosing a lightweight base model is the mainstream choice for vertical domains, for three reasons:
- Lower deployment cost: Legal scenarios usually require private deployment. Lightweight models demand less GPU memory and fewer inference resources, making them affordable for small and medium-sized teams.
- Faster iteration: A moderate parameter scale means more controllable data and compute investment for domain training, making it easier to keep pace with regulatory updates.
- Strong fine-tuning results: Extensive practice shows that with high-quality domain data, small-to-mid-sized models can approach or even outperform larger general-purpose models of the same generation on specialized tasks.
Legal Domain Continual Pre-Training
The core of the intermediate training stage is building a high-quality legal corpus. Common data sources include:
- Normalized texts of laws, regulations, and judicial interpretations;
- Anonymized judicial and arbitration documents;
- Contract templates, clause libraries, and review annotations;
- Legal Q&A, case analysis, and other professional content.
The key at this stage is not just how much data you feed in, but data cleaning and mixing ratios. For example, you need to control the ratio of legal to general-purpose corpus so the model gains domain knowledge without losing general reasoning and instruction-following ability.
Reinforcement Learning Post-Training (RLHF / RLAIF)
Legal tasks have highly structured evaluation criteria, making them well suited to rule-based reward signals. For example:
- In clause review, rewards can be constructed across multiple dimensions: completeness of risk identification, correctness of statute citations, and actionability of revision suggestions.
- In evidence analysis, reward signals can be anchored to the accuracy of fact extraction and consistency of timeline reconstruction.
- In compliance planning, checklist coverage rate can serve as the reward basis.
This “verifiable rewards” approach significantly suppresses hallucination and brings model output closer to real legal practice standards.
Capability Design for Real Legal Workflows
The value of a vertical model ultimately shows in closed-loop workflows rather than single-turn Q&A. Three scenarios are most representative.
Contract Review
Contract review is essentially “clause-level risk detection + revision suggestion generation.” In engineering terms, the pipeline is typically decomposed as follows:
# Contract review pipeline examplecontract = parse_document("target.docx") # Structured parsingclauses = split_clauses(contract) # Clause segmentationrisks = [model.review(c, checklist=CHECKLIST) # Risk identification per clausefor c in clauses]report = aggregate(risks, format="revision_marks") # Aggregate into revisions and comments
The final deliverable is often not a natural-language summary but “revisions + comments” generated directly in the office document, giving legal professionals a WYSIWYG experience. This reflects an important trend in legal AI product design: embedding model capabilities deeply into document editing environments rather than asking users to change their working habits.
Evidence Analysis
Evidence analysis requires the model to extract factual elements from large volumes of unstructured material (chat logs, receipts, contracts, deposition transcripts), build timelines and relationship networks, and identify contradictions in evidence chains. This task demands strong long-context and structured reasoning capabilities, and typically requires retrieval-augmented generation (RAG), where massive evidence collections are chunked, indexed, and retrieved on demand.
Compliance Planning
Compliance is characterized by dynamically changing rules. The model must continuously track regulatory updates, map new rules to internal policies and business processes, and output gap analyses with remediation suggestions. The architecture usually adopts a two-layer “model + knowledge base” design: the model handles understanding and reasoning, while the knowledge base handles freshness—preventing the model from relying on outdated regulations.
How to Evaluate Legal LLMs Scientifically
Legal evaluation should not rely on accuracy for individual questions alone. Widely accepted practices in the field include:
- All-pass rate per task (a task counts as passed only if every sub-item is correct in strict mode), measuring stable output;
- Overall accuracy, measuring general correctness;
- Per-task evaluation, covering contract review, statute retrieval, case analysis, compliance Q&A, and other dimensions to avoid a lopsided model.
Teams planning to adopt legal LLMs should first establish a baseline on their own anonymized test sets, then compare against locally fine-tuned open-weight models to build an evaluation framework that matches their business.
Deployment Recommendations and Outlook
Based on engineering practice, deploying legal LLMs should follow these principles:
- Private deployment first: Legal data is highly sensitive; prioritize open-weight solutions that can be deployed on-premises.
- Human-in-the-loop positioning: Treat the model as a “first-pass review assistant”—final legal judgments must be reviewed by licensed professionals.
- Traceable output: Require the model to cite the basis for its conclusions (clause locations, statute numbers) for auditability.
- Continuous iteration: Build a closed loop from regulatory updates to corpus updates to model updates.
Looking ahead, as office-document-level integration and agent-based workflow orchestration mature, legal LLMs will evolve from “Q&A tools” into process engines spanning the full contract lifecycle, litigation support, and compliance monitoring. The technical route of lightweight open-source models plus domain post-training will continue to lower the barrier to intelligent legal operations.
