Engineering reference

Building a Chinese Legal Retrieval Pipeline: ETL, Indexing, Citations

Most "add China coverage" projects die in the same place: a team licenses or scrapes a pile of Chinese judgments, drops them into a vector database, runs a demo, and watches it confidently return cases that look right and were decided the opposite way. The corpus was never the hard part. The hard part is the retrieval pipeline — the machinery that turns 170M+ heterogeneous documents into something a model can search, rank, and cite without lying.

This is a reference architecture for that pipeline, written for the ML, platform, and search engineers who have to build it. It assumes you already have, or can license, a structured corpus — if you are still deciding how to assemble one, start with how to structure PRC court data for AI and the license-vs-scrape tradeoff. Here we pick up after the corpus and walk the five stages: ETL, chunking and embedding, hybrid indexing, query-time retrieval, and the citation and eval layers that make the whole thing trustworthy.

The pipeline at a glance

StageWhat it producesWhat breaks without it
1. ETL & ingestionClean, structured, de-duplicated records with stable IDs and extracted fieldsGarbage in — every downstream stage inherits noise, duplicates, and missing metadata
2. Chunking & embeddingSection-aware passages, each encoded and carrying its parent's metadataRetrieval returns whole documents or severed fragments; citations don't resolve
3. Hybrid indexingA lexical index + a vector index, both filterable by structured fieldsExact terms (case numbers, statute articles) are blurred away or scanned blindly
4. Retrieval & rerankA filtered, fused, reranked candidate set for each queryLook-alike cases outrank on-point ones; precision collapses at the top
5. Citations & evalsA resolvable source per passage; measured recall, ranking, false-precedent rateUnverifiable answers; no way to know whether a change helped or hurt

Stage 1 — ETL: the layer most teams underestimate

Extract-transform-load over Chinese judgments is not a weekend script. The source documents are highly formatted but carry their metadata in prose, the same matter appears across instances and reposts, redaction is built in under Supreme People's Court rules, and format and encoding drift across thousands of courts and two decades of publication. A cleaning rule that holds for 99% of documents still fails on more than a million.

The ETL stage has to deliver, for every record:

This is the layer with the worst ratio of effort to product differentiation. Two teams with the same clean corpus compete on retrieval and UX, not on who cleaned the text better. It is also why many teams license the corpus-and-ETL layer rather than rebuild it — we break that decision down in the license-vs-scrape piece. Either way, treat ETL output as a contract: a typed, validated schema your indexing stage can rely on.

Stage 2 — Chunking and embedding, the legal way

Naive fixed-size chunking is where legal retrieval quietly degrades. A 512-token window that splits a holding from the reasoning that supports it, or fuses two unrelated parties' claims, produces passages that retrieve well and cite badly. Chinese judgments give you a better seam: they are written in recognizable sections — caption, procedural history, findings of fact, reasoning, holding. Chunk along those sections, not along arbitrary token counts.

Practical guidance:

Stage 3 — Hybrid indexing: lexical and vector, not one or the other

The single most common mistake is going pure-vector. Dense embeddings are excellent at semantic similarity and disastrous at the exact tokens legal relevance often turns on: a case number, a specific statute article, a precise monetary threshold, a named cause of action. Vector search will happily return a factually similar case that was decided the opposite way while missing the on-point case that happened to use different phrasing.

The production answer is a hybrid index:

IndexStrong atWeak at
Lexical (BM25-style)Exact case numbers, statute articles, rare terms, precise figuresParaphrase, synonymy, conceptual similarity
Vector (dense)Semantic similarity, "cases like this" by fact patternExact identifiers; can rank look-alikes over on-point cases
Structured filtersCause of action, court level, date range, document type, outcomeNothing — they constrain, they don't rank

Build all three over the same records: a lexical index, a vector index, and structured fields you can pre-filter on. The fields are the cheapest, highest-leverage win — constraining to the right cause of action and court level before you rank shrinks the candidate set to cases that are actually comparable, which is exactly what a lawyer does first.

Stage 4 — Retrieval and reranking at query time

With the index in place, each query runs a four-step path:

  1. Structured pre-filter. Lock the obvious constraints — cause of action, court level, time window, document type. This removes whole classes of non-comparable cases before ranking and is where the "decided the opposite way" failures are cheapest to kill.
  2. Parallel recall. Run lexical and vector retrieval together and fuse the candidate lists (a rank-fusion method such as reciprocal rank fusion is a sound default). You want the on-point case whether it matched by wording or by meaning.
  3. Rerank. Pass the fused top candidates through a cross-encoder reranker that scores query-passage pairs jointly. This is the step that most improves top-k precision — the difference between "ten plausible cases" and "the three that actually govern."
  4. Ground. Return each surviving passage with its citation attached, ready for the model to cite and a lawyer to verify.

This is the same methodology, viewed from the data side, that we describe for similar-case retrieval generally. If you want the buyer-side framing of the whole stack rather than the pipeline internals, see Building China coverage into your legal AI.

Stage 5a — Citation grounding: a data property, not a prompt

