Blog
hedwigaihedwigaihedwigai

How to build a reinforcement-learning environment from court decisions

A reinforcement-learning (RL) environment is a set of tasks with a reward a program can compute, so a model can be trained by trying the tasks and being scored. We built one from 20 public decisions of India's customs appeal tribunal, CESTAT (the Customs, Excise and Service Tax Appellate Tribunal), made between July and November 2026. Each task gives a model the appeal as both sides argued it and asks it to decide the appeal, as typed fields. Code grades the fields against the order the tribunal passed.

  • We used three open models from three labs: Qwen3-235B, Alibaba's; GLM-5.3-Flash, Z.ai's; and DeepSeek-V4.1-Flash, from the lab DeepSeek. Each answered every task five times. They got between 63.1% and 79.6% of the fields right. Counting only the rulings a case actually raises, they got between 50.5% and 63.3%.
  • The field they missed most was the outcome itself: whether the appeal was allowed, partly allowed, dismissed or sent back (46.8% right).
  • The models fail differently. Where the department's order and the tribunal's differ, 59% of DeepSeek's misses sided with the customs department, and only 23% of Qwen3-235B's.

1. We cut each record at the decision

A tribunal order runs in a fixed order: the facts, the order under appeal, what the appellant argued, what the department's representative argued, and then the bench's own analysis ("We have heard both sides…") and its decision. We cut each order just before the analysis. What comes before is the task; the decision is the key, which the model never sees.

It is the cut SWE-bench makes on a code repository, rewinding it to before a fix, and the one Hatchery makes on lawyers' case stories in Scaling experts to build hundreds of knowledge work environments. We also took out the case number, the bench, the date of decision and any headnote. A check rejects a task if a quote from the decision appears in its input, or if the input shares an eight-word run containing an outcome word with the decision.

The orders come from Indian Kanoon, which indexes the tribunal's own published orders. Test sets leak into training data (Golchin and Surdeanu), which is why LiveCodeBench dates every problem. We took only orders from July 2026 on, the most recent we could find. That lowers the chance a model read them; it does not rule it out.

2. We write the decision as typed fields

A judgment is prose, but its operative part is a short list of rulings, each under a section of the Customs Act, 1962. We wrote it as 11 typed fields: the disposition (allowed, partly allowed, dismissed or remanded), whether the duty demand and the extended period stand, whether confiscation stands, the redemption fine and each penalty (upheld, reduced or set aside), the tariff item held, and whether an exemption or refund is allowed. A field the case does not raise is null.

Prediction from Indian judgments has been done before as a yes or no (ILDC), and legal reasoning has been tested as many small tasks (LegalBench). Typed fields sit between: each ruling is scored on its own, and none can be argued into being right.

3. We grade each field with code, not a model

The reward is the share of fields that match the order, worked out by a short Python function. No model judges. Judges prefer long answers, the first answer they see and their own (Zheng et al.), and making one fit for legal work is a project in itself (Hatchery). Rubrics (Rubrics as Rewards, checklists) suit work with no single answer. An appeal has one, the order, which makes it a case for the verifiable rewards of Tulu 3 and DeepSeek-R1.

One trap: most cases raise only a few of the 11 questions, so 46.1% of the graded fields have the key "not in issue". Those are easy, and a share taken over all fields rewards a model for staying out of questions nobody asked. We report the share over all fields and the share where the key has a value; for training, the reward should weight the second.

4. Three model families answer every task

The three models each answered every task 5 times: 300 runs. The margin, a 95% interval, comes from resampling the 20 tasks: the five runs and the fields of one task are not independent, so the task is the unit.

ModelFields rightMargin, 95%Right where the key has a valueMalformedMisses on the rigid answer
GLM-5.3-Flash79.6%69.8–88.063.3%1 of 10035 of 62
DeepSeek-V4.1-Flash70.8%60.9–80.050.7%0 of 10064 of 109
Qwen3-235B63.1%51.5–73.750.5%0 of 10020 of 88

