MEMON SYSTEMS

Chapter & Verse: UK Legislation Answers Checked Sentence by Sentence on One 24 GB ARM VM, and Five Changes That Failed

A legal answer is useful only when each sentence can be traced to the provision that supports it. Most retrieval systems leave the citation to the language model. The model can then write a section that does not exist, or attach a real section to the wrong Act, and the reader has to check every line by hand.

Chapter & Verse is an open-source engine (AGPL-3.0) for questions about UK legislation, built to remove that check. The model never writes a citation. The system binds each question to a provision before retrieval and tests every generated sentence against the retrieved statute text before it reaches the browser. It then renders each citation itself from the bound coordinates. A question outside the held statutes gets a structured refusal.

The whole engine runs on one Oracle Cloud ARM64 A1 VM with 4 OCPUs and 24 GB of RAM.

Figures are Measured unless a section is labelled By design. All runs use the legislation snapshot of 28 September 2026.

Summary

  • Measured, 20 November 2026, sealed battery of 155 planted errors and 191 correct sentences: the sentence judge caught 154 errors and wrongly rolled back 14 correct sentences.
  • Measured, 29 September 2026, 2,112 labelled UK queries: the citation router bound 0 of 1,897 real citations to the wrong instrument, and 0 of 68 invented Acts. Median routing time was 0.14 ms on an Apple M4.
  • Measured, 25 November 2026, 91 sealed hand-written questions with no citation: the right instrument was in the top 10 for 93.4% and first for 62.6%. All 12 questions about fictional law were refused.
  • Measured, 21 November 2026: 29 of 29 security and prompt-injection probes passed against the live stack, and none produced a generated sentence.
  • Five changes failed gates written before they ran, and stayed off. Each is listed below with its numbers.

How an answer is built

By design. Each question passes through five steps.

  1. Route. legal-rag-router reads any citation in the question and returns one decision. The decision is a provision to retrieve from, a question back to the user, or a refusal. No model is involved.
  2. Retrieve. A question with a citation retrieves from the bound provision. A question without one goes to discovery, which fuses BM25F keyword search with dense vectors and shows the top 10 instruments as choices. Nothing binds until the user picks one.
  3. Generate. The model writes the answer from the retrieved text.
  4. Judge. A second model checks each sentence against every retrieved window. A sentence the text does not support is rolled back and rewritten before it streams to the browser.
  5. Cite. The system renders citations from the bound coordinates. Each answer carries a JSON receipt (AnswerFactObject). The browser recomputes its SHA-256 answer_id with Web Crypto. A second hash, evidence_id, covers only the deterministic routing and retrieval fields, so the same question gives the same evidence_id on every run.

Three dated limits in the Employment Rights Act 1996, under sections 124, 186 and 227, skip the model entirely. The answer comes from a table of 48 rows taken from 16 Employment Rights (Increase of Limits) Orders, SI 2010/2926 to SI 2026/310, each row verified by SHA-256. Asked for the section 124 cap as at 1 January 2012, the engine returns £68,400 under SI 2010/2926. Measured, November 2026: the lookup takes 174 µs and makes 0 model calls.

What it holds

The snapshot of 28 September 2026 sits in about 5.8 GB of RAM.

  • 134,219 UK instruments. 69,935 have full text and 64,284 have title and metadata only.
  • 5,564,149 provisions in a zstd-packed text store, with a SymSpell spelling dictionary.
  • 1,322,050 int8 concept vectors from bge-small-en-v1.5, in a 545 MB index. A 48-byte binary code per vector drives a Hamming pass that keeps 1,000 candidates, and exact int8 scores rank those.
  • The 48 dated limit rows above.

Results

A sealed split is a test set hashed and set aside before development, then scored once. Each gate below was committed to the repository before its run.

Results: Component, Date, Result, Speed and more (Data Table)
Component Date Result Speed Report
Citation router 29 Sep 2026, re-run through the engine 19 Nov 2026 0 of 1,897 real citations bound to the wrong instrument. 0 of 68 invented Acts bound. 2,112 queries. Median 0.14 ms, Apple M4 slice1-gates.md
Discovery without a citation 25 Nov 2026 91 sealed hand rows. Right instrument in top 10 for 93.4%, first for 62.6%, MRR 0.719. 0 candidates that do not exist. 12 of 12 fictional-law questions refused. Dense stage p50 65.7 ms, p95 70.4 ms on the A1 with 4 threads, 23 Nov 2026 sprint5-clarify-sealed.md, slice3-gates.md
Sentence judge 20 Nov 2026 154 of 155 planted errors caught (99.4%). 14 of 191 correct sentences rolled back (7.3%). 8 of 179 grounded paraphrases rolled back (4.5%). Precision 91.7%. Per call p50 1.0 s, p95 1.9 s heldout-qwen-modal.md
Legal question battery 25 Nov 2026 Sealed 40-row test split, run once. 38 of 40 passed. Recall of required provisions 0.947. Dev split 38 of 40, 0.956. sprint5-gates.md
Security and prompt-injection probes 21 Nov 2026 29 of 29 passed, local and live. 0 generated sentences. probes-resilience.md

The judge is Qwen 27B at 4 bits (Vishva007/Qwen3.8-27B-W4A16-AutoRound-GPTQ, run name qwen27-ar4), served on one Modal L40S for this run. Production sends judge calls to Groq first. On a separate check of 151 graded sentences in November 2026, Groq scored 137 correct and Modal 138 (judge-gate-2026-11.md).

