RAG for EPR Legislation
Prompt: How to build a RAG pipeline for global Extended Producer Responsibility legislation. Cover the overall concepts of the RAG pipeline and the challenges of doing RAG, applying it to this particular domain as a running example. Start with a brief introduction to EPR as an interesting example of a complex domain with different laws in different parts of the world.
Retrieval-augmented generation looks simple on a whiteboard: chunk, embed, retrieve, generate. Pointing it at a sprawling, multilingual, constantly amended body of law is where the interesting problems start.
All statute excerpts on this page are simplified or fictionalised for illustration. Nothing here is legal advice, and a system like the one described shouldn't claim to give any either (more on that below).
1. A crash course in EPR
Extended Producer Responsibility (EPR) is a policy idea with a one-sentence core: if you put a product on the market, your responsibility for it doesn't end at the till. It extends to the end of the product's life, which usually means paying for, and sometimes organising, its collection and recycling. The term was coined by Thomas Lindhqvist at Lund University in 1990, and Germany's 1991 Packaging Ordinance (the origin of the "Green Dot" symbol) turned it into working law. The OECD has been publishing guidance on it since 2001.
What makes EPR an interesting domain is that this one simple idea has been implemented in wildly different ways in different parts of the world, and the differences are exactly the kind of thing a business needs precise answers about:
- Different laws per place. The EU has a packaging regulation (the PPWR) that applies from August 2026, layered on top of 27 national systems. The US has no federal law but seven states with their own packaging EPR statutes. Canada runs it province by province. India, Japan and South Korea each have their own decades-old regimes.
- Different definitions. The word "producer" can mean the brand owner, the importer, the first distributor or the online marketplace, depending on the law. A company can be the "producer" in Oregon and not in Maine for the same product.
- Different scope. EPR covers packaging, electronics (WEEE), batteries, textiles, tyres, mattresses, fishing gear and more, each with its own instruments, thresholds and deadlines.
- Constant change. Laws are amended, guidance is reissued, fee schedules are republished annually, and new states and product streams join every year.
| Jurisdiction | Example instrument (packaging) | What makes it awkward for a knowledge system |
|---|---|---|
| EU | Packaging & Packaging Waste Regulation 2025/40 (PPWR) | In force Feb 2025, applies Aug 2026, fee provisions later still; 24 official languages; interacts with 27 national schemes |
| UK | pEPR (Producer Responsibility Obligations Regulations 2024) | Recently restructured; data reporting and fee rules live in separate instruments and guidance |
| US | State laws: ME, OR, CA (SB 54), CO, MN, MD, WA | Seven different statutes plus rulemaking dockets; more states pending; no federal baseline |
| Canada | Provincial regulations (BC, Québec, Ontario...) | Province-level variation; bilingual sources; long-running schemes with layered amendments |
| India | Plastic Waste Management Rules 2016, amended 2022 | Amendments published as deltas; much of the detail lives in regulator (CPCB) guidance and portals |
| Japan / South Korea | Containers & Packaging Recycling Law; Resource Circulation Act | Authoritative text not in English; long histories of revision |
Imagine you're building an assistant for compliance teams: "Do I owe fees on the boxes I ship to Colorado?", "Compare recycled-content rules in the EU and California." The answers exist, scattered across thousands of pages of statute, regulation and guidance in a dozen languages. That's the problem RAG is built for.
2. Why RAG, and not something else
A large language model on its own is the wrong tool for this. Its knowledge is frozen at its training cutoff, it has read EPR law only incidentally, and when it's unsure it produces plausible text rather than silence. In a compliance setting, a confidently wrong tonnage threshold is worse than no answer. And even a correct answer is of limited use if you can't show where it came from.
Retrieval-Augmented Generation (RAG, named in a 2020 paper by Lewis et al.) splits the job in two. A retrieval system finds the handful of passages relevant to the question from a corpus you control, and the language model's job shrinks to reading those passages and composing an answer grounded in them, with citations. The model supplies language understanding; the corpus supplies the facts.
Compared with the alternatives:
| Approach | Why it falls short here |
|---|---|
| Just ask the model | Stale, patchy coverage of a niche domain, no citations, fluent hallucination of article numbers and thresholds |
| Fine-tuning | Bakes knowledge into weights: expensive to refresh every time a law is amended, and still can't point at its source |
| Stuff everything into the context window | The corpus is thousands of documents; even million-token contexts can't hold it, and per-query cost and latency would be absurd |
| RAG | Update the index when the law changes, answer from retrieved text, cite the exact provision. The fit is good; the engineering is the hard part |
3. The shape of the pipeline
Every RAG system is really two pipelines. An offline indexing pipeline turns raw documents into a searchable index, and an online answering pipeline turns a user's question into a grounded, cited answer. They meet in the middle at the index.
Each stage looks innocuous. Each one has a way of quietly ruining the whole system when the domain is law. The rest of this page walks the stages in order.
4. Building the corpus
The corpus is the system's entire universe: if a provision isn't in it, no amount of clever retrieval will find it. For EPR you'd be pulling from official sources such as EUR-Lex, national legislation gazettes, US state legislature sites, and regulator guidance (CalRecycle in California, the CPCB portal in India, PackUK in the UK). Three problems show up immediately.
Format chaos
EUR-Lex serves clean structured HTML. A US state statute might be a web page with its hierarchy encoded only in indentation. An Indian gazette notification might be a scanned PDF needing OCR. The parser has to normalise all of this into one representation that preserves the document's structure, because (as the next section shows) structure is what good chunking hangs on.
Amendments and consolidation
Legislation is rarely republished whole. Amendments are published as deltas: "in paragraph 2, substitute '30%' for '25%'". If you naively index both the original and the amendment, the index now contains two contradictory thresholds and no signal about which one is law. You either need consolidated versions (EUR-Lex publishes these; many jurisdictions don't) or you need to apply the amendments yourself, which is genuinely hard and a place where errors are costly.
Versions and authority
Old versions still matter ("what were my obligations in 2021?"), so each document should be stored with a validity window rather than overwritten. And not everything in the corpus carries equal weight: a statute, an implementing regulation and a PRO's FAQ page are three different levels of authority. Tag each document with its type, so the answering stage can prefer, and clearly attribute, the binding text.
5. Parsing and chunking
Embedding models and rerankers work on passages of bounded size, so documents must be split into chunks: the units that get embedded, retrieved and shown to the model. The default approach, cutting every n characters with some overlap, is exactly wrong for statutes. Legal text is a hierarchy (regulation → chapter → article → paragraph → point) in which a paragraph's meaning routinely depends on its neighbours: paragraph 1 states the rule, paragraph 2 the exemption. Separate them and a retrieved chunk can be true-but-misleading.
Try it on a (fictionalised) EPR provision:
The structure-aware version does two things. It splits along the document's own joints (articles and paragraphs, merging tiny ones, splitting giant ones), and it prepends a breadcrumb so the chunk is self-describing: the embedding of "Regulation 20XX/NN › Article 12(2) › exemption for small producers" carries far more signal than the bare sentence. A common refinement is small-to-big retrieval: search over small chunks for precision, but hand the model the whole parent article for context.
6. Metadata is half the battle
In a single-document RAG system, metadata is a nicety. In a multi-jurisdiction legal corpus, it is the retrieval system. Similarity search alone cannot tell Oregon from Maine: provisions from different jurisdictions say nearly identical things ("producers shall register with the scheme administrator...") and land next to each other in embedding space. The question "what's the registration deadline in Oregon?" will happily retrieve Maine's deadline unless something filters by jurisdiction before similarity is consulted.
Every chunk should carry at least:
| Field | Example | Why it matters |
|---|---|---|
jurisdiction | US-CO, EU, IN | Hard filter; the single most important field |
instrument_type | statute / regulation / guidance | Authority level; prefer binding text, attribute guidance as guidance |
product_stream | packaging / WEEE / batteries / textiles | Stops battery rules answering packaging questions |
dates | adopted / in force / applies from | These are three different dates, and conflating them produces wrong answers |
version_validity | 2022-07-01 → 2024-03-31 | Lets "what applied in 2023?" retrieve the right historical text |
citation | Reg 2025/40, Art 45(2) | What the final answer cites; must survive the pipeline intact |
The dates row deserves a highlight, because EPR law is full of staged timelines. The EU's PPWR was published in January 2025, entered into force on 11 February 2025, applies from 12 August 2026, and its EPR fee provisions bite later still, with labelling and recyclability rules staged out to 2028 and 2030. A system that knows only "the document is from 2025" will confidently tell a user that obligations apply today which don't apply until 2030. Temporal metadata isn't an optimisation here; it's correctness.
7. Embeddings and hybrid search
With chunks and metadata in hand, indexing is next. An embedding model maps each chunk to a vector such that texts with similar meaning land close together. At query time the question is embedded the same way and the nearest chunks are fetched. This is what lets "who pays for recycling cardboard boxes?" find a provision that never uses the words "pay", "cardboard" or "box", but talks about "financial responsibility for fibre-based packaging waste".
But semantic search has a blind spot that legal text pokes constantly: exact identifiers. "SB 54", "Article 45", "Regulation 2025/40" are near-meaningless strings to an embedding model, yet to the user they are the whole question. Empirical work on legal retrieval finds that statute numbers and citation formats benefit dramatically from old-fashioned keyword recall. So production systems run hybrid search: a dense (vector) query and a sparse (BM25 keyword) query in parallel, with the two ranked lists fused, typically by reciprocal rank fusion, and a cross-encoder reranker reordering the merged candidates before the best few go to the model.
8. Query time: routing and retrieval
Now the online half. Before any search runs, the question itself needs understanding, and this stage is where multi-jurisdiction RAG differs most from the textbook version. Three jobs:
- Scoping. Detect the jurisdiction(s), product stream and time frame the user means, and turn them into metadata filters. "Colorado" is easy. "Do I owe fees in the US?" means seven states. No jurisdiction at all means the system should ask, not guess.
- Decomposition. A comparative question ("EU vs California recycled-content rules") should fan out into one retrieval per jurisdiction and be synthesised afterwards. A single mixed retrieval tends to return five chunks about whichever jurisdiction is better represented in the corpus.
- Abstention. If the question is about Brazil and the corpus doesn't cover Brazil, the right output is "not covered", said plainly. Without an explicit coverage check, the retriever will return the closest chunks it has (probably the EU's) and the model will weave them into a confident, wrong answer.
Walk a few questions through the whole pipeline:
9. Grounded generation
The final model call receives the question plus the reranked chunks, each tagged with its citation, and a set of instructions that do a lot of load-bearing work. A sketch:
You are a research assistant for EPR compliance teams. Answer ONLY from the numbered extracts below. - Cite every claim with its extract number, e.g. [2]. - Quote thresholds, percentages and dates exactly as written. - Distinguish binding law from guidance when both appear. - State the as-of date of the underlying texts. - If the extracts do not answer the question, say so. Do not fill gaps from general knowledge. - You provide research support, not legal advice.
Three of those lines matter more than they look. Answer only from the extracts is the line that separates RAG from decoration: without it the model blends retrieved text with its training-data memory of EPR law, and you can no longer tell which is which. Quote exactly matters because paraphrased law drifts ("around 10 tonnes" is not "less than 10 tonnes"). And say so when you can't answer is the abstention behaviour from the previous section, enforced again at the last line of defence.
10. Evaluation and freshness
A RAG system has two parts that can fail independently, so it needs two kinds of measurement. Build a golden set of a few hundred real questions with expert-verified answers and the provisions that support them, spread across jurisdictions, product streams and time frames. Then track:
- Retrieval quality: for each golden question, do the top-k chunks include the supporting provision (recall@k)? This catches chunking and indexing regressions cheaply, with no model in the loop.
- Answer quality: is the generated answer faithful to the retrieved text, complete, and correctly cited? LLM-as-judge scoring works for breadth; periodic expert review keeps the judge honest.
Run the golden set on every index rebuild and prompt change, like a test suite, because a "harmless" chunking tweak can silently halve recall for one jurisdiction. And mine production logs: unanswered questions cluster around corpus gaps, which tells you what to ingest next.
Freshness is the other half of operations. EPR law moves on a monthly cadence: new state rulemakings, amended fee schedules, fresh guidance. The indexing pipeline from section 3 should re-crawl sources on a schedule, diff against what's indexed, and re-process only what changed, updating validity windows rather than deleting history. A stale RAG system fails in the worst possible way: confidently, with citations to law that has since been amended.
11. Failure modes, collected
| Failure | Looks like | Mitigation |
|---|---|---|
| Jurisdiction bleed | Maine's deadline cited in an answer about Oregon | Metadata filters before similarity search; per-jurisdiction fan-out |
| Split provision | Rule retrieved without its exemption; technically true, practically wrong | Structure-aware chunking; small-to-big retrieval |
| Identifier miss | "What does SB 54 say?" retrieves nothing useful | Hybrid (dense + keyword) search; citation-aware indexing |
| Temporal confusion | 2030 recyclability rules presented as applying today | Adopted / in-force / applies-from dates as first-class metadata |
| Stale corpus | Pre-amendment threshold quoted, with a citation, after the amendment | Scheduled re-crawl and diff; validity windows; consolidated sources |
| Hallucinated citation | An article number that doesn't exist, formatted perfectly | Answer-only-from-context prompting; mechanical citation verification |
| Confident out-of-scope answer | A question about Brazil answered from EU chunks | Coverage check and explicit abstention |
None of these is exotic. Every one is the default behaviour of a naive pipeline applied to this domain, which is the real lesson of the exercise: the RAG architecture is generic, but almost every design decision inside it (what to chunk on, what metadata to extract, how to route a query, when to refuse) is a domain decision. EPR, with its one simple idea refracted through dozens of legal systems, just makes that unusually visible.
12. Sources and further reading
- Lewis et al., "Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks" (2020), the paper that named RAG.
- "Navigating Global AI Regulation: A Multi-Jurisdictional Retrieval-Augmented Generation System" (2026), a research system tackling the same multi-jurisdiction problems in a neighbouring domain.
- "Towards Reliable Retrieval in RAG Systems for Large Legal Datasets" (2025), on document-level retrieval mismatch in legal corpora.
- "Enhancing Legal LLMs through Metadata-Enriched RAG Pipelines" (2026), on metadata as a retrieval backbone.
- OECD, Extended Producer Responsibility, the canonical policy overview.
- EUR-Lex summary of the Packaging and Packaging Waste Regulation (PPWR, Regulation 2025/40).
- O'Melveny, "2026 Plastics EPR & Packaging Rules Update", on the US state landscape.
- Anthesis, "Global Extended Producer Responsibility: Rules Worldwide", a country-by-country survey.