Why Legal Tech Companies Build Their Own LLMs: Open-Weight Base Models and Domain Adaptation
This article examines why legal technology companies increasingly build proprietary models on open-weight base models, despite strict compliance requirements. It breaks down the selection criteria for base models, the pipeline from continued pretraining to supervised fine-tuning and preference alignment, the necessity of retrieval-augmented generation, and a three-layer evaluation framework. It also covers engineering architecture, cost control through model routing, and common risks such as license compliance and catastrophic forgetting. The core takeaway is that the real moat lies in data governance, evaluation loops, and retrieval infrastructure rather than the model itself.
1. Industry Context: Why Legal Is a High Bar for In-House Models
A US legal tech company valued in the tens of billions recently announced its first proprietary model, built by post-training an open-weight base model. The news drew attention in developer communities—not because another open-weight derivative had appeared, but because a company in one of the most compliance-sensitive industries chose an open-weight path for its core capability.
Post-training on open-weight bases is already common practice. Coding assistant vendors use it for code completion and repository-level understanding; local services and mobility platforms use it for customer support, intent recognition, and structured extraction. The drivers are consistent: controllable inference cost, private deployment, and deep customization on vertical corpora. What makes legal different is that it pushes all three constraints to the limit.
Three hard constraints shape model strategy in legal:
- Confidentiality: Contracts, M&A materials, and litigation files are highly sensitive; cross-border transfer and third-party retention require strict assessment.
- Accuracy: Errors in clause comparison, obligation extraction, or timeline reconstruction can cause material legal and commercial damage.
- Traceability: Outputs must link back to source text. The model must support citation back-references, not just conclusions.
Proprietary closed APIs fall short on all three: data must leave your boundary, versions are controlled externally, and behavior cannot be fine-tuned. In-house development is therefore not a technical flex but a risk-management necessity.
2. Why the Companies That “Should” Avoid External Models Build First
The intuitive assumption is that heavier compliance pressure calls for more conservatism. The actual logic is the opposite: the heavier the compliance burden, the more you need model behavior inside your internal audit scope. With an external API, you can only audit inputs and outputs. With weights and the training pipeline in hand, you can audit data mixtures, training epochs, refusal policies, and evaluation results.
The core abstraction here is trading control and explainability for out-of-the-box generality. You give up some general capability to gain full control over failure modes. For legal products, predictable failure matters more than occasional high scores.
3. Technical Breakdown: From Open Base to Domain Model
3.1 Key Criteria for Base Model Selection
Do not score candidates on leaderboard benchmarks alone. Recommended dimensions:
| Dimension | What to Check |
|---|---|
| License | Commercial use allowed, derivative open-sourcing required, attribution obligations |
| Context length | Stable long-context performance for long contracts and case files |
| Structured output | Reliable strict-mode structured generation |
| Deployment | Private deployment support, acceptable accuracy loss after quantization |
| Ecosystem maturity | Fine-tuning frameworks, inference runtimes, quantization toolchain |
Licensing is the most overlooked pitfall: some open weights are research-only or require derivatives to be open-sourced, which directly conflicts with a closed-source commercial product.
3.2 Continued Pretraining: Injecting “Legal Intuition”
General bases often understand legal text only at the surface level. Continued pretraining familiarizes the model with the distribution of statutes, case law, and conventional contract phrasing. Practical points:
- Prioritize corpus cleaning over scale; remove template noise and duplicate clauses.
- Control the learning rate—typically one to two orders of magnitude below pretraining—to avoid catastrophic forgetting.
- Mix in general-domain data (a common practice is retaining a substantial general-data proportion) to preserve general capability.
- Use both perplexity and downstream task metrics to decide when to stop.
Illustrative training config:
config = {"base_model": "open-weights-model", # Open-weight base"stage": "continued-pretraining","lr": 2e-5, # Far below pretraining learning rate"global_batch_size": 1024,"max_seq_len": 32768, # Covers long documents"general_ratio": 0.3, # General corpus share, prevents forgetting"save_every_steps": 500,}
3.3 Supervised Fine-Tuning and Preference Alignment
Supervised fine-tuning handles “working in the right format”; preference alignment handles “refuse rather than fabricate.” For legal, construct three preference pairs:
- Grounded answers vs. fluent but unsupported answers (suppress hallucination);
- Answers with clause citations vs. answers without (reinforce traceability);
- Answers that state uncertainty vs. answers that force a conclusion (calibrate confidence).
3.4 Retrieval Augmentation Is a Requirement, Not an Option
No domain model, however strong, can memorize a client’s private documents. The standard approach decouples retrieval from generation:
def legal_qa(query, store, model):hits = store.search(query, top_k=8) # Hybrid vector + keyword recallcontext = rerank(hits, query)[:5] # Rerank and denoiseprompt = build_prompt(query, context) # Enforce source numberingout = model.generate(prompt, max_tokens=1200)return {"answer": out, "citations": context} # Return citations with the answer
Chunking strategy also matters: splitting by clauses and sections beats fixed-length splitting, because legal semantic boundaries do not align with character boundaries.
4. Evaluation: Turning “It Feels Better” into Numbers
Build a three-layer evaluation:
- General capability: general understanding and long-document summarization, to catch models degraded by domain training;
- Domain tasks: obligation-party extraction, clause change comparison, deadline calculation, measured with exact match and field-level F1;
- Safety and refusal: refusal rate and false-refusal rate for out-of-scope or beyond-material questions.
A minimal, deployable evaluation skeleton:
def evaluate(model, cases):stats = {"f1": [], "citation_hit": [], "refuse_ok": 0}for c in cases:r = model.answer(c["query"])stats["f1"].append(field_f1(r, c["gold"]))stats["citation_hit"].append(cite_in(r, c["source"]))if c["should_refuse"] and r.refused:stats["refuse_ok"] += 1return {k: sum(v) / len(v) for k, v in stats.items() if isinstance(v, list)}
The key principle: keep the evaluation set strictly isolated from the training set and involve legal staff in annotation. Otherwise, metric gains carry no business meaning.
5. Engineering and Cost: In-House Does Not Mean Building Everything
Beyond the model itself, supporting capabilities can lean on general cloud services: object storage for corpora and weights, container platforms for elastic inference and canary releases, message queues to smooth batch document parsing, and logging plus monitoring and alerting to track latency, refusal rate, and hallucination complaints. The capability shapes offered by Baidu AI Cloud in these general categories can serve as an architecture reference; specific choices should still follow your own compliance assessment.
Three effective cost controls: small models for narrow tasks like classification and extraction, large models only for complex reasoning, and semantic caching for high-frequency requests. In practice, tiered routing usually beats simply swapping in a larger model.
6. Common Risks and Mitigations
- License risk: complete license review before launch and retain records;
- Catastrophic forgetting: keep general-capability regression tests as a release gate;
- Data contamination: deduplicate training corpora and use source allowlists;
- Version drift: pin base model versions and inference parameters; route changes through canary releases;
- Liability boundary: position the product clearly as an “assistive tool” and keep human review in the loop.
7. Conclusion
The choice made by legal tech companies signals a trend: when data sensitivity, accuracy, and auditability are all maxed out, an open-weight base plus deep post-training becomes the mainstream engineering paradigm. The real moat is not the model itself but the “unsexy” infrastructure—data governance, evaluation loops, and the retrieval pipeline.