What failed

Five changes were expected to help. Each was measured against a gate set before the run, and each stayed off.

1. DeBERTa NLI caught 80% of planted errors

The first judge design paired deterministic claim checks with an entailment model. It was tested on the sealed battery heldout-2026-10-06 between 6 and 8 October 2026.

Claim checks alone caught 83 of 155 errors (53.6%). Adding DeBERTa-v3-base NLI with enrichment raised that to 124 of 155 (80.0%), and rolled back 15 of 191 correct sentences. On 20 November 2026, the Qwen 27B judge caught 154 of 155 on the same battery and rolled back 14 of 191. It replaced DeBERTa (heldout-qwen-modal.md). The earlier study is in What Failed in My Own Controls.

2. ColBERT reranking lowered accuracy and added over a second

The test was whether answerai-colbert-small-v1, reranking the top 24 subsection windows, would improve discovery. It ran on the 112-row dev split in November 2026.

With reranking, hit@10 was 0.866 and MRR 0.635. Without it, the BM25F and dense fusion scored 0.929 and 0.750, and BM25F alone 0.902 and 0.739. The reranker also added 1.35 s at p50 and 2.06 s at p95 on a Mac CPU. It was not run on the test split (slice3-gates.md).

3. A narrower judge context rolled back more correct sentences

Sending every retrieved window to the judge costs a median 1,545 prompt tokens. On 25 November 2026, two cheaper inputs were tested on the sealed battery. One sent only the cited windows, at a median 358 tokens. The other sent only the cited sections, at 420.

Both caught 155 of 155 errors. Both also rolled back more correct sentences. Cited windows rolled back 24 of 191 correct sentences and 18 of 179 grounded paraphrases. Cited sections rolled back 18 of 191 and 12 of 179. The gate allowed at most 14 of 191, so both failed. A valid paraphrase often relies on an adjacent window or a cross-reference. Without that text, the judge marks the sentence as not stated (heldout-qwen-modal-cited.md, heldout-qwen-modal-section.md).

4. The judge gave different labels to identical prompts

The section-scope run on 25 November 2026 repeated 261 prompts byte for byte from the run of 20 November. Both used temperature 0.7 and seed 0. 8 of the 261 got a different label, and 4 of those changed the verdict.

The baseline of 14 of 191 is therefore one draw, and a rerun moves it by a few rows. Any future judge change needs a control run of the current judge on the same day (heldout-qwen-modal-section.md).

5. Sending judge calls to Cloudflare first slowed answers

Groq allows 8,000 tokens a minute on the free tier, shared between generation and judging. The idea was to send judge calls to Cloudflare first and keep Groq for generation. It was tested in November 2026 on 23 dev questions, one every 20 seconds, with only Groq and Cloudflare enabled.

Median answer time rose from 5.3 s to 9.4 s, and incomplete answers rose from 2 to 3. Rows passed were 20 of 23, against 17 for the main code. The slower answers and extra incomplete answers decided it, and production keeps Groq first for both purposes (sprint5-gates.md).

Limits of this evidence

  • The corpus is current UK legislation as at 28 September 2026, plus the 16 Orders for Employment Rights Act 1996 sections 124, 186 and 227. Any other "as at" question returns HISTORY_NOT_HELD with a dated link to legislation.gov.uk.
  • The 64,284 title-only instruments return TEXT_NOT_HELD with a link to the official text.
  • There is no case law, tribunal decisions, regulatory guidance or document upload.
  • Each question is routed and verified on its own. There is no multi-turn conversation.
  • The 155 judge errors are planted. Error rates on unprompted model output are not reported here.
  • The public demo runs on free-tier generation quotas behind Cloudflare Turnstile and per-IP rate limits.

Reproduce

The README holds the results table with links. The reports/ folder holds each gate as written before its run, the result files and the raw judge requests. The router is described in detail in legal-rag-router: Deterministic Citation Routing for UK Legal RAG.

More Articles You Might Like

Nov 17

Layer-Hot Decoding: A Second Token per Weight Pass Ran at 0.87x of Plain Decoding on an M4

A proof of concept that runs a guessed second token through each layer while its weights are loaded. Measured 14 to 16 November 2026 on a MacBook Air M4 with Qwen3 0.6B, 1.7B and 4B at 4 bits: a second token cost 2 to 11% extra on MLX, but a guess from the first layers was right 27 to 40% of the time, and the loop ran at 0.87x of plain mlx-lm on 4B. Tuned llama.cpp DFlash2 reached 1.22x on the same machine.

llm-inferencespeculative-decoding+4 more
Read Article
Oct 20

Can You Build Confidential Legal AI Without a TEE? Empirical Lessons on PIR and Keyed Models

Two studies on fictional UK employment matters, October 2026, with the cloud provider treated as an attacker with full access. A model hidden behind a secret key was read in full: 100% of the secret content recovered from public statistics of its weights. Keeping client work on a laptop and fetching public law by private information retrieval sent 0 of 17 client secrets to the cloud, where a standard cloud pipeline sent 16 private tokens. With dates and amounts computed in code, 30 of 30 conclusions on 8 unseen matters were correct. Work that needs cloud compute on client data needs a hardware trusted execution environment, such as Prem Enclave.

legal-techconfidential-computing+6 more
Read Article

New entries are published to the feed.

RSS: /feed.xml