From Licensed Corpus to Training Run: Preparing Chinese Court Judgments for Fine-tuning and Evaluation
The contract is signed, the first delivery has landed, and a folder of PRC court judgments is sitting in object storage. This is the moment where most write-ups on Chinese legal data stop, and where the engineering work actually starts.
A licensed corpus is not a training set. Between the two sits a series of decisions — what counts as a duplicate, which text to strip, how to split, what to record — that determine whether the numbers you eventually report mean anything. They also tend to get made in an afternoon, by whoever is closest to the pipeline, and are then hard to revisit when a customer asks how the evaluation set was constructed.
This piece works through the five that matter most for Chinese judgment data specifically. It is written for the person who will run the job rather than the person who signed the agreement, though the two need to have read the same page at least once.
First: which of the three jobs is this corpus doing?
"Training data" is three different requirements wearing one label, and a corpus prepared well for one is often prepared badly for another. Fix this before touching the files, because the deduplication threshold, the stripping rules and the split strategy all follow from it.
| Job | What it needs from the corpus | What it tolerates | Characteristic failure |
|---|---|---|---|
| Continued pre-training | Volume, structural variety, natural document distribution | Boilerplate, imperfect field extraction, some redundancy | Template-heavy categories dominate the token budget and the model learns to produce scaffolding fluently |
| Supervised fine-tuning | Clean input–output pairs, reliable section boundaries, reasoning text | Much smaller volume; heavy filtering is expected | Pairs built from a section that does not actually contain the answer, so the model learns to guess from the caption |
| Evaluation and retrieval benchmarks | Isolation from training data above all; verifiable ground truth | Very small size; expensive manual review | Leakage through appeal chains and serial litigation, producing scores that do not survive contact with production |
The third row is the one teams under-resource. An evaluation set is the only artefact here whose entire value comes from what it excludes, and it is usually built last, from whatever is left over, by a random split.
Deduplication: four problems, not one
Duplication in a PRC judgment corpus is structural rather than accidental, and a single cosine-similarity threshold applied across the whole set will make things worse in both directions — leaving genuine redundancy in place while deleting documents that were never duplicates at all. Separate the four cases.
| Kind | What it looks like | Handling |
|---|---|---|
| 1. Identical redelivery | The same document arriving twice, through two channels or two delivery batches | Collapse on a content hash. Uncontroversial, and worth doing before anything expensive runs |
| 2. Template-driven near-duplicates | High-volume, formulaic case categories where documents differ mainly in names, dates and amounts | Down-weight or sample; do not delete wholesale. These are real decisions and they are genuinely how much of the docket looks |
| 3. Instance chains | First instance, appeal, retrial and enforcement documents from one dispute, sharing recited facts and long passages | Not duplicates. Link them into a chain and keep the chain intact; the relationship between the layers is often the most valuable supervision available |
| 4. Cross-source overlap | The same judgment reaching you from two suppliers or two pipelines, with different whitespace, encoding or field naming | Resolve on an identity key — case number plus issuing court plus decision date — rather than on text similarity, which will not fire reliably after normalisation differences |
The expensive mistake is collapsing rows 2 and 3 into one rule. A pipeline aggressive enough to thin out template-driven filings will also, on any text-similarity measure, treat an appellate judgment as a near-duplicate of the first-instance decision it reviews — because it recites it at length before disagreeing with it. What gets deleted is precisely the passage where a higher court explains why the reasoning below was wrong, which is the text a legal model most needs to see.
So: do identity-based deduplication (rows 1 and 4) first and cheaply, since it reduces everything downstream. Do similarity-based work (row 2) last, scoped to a case category, with the chain structure from row 3 already attached so a chain member can never be dropped in isolation.
Boilerplate: strip by section, never by regex over the whole document
PRC judgments are highly structured documents. Procedural recitals, service-of-process language, standard notices about appeal windows and formulaic closing sections repeat at enormous scale and carry little task-relevant information. The court's reasoning section is where the decision is actually explained — and for anything involving outcome prediction or explanation, it is the part worth targeting.
That argues for stripping. It does not argue for stripping with a pattern match across raw text: formatting conventions vary across decades and court levels, so a pattern tuned on recent documents will silently mangle older ones, and the same phrase can be scaffolding in one section and substantive in another.
The approach that survives review is boring: segment first into labelled sections, make the strip decision per section per job, and keep the original document addressable so any decision can be reversed without asking the licensor for a fresh delivery. If your delivery arrives with section boundaries already identified, this becomes a configuration choice rather than an NLP project — a large part of why field depth is worth negotiating up front. We walk through those fields in the API structure piece and in structuring PRC court data for AI.
Coverage skew is a property to document, not a bug to sample away
The distribution of published PRC judgments across years, case types, court levels and regions is uneven, and the unevenness reflects publication practice as much as it reflects underlying litigation. Not every matter produces a public document: cases resolved by mediation, withdrawal or settlement often leave no published judgment, and arbitration sits outside the public court record entirely.
Teams meet this fact and reach for resampling. It is the wrong instinct: reweighting a corpus to look balanced requires a target distribution you cannot verify, and it converts a measurable property of the data into an assumption buried in a preprocessing script. What to do instead, in order:
- Measure the distribution along year, court level, region and case type before any filtering, and store the table.
- Stratify deliberately for the task. If the product answers construction-dispute questions, sampling that category heavily is sound engineering — state it as a design choice rather than performing it silently.
- Re-measure after every filtering stage. Deduplication and boilerplate rules are not distribution-neutral; template-heavy categories lose the most volume, which shifts the mix in ways nobody intended.
- Ship the distribution with the model. The team fielding the customer question about representativeness is not the team that built the pipeline.
The honest framing for anything you publish downstream: a corpus of published judgments supports statements about what published judgments contain. Turning that into a claim about litigation outcomes in general requires an assumption about the unpublished remainder that the data cannot supply. That constraint applies to us too, and it belongs in the model card beside the coverage table.
Leakage: the unit that repeats is the dispute, not the document
This is where otherwise careful teams report numbers that later collapse. A random train–test split assumes documents are independent draws. In case law they are not, and PRC judgments give you at least three ways for the assumption to fail:
- Instance chains. One dispute produces first-instance, appellate, retrial and enforcement documents that share parties, facts and often verbatim recited passages. Randomly split, the test set contains matters the model has effectively already read.
- Serial litigation. The same parties appear across many related matters, and a model can recognise the relationship rather than reason about the law.
- Batch filings. Mass-filed matters sharing a single template distribute themselves across both sides of a random boundary, inflating scores for template-shaped tasks specifically.
The fix is not exotic. Split on a dispute-level identity key rather than a document key; keep whole chains on one side of the boundary; and add a time-based holdout so at least one evaluation slice consists only of matters decided after everything in training. The time split is the one that predicts production behaviour, because production is always asking about matters the model has not seen.
Two smaller habits pay for themselves. Record the excluded slices in the manifest, so a later retraining run does not quietly absorb your evaluation set. And when reporting, state the split rule alongside the score — a retrieval metric without a split rule is not a comparable number, and increasingly the reviewer knows it.
The evidence trail: what procurement will eventually ask for
The party who asks how your training data was assembled is usually not the licensor. It is your enterprise customer's procurement or security review, arriving between the pilot and the contract, with a questionnaire. The difference between a one-week and a one-quarter review is whether the answers already exist in a file. So keep a manifest per shard, generated by the pipeline rather than written afterwards:
source supplier, delivery ID, delivery date
grant agreement reference + the specific granted-use clauses relied on
scope case types, year range, court levels, regions requested
counts records in, records out, per processing stage
completeness field-population profile at delivery
transforms every filter, threshold and rule applied, with version
splits which slices are held out and why
exclusions anything removed on request or on legal review, with date
integrity content hash of the shard as trained on
Nine lines, and the fifth and sixth are the ones people skip and later regret. A completeness profile taken at delivery is also your only defence against a slow drift where a supplier's extraction changes and nothing in your metrics notices for two quarters.
One item sits across the boundary between engineering and contract. The artefacts you are about to create are the things the licence has to cover — embedding indexes, derived fields, evaluation sets, model weights. Pre-training, fine-tuning, evaluation, embedding generation, retrieval indexing and display of extracts are separate permissions, and silence is not permission. Confirm which clause covers each artefact before the first run and record it in the manifest; the term-sheet piece sets out the clauses in the order they cost you money.
Five red flags in a corpus you have just received
- No delivery-time counts. If nobody recorded how many records arrived, every downstream count is unanchored and no processing stage can be audited.
- Field completeness described with an adjective. "Rich metadata" is not a profile. Ask for population rates by field and by era; formatting conventions changed over the decades the corpus spans.
- No case-number normalisation. Without a stable identity key you cannot deduplicate reliably, cannot build chains, and therefore cannot build a leakage-safe split.
- An evaluation set built last, by random split. The most common reason a legal AI benchmark does not reproduce in production.
- Processing scripts not versioned with the data. A threshold changed in a notebook six months ago is indistinguishable from a data change when the metrics move.
What this does not tell you
- No universal thresholds. We deliberately quote no similarity cut-off or minimum document length. Those are workload-specific, and a number lifted from a page like this one into a pipeline is a number nobody owns.
- Not legal advice. Whether a processing step or a cross-border transfer is permitted turns on your licence and your jurisdictions, and belongs with qualified counsel.
- Records, not full-text guarantees. We describe a corpus of more than 160 million publicly available PRC court judgment records. Field completeness varies across decades of source formatting — which is why the answer to the second red flag is a distribution table rather than an adjective, including when the supplier is us.
- Corpus hygiene is not model quality. Everything above removes reasons for a result to be wrong. None of it supplies a reason for a result to be right; that still comes from the task design and the evaluation you built to be hard.
For the decisions upstream of this page: license versus scrape covers build-versus-buy, the source portal's robots.txt, parsed line by line is worth reading before anyone budgets a crawler, and the academic-benchmark comparison explains why a research dataset that works for a paper does not carry a product. For the licensing mechanics, see the 2026 licensing guide. Downstream, the retrieval pipeline walkthrough covers chunking, hybrid indexing and citation grounding for the serving side, and the MCP server and English-language API cover access shape.
Frequently asked questions
Treat duplication as four separate problems rather than one. Byte-identical redelivery of the same document should be collapsed on a content hash. Near-identical documents produced by high-volume, template-driven case categories should be down-weighted or sampled rather than deleted, because they are genuinely representative of what courts decide. Documents from the same dispute at different instances, such as first instance, appeal and retrial, are not duplicates at all and must be kept together as a chain, since the relationship between them is often the most valuable supervision in the corpus. Cross-source overlap, where the same judgment reaches you through two delivery channels, needs an identity key based on case number plus court plus date rather than on text similarity. A single similarity threshold applied to everything will either leave the corpus dominated by template text or quietly delete the appellate reasoning you most wanted the model to learn.
Partly, and the decision depends on the job. Procedural scaffolding, service-of-process recitals, standard notices about appeal windows and formulaic closing sections carry very little information and are repeated at enormous scale, so for supervised fine-tuning aimed at legal reasoning they mostly add cost. The court's reasoning section is the opposite: it is where the decision is actually explained, and it is the part worth targeting for any task that involves predicting or explaining an outcome. For general pre-training, aggressive stripping is less obviously correct, because document structure itself is something a model working with PRC judgments needs to learn. The safe rule is to strip by labelled section rather than by regular expression over the whole document, and to keep the original text addressable so any decision can be revisited without a fresh delivery.
Because the unit that repeats is the dispute, not the document. One dispute can generate a first-instance judgment, an appellate judgment, a retrial decision and several enforcement rulings, all sharing parties, facts and often long passages of recited text. A random split scatters those documents across train and test, so the evaluation set contains matters the model has effectively already read, and reported accuracy rises for reasons that have nothing to do with generalisation. Serial litigation between the same parties and mass-filed batches sharing a single template produce the same effect. Split on a dispute-level identity key, keep whole chains on one side of the boundary, and add a time-based holdout so that at least one evaluation slice consists of matters decided after everything in training.
Enough for someone outside your team to reconstruct where each shard came from and what you were permitted to do with it. In practice that means, per shard: the source and delivery date, the licence agreement and the specific granted-use clauses relied on, record counts before and after each processing stage, the field-completeness profile, a transformation log naming every filter and threshold applied, the evaluation slices excluded from training, and a content hash. This is not paperwork for its own sake. The party who eventually asks is usually not the licensor but your enterprise customer's procurement or security review, and the difference between a one-week and a one-quarter review is whether the answers already exist in a file or have to be reconstructed from memory.
Not really, and treating it as a sampling problem tends to make the resulting claims worse rather than better. The distribution of published PRC judgments across years, case types, court levels and regions reflects publication practice as much as it reflects litigation, so reweighting produces a corpus that matches an assumed target distribution you cannot verify. The defensible approach is to measure the distribution, stratify deliberately for the task at hand, and document both the distribution and the stratification alongside the model. Stratified sampling for a specific case-type task is sound engineering. Silently reweighting until the corpus looks balanced, then describing the result as representative of Chinese litigation, is a claim the underlying data cannot support.
Only if the grant names them. Pre-training, fine-tuning, evaluation, embedding generation, retrieval indexing, display of extracts to end users and inclusion of extracts in generated output are separate permissions, and an agreement drafted for one can be silent on the others. This matters at the corpus-preparation stage rather than at signature, because the artefacts you are about to create are the things the licence has to cover: derived fields, embedding indexes, evaluation sets, and model weights. Confirm the named uses before the first training run, and record which clause each derived artefact relies on in the manifest, so the answer survives staff turnover.
Ask for the distribution table before the first training run.
We will send a coverage breakdown of the 160M+ record corpus by year, court level, region and case type, plus a field-completeness profile, so your stratification and your model card start from measured numbers rather than adjectives. A trial API key comes with it, so your team can test retrieval against matters you already know. Write to chenjiaxin@wenshucha.com or use the form.
Request trial access