For legal AI, the line between a usable system and a malpractice risk is whether every surfaced fact resolves to a real document. Grounding cannot be bolted on at the end with a clever prompt; it is something the pipeline either preserves or destroys. Three earlier decisions determine it:

Get those right and a retrieval-augmented system can show its work: every passage opens to the judgment behind it. Drop the IDs anywhere in the chain and the answers become unverifiable, which in a legal product is the same as wrong. "We have the documents" and "our AI can cite from them" are different claims, and the gap between them is this pipeline.

Compliance note: published Chinese judgments retain party names while redacting personal identifiers, and cross-border use is framed by the Personal Information Protection Law and the Data Security Law. This is informational background, not legal advice — structure any data and licensing arrangement with qualified counsel.

Stage 5b — Evals: you cannot improve what you do not measure

Without an evaluation harness, every pipeline change is a guess. Build a labeled set of real legal queries with known-relevant judgments — a few hundred, spread across causes of action and court levels — and track three families of metric:

Re-run the harness on every change to embeddings, chunking, fusion weights, or reranker. The number that matters is not a leaderboard score on someone else's benchmark — it is performance on your queries against your corpus.

Build vs license, layer by layer

Not every layer deserves your engineers' time. A useful split:

LayerTypical decisionWhy
Corpus + ETLUsually license170M+ judgments, cleaning, de-dup, field extraction, citation linking, and the legal right to ingest — high cost, low differentiation
Chunking + embeddingBuild, tuned to legal ChineseDomain-specific; off-the-shelf choices underperform on legal terms
Hybrid index + retrievalBuildCore product behavior; where your relevance lives
Citations + evalsBuildTrust and iteration speed — nobody can own these for you

The pattern that works for most legal AI vendors: license a structured, citation-linked, English-indexed corpus to remove the corpus-and-ETL burden, then build the indexing, retrieval, and evals that make the product yours. That is precisely the layer SinoVerdict is built to supply.

The bottom line

A Chinese legal retrieval pipeline is five stages, and four of them are where the demos go wrong: ETL that delivers clean, ID-anchored records; section-aware chunking with metadata carried through; a hybrid index that respects exact legal tokens; retrieval that pre-filters, fuses, reranks, and grounds; and an eval harness honest enough to catch a look-alike masquerading as precedent. SinoVerdict supplies the foundation those stages stand on: a structured, machine-readable corpus of more than 170 million Chinese judgments — normalized, de-duplicated, field-extracted, and citation-linked, with English query and summaries and links back to source — delivered as a bulk dataset to seed your index, a REST API to serve queries, and an MCP server for Claude, ChatGPT, and Cursor, with daily updates.

Build your retrieval on a corpus that's already clean

Request a trial API key and a corpus coverage report — including the field schema and a sample of structured, citation-linked records — and run it against your own recall, ranking, and false-precedent evals.

Request trial access & coverage report

Or email chenjiaxin@wenshucha.com · See how delivery works

Frequently asked questions

What does a retrieval pipeline for Chinese case law actually consist of?

Five stages: ETL that turns raw judgments into clean, structured, de-duplicated records with stable IDs; chunking and embedding that segment each judgment into retrievable passages carrying their metadata; hybrid indexing that builds a lexical index for exact terms and a vector index for semantic similarity, both filterable by structured fields; retrieval that runs filtered hybrid search plus reranking; and a citation-and-eval layer that grounds every passage to a source and measures recall, ranking, and false-precedent rate.

Why isn't pure vector search enough for Chinese legal retrieval?

Legal relevance often hinges on exact tokens a dense embedding blurs — case number, statute article, monetary threshold, cause of action. Pure vector search retrieves cases that look similar but were decided the opposite way, and misses on-point cases that used different wording. Use hybrid: structured pre-filter, parallel lexical and dense recall, cross-encoder rerank, then grounding to the source.

How do you keep a Chinese legal retrieval system grounded and citable?

Grounding is a property of the data, not a prompt. Every chunk must carry a stable record ID and resolving metadata — case number, court, date, source link — through the whole pipeline, and retrieval must return that citation so a lawyer can verify it. If IDs are dropped during ETL or chunking, nothing downstream makes answers traceable.

Should a legal AI team build this pipeline or license a structured corpus?

Indexing, retrieval, reranking, and evals are core product work to own. The expensive, low-differentiation layers are the corpus and the ETL that cleans, de-duplicates, field-extracts, and citation-links 170M+ judgments, plus the legal right to ingest them. A common split: license a structured, license-ready corpus and English layer, then build the retrieval that makes your product distinctive.

What does SinoVerdict provide for building a Chinese legal retrieval pipeline?

A structured, machine-readable corpus of more than 170 million Chinese judgments — already normalized, field-extracted, de-duplicated, and citation-linked, with English query and summaries and links back to source — delivered as a bulk dataset to seed an index, a REST API to serve queries, and an MCP server for Claude, ChatGPT, and Cursor, with daily updates. A trial API key and coverage report are available on request. Clients include LexisNexis and China's leading legal databases. Informational background, not legal advice.