Compared task by task, GLM-5.3-Flash is ahead of DeepSeek-V4.1-Flash by 9 points (margin 3 to 15) and of Qwen by 16 points (margin 9 to 23). DeepSeek's lead over Qwen, 8 points, is within what 20 tasks can resolve.

Where the key has a value, the order changes. DeepSeek (50.7%) and Qwen (50.5%) are level, and GLM (63.3%) leads. On "not in issue" fields DeepSeek is right 94.3% of the time and Qwen 78.0%: Qwen rules on questions the case does not raise, and that, not the rulings themselves, is most of the gap between them.

The one malformed answer is GLM spending its whole 32,000-token budget thinking and writing nothing. It is counted apart from wrong answers, because it is a different failure. By field, the hardest are disposition (46.8%), penalty_112_114 (57.9%), duty_demand (64.4%); the easiest is tariff_item_held (87.9%).

FieldRight, all runsWhat it asks
disposition46.8%allowed = the appellant succeeds on every point it challenges; partly_allowed = it succeeds on some and fails on others; dismissed = the impugned order is upheld on every challenged point; remanded = sent back for fresh decision
penalty_112_11457.9%penalty under section 112 (imports) or 114 (exports); null if none
duty_demand64.4%the differential duty demand confirmed by the impugned order; null if none
redemption_fine68.2%redemption fine under section 125; null if none was imposed
penalty_114A71.0%penalty under section 114A; null if none
confiscation_upheld72.8%do the goods remain liable to confiscation under section 111 (or 113 for exports); null if no confiscation was ordered
penalty_114AA72.8%penalty under section 114AA; null if none
extended_period_upheld78.1%is the extended period of limitation under section 28(4) validly invoked; null if the impugned order did not invoke it
refund_allowed82.9%is the refund the appellant claimed allowed; null if no refund is in issue
exemption_allowed83.5%does the appellant get the exemption or concessional-rate notification it claimed; null if no exemption claim is in issue
tariff_item_held87.9%8-digit Customs Tariff item, digits only (e.g. "39269099"), under which the goods are classified after your decision; null if classification is not in dispute

12 of the 20 tasks average under 80%, so there is room to train. Pick one to see its key, the rigid answer, and what the models said:

Amara Raja

Decided 2026-11-26 · extended limitation s.28(4) after accepted reclassification; confiscation, RF, s.114A · input 12k characters · the order

Mean score: Qwen3-235B 0.69 · GLM-5.3-Flash 0.78 · DeepSeek-V4.1-Flash 0.76

FieldKeyRigid answerRuns rightMost common wrong answer
dispositionalloweddismissed4 of 15partly allowed
duty_demandreducedupheld2 of 15set aside
extended_period_upheldnoyes14 of 15yes
confiscation_upheldnoyes14 of 15yes
redemption_fineset asideupheld14 of 15upheld
penalty_112_114not in issue—15 of 15—
penalty_114Aset asideupheld14 of 15upheld
penalty_114AAnot in issue—15 of 15—
tariff_item_heldnot in issue—5 of 1556013000
exemption_allowednot in issue—15 of 15—
refund_allowednot in issue—11 of 15no

The rigid answer is shown in amber where it differs from the key. Hover a field for the words of the decision its key was read from.

5. We audit the results and the key

Four checks, after RubricCraft and JusticeAxis.

Malformed apart from wrong. Reported above, per model.

Cells that never separate models. 79 task-and-field cells were right in every run. Items like these distort leaderboards (Rodriguez et al.); we keep them, since they still catch careless answers, and list them in the report.

The key, wherever every family disagrees with it. Keys are wrong more often than expected: at least 3.3% of test labels across ten benchmarks (Northcutt et al.), 6.5% of MMLU questions (Gema et al.). We re-read the order for all 12 cells where all three models disagreed with the key. One was ours to fix: in Alpha Impex the dispute was misdeclaration and the tribunal never ruled on a tariff item, so that field is no longer graded. The rest held. In Kuber Garnet the tribunal upheld the order of the first appeal, and the models answered against the original order that appeal had already changed.

Which way the misses lean. JusticeAxis scores a legal answer against two wrong references, one that applies the rule rigidly and one that argues from grounds the record does not support. Our rigid reference is the department's order upheld in full. A miss that lands on it means the model sided with the department by default: DeepSeek 64 of 109, GLM 35 of 62, Qwen 20 of 88. Task by task, Qwen's share is lower than DeepSeek's by 36 points (margin 2 to 71); the margin is wide because a few tasks hold most of the misses. GLM and DeepSeek cannot be told apart on it. Fields right and where the misses land are two measures, and they do not rank the models the same way.

6. We export the tasks for training

Each task is written as a Harbor directory: the instruction, task.toml, a Dockerfile, the grader in tests/ and the key in solution/. The grader writes the reward to /logs/verifier/reward.txt. The same tasks load as a verifiers environment for training.

What we do next

Training comes next: sample many answers per task, keep the best graded, fine-tune an open model on them, then run RL with the code grader as the reward, and report it on orders held out by date. The method needs only dated decisions with typed outcomes: tribunal and court orders, and the notices, replies and orders a firm already holds.

What this test cannot show

  • 20 tasks, so each model's margin is about ±10 points.
  • Customs appeals only.
  • We read the keys from the operative part; a lawyer did not.
  • In two cases the tribunal upheld "the order as a whole" without discussing a field. We kept those keys and flag them.

Sources

  1. Scaling experts to build hundreds of knowledge work environments. Henry Mao and Arjun Kumar, Hatchery, 2026.
  2. Calibrating a judge for legal work. Henry Mao, Hatchery, 2026.
  3. SWE-bench: Can Language Models Resolve Real-World GitHub Issues?. Jimenez et al., ICLR 2024.
  4. LiveCodeBench: Holistic and Contamination Free Evaluation of Large Language Models for Code. Jain et al., 2024.
  5. Time Travel in LLMs: Tracing Data Contamination in Large Language Models. Golchin and Surdeanu, ICLR 2024.
  6. The Customs Act, 1962. Government of India, India Code.
  7. Customs, Excise and Service Tax Appellate Tribunal. Ministry of Finance, Government of India.
  8. Indian Kanoon: CESTAT decisions. Indian Kanoon (a private search engine, not an official reporter).
  9. ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation. Malik et al., ACL 2021.
  10. LegalBench: A Collaboratively Built Benchmark for Measuring Legal Reasoning in Large Language Models. Guha et al., NeurIPS 2023.
  11. Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena. Zheng et al., NeurIPS 2023.
  12. Rubrics as Rewards: Reinforcement Learning Beyond Verifiable Domains. Gunjal et al., Scale AI, 2025.
  13. Checklists Are Better Than Reward Models For Aligning Language Models. Viswanathan et al., NeurIPS 2025.
  14. Tulu 3: Pushing Frontiers in Open Language Model Post-Training. Lambert et al., Allen Institute for AI, 2024.
  15. DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning. DeepSeek-AI, 2025.
  16. RubricCraft: Where Solutions Diverge, Criteria Emerge. Hasanbeig et al., Microsoft, 2026.
  17. JusticeAxis: Benchmarking Legal Judgment between Rigid Rule Application and Ungrounded Discretion. Tu et al., 2026.
  18. Evaluation Examples are not Equally Informative: How should that change NLP Leaderboards?. Rodriguez et al., ACL 2021.
  19. Pervasive Label Errors in Test Sets Destabilize Machine Learning Benchmarks. Northcutt, Athalye and Mueller, NeurIPS 2021.
  20. Are We Done with MMLU?. Gema et al., NAACL 2025.
  21. Harbor. Laude Institute, 2025.
  22. verifiers. Prime Intellect.