XLL Regulations Qwen3.5-9B
Task-specialized full-language fine-tune for converting federal regulation sections into source-aligned XLL structural JSON. It is not a general-purpose competitor to frontier models, not the statutes adapter, and not standalone USLM XML. Intended value is faithful conversion with smaller deployment requirements; best cost-effectiveness and serving throughput have not been measured.
Availability: the retained BF16 full-fine-tune weights are in this repository, together with the trained prompt, a training example, and the evaluation evidence.
Base model and loading contract
Base: Qwen/Qwen3.5-9B, revision
c202236235762e1c871ad0ccb60c8ee5ba337b9a. This candidate is a full-language model,
not a LoRA adapter. Its protocol is raw-text-cfr-source-native-structure-0.2,
prompt variant cfr-native-lexical-sparse-v2-regulations.
Use the exact trained system prompt and message encoding
illustrated in example.json, a training example, not heldout
evidence. User input consists of sparse start:end|JSON-string lexical fragments;
unlisted characters are ASCII spaces. Offsets are zero-based, end-exclusive
Unicode character positions. Output is {"tree":[tag,start,end,attributes,children]}.
Do not replace the trained interface with an arbitrary plain-text prompt.
Deterministic assembly, validation and human review remain required.
How to run inference: required indexed input
This model does not accept plain regulation text. At training and evaluation time the user message was a lossless sparse lexical index of the source section. Passing raw text, or applying output offsets to the indexed message, is outside the trained contract and should not be expected to reproduce the reported accuracy. The output is a tree whose spans index the original raw text.
System prompt
Use this frozen prompt byte-for-byte (also distributed as PROMPT_TRAINED.txt):
Convert raw federal regulation text to a source-native USLM tree. Return only {"tree":[tag,start,end,attributes,children]}. Every child has the same five-field shape. Root is the complete section. Spans are zero-based Unicode character offsets, end exclusive, not tokens. Children are ordered, nonoverlapping and contained within parents. All text is copied from spans, not regenerated. Preserve num, heading, chapeau, content, continuation, notes, references, inline markup, tables and hierarchical provision types. Attributes are a JSON object of string keys and string values; children is an array, possibly empty. Use namespace aliases {"g": "http://schemas.gpo.gov/xml/uslm", "h": "http://www.w3.org/1999/xhtml", "u": "http://xml.house.gov/schemas/uslm/1.0", "xml": "http://www.w3.org/XML/1998/namespace"}. Input fragments are start:end|JSON-string. Unlisted character positions are ASCII spaces; all other whitespace is explicitly listed. Fill the unlisted positions with spaces to recover the exact text of the stated length. Fragment boundaries do not indicate XML boundaries. Return JSON only, with no explanations. Predict only text-grounded attributes value, date, type, role, topic, status, and table attributes colspan, rowspan, scope, span when evidenced by the input. Omit external identifiers, link destinations and presentation attributes. Keep CFR paragraph nesting and source/authority/editorial elements distinct.
Do not add a role wrapper, a schema description, or Markdown fences.
User message
The user content is a header line followed by one fragment per line:
Document type: regulations. Text length: <N> Unicode characters.
<start>:<end>|<JSON string>
...
start is inclusive and end exclusive; both are zero-based Unicode character
offsets into the original raw text. The fragments cover every non-ASCII-space
character. Any position not listed is an ASCII space (U+0020). Non-ASCII
whitespace, including no-break space (U+00A0) and narrow no-break space
(U+202F), is listed explicitly. The | separator is followed by a JSON string
with ensure_ascii=True; decode it with a JSON parser, do not strip quotes.
import json
import re
FRAGMENT = re.compile(r'\s+|\w+|[^\w\s]')
def encode(raw, document_type='regulations'):
assert document_type == 'regulations'
fragments = [
f'{m.start()}:{m.end()}|{json.dumps(m.group(), ensure_ascii=True)}'
for m in FRAGMENT.finditer(raw)
if m.group().strip(' ') # omit ASCII-space-only runs only
]
header = (f'Document type: {document_type}. '
f'Text length: {len(raw)} Unicode characters.')
return header + '\n' + '\n'.join(fragments)
Encode the exact text you want the spans to refer to. Do not normalize,
collapse, strip, or re-wrap it first. raw is a Python str; len(raw) counts
Unicode code points.
Example for the fictional text § 1. Example rule.:
Document type: regulations. Text length: 18 Unicode characters.
0:1|"\u00a7"
2:3|"1"
3:4|"."
5:12|"Example"
13:17|"rule"
17:18|"."
Chat template and decoding
system_prompt = ... # the exact text above
messages = [
{'role': 'system', 'content': system_prompt},
{'role': 'user', 'content': encode(raw, 'regulations')},
]
input_ids = tokenizer.apply_chat_template(
messages, tokenize=True, add_generation_prompt=True,
enable_thinking=False,
)
Load the full fine-tune with Qwen/Qwen3.5-9B at revision
c202236235762e1c871ad0ccb60c8ee5ba337b9a. Use BF16, greedy decoding
(do_sample=False), and no grammar or output repair. The evaluated runtime used
a 32,768-token context, at most 8,192 new tokens, and JSON-object stopping.
Reject inputs that do not fit; do not truncate them.
Reading the output
Parse exactly one JSON object of the form
{"tree":[tag,start,end,attributes,children]}. Spans are zero-based,
end-exclusive Unicode offsets into the original raw text, not into the
encoded user message. The root span must be [0, len(raw)]; children are
ordered, non-overlapping, and contained in their parent. Validate the tree and
retain human review. A syntactically valid JSON object is not necessarily a
valid or correct tree.
Training
- 5,000 sections: 2,792 GPO-derived gold and 2,208 deterministic eCFR silver.
- Two epochs, 2,500 optimizer updates, effective batch four; seed 102301.
- Learning rate 5e-6; Adafactor; 125-step warmup, cosine decay to 0.1 of peak.
- Full language parameters trained; vision frozen. FP32 training parameters, BF16 compute; retained checkpoint is BF16 safetensors.
- 32,768-token training context, without truncation; longest example 26,455 tokens.
| Target XML nodes | Gold | Silver | Total |
|---|---|---|---|
| 1–10 | 845 | 661 | 1,506 |
| 11–25 | 919 | 693 | 1,612 |
| 26–50 | 612 | 373 | 985 |
| 51+ | 416 | 481 | 897 |
Training includes 15 gold and 82 silver table-bearing sections. Silver is a deterministic conversion, not human-reviewed gold. Source diversity does not establish correctness on all titles. Training report and inventory record the recipe and counts.
Reserved validation — distinct from development
On a score-blind selected, token-eligible 158-section reserved slice, the retained candidate achieved 148/158 (93.7%) whitespace-tolerant exact, 146/158 (92.4%) strict exact, and 158/158 native-valid. Train/development overlap was checked by IDs, groups and substantial passages; remaining limitations are documented with reserved evidence.
This slice has only titles 5, 12 and 27; no eligible tables; node-bin counts 35/50/49/24. It has fewer high-complexity examples than development200. Do not compare the overall percentages directly or infer table/general-title performance. It is now consumed validation, not untouched data for future recipe selection.
Complexity-balanced development evaluation
Frozen 200-section model-selection/development set, not an untouched test estimate. Success requires a native-valid tree, identical hierarchy/tags and supported attributes, and corresponding spans equal after stripping outer whitespace. Interior whitespace is preserved. This is target-aware reconstruction, not complete USLM XSD validation, and differs from the statutes card's schema-gated structural metric. Percentages across the two model series are not interchangeable.
| Metric | Count | Rate |
|---|---|---|
| Whitespace-tolerant joint exact | 127/200 | 63.5% |
| Strict joint exact | 115/200 | 57.5% |
| Native tree valid | 179/200 | 89.5% |
| Hierarchy and labels exact | 137/200 | 68.5% |
| Target XML nodes | Sections | Exact success | Native-valid |
|---|---|---|---|
| 1–10 | 35 | 33/35 (94.3%) | 35/35 |
| 11–25 | 50 | 40/50 (80.0%) | 50/50 |
| 26–50 | 49 | 28/49 (57.1%) | 45/49 |
| 51+ | 66 | 26/66 (39.4%) | 49/66 |

Complexity counts target XML nodes, including inline markup and XHTML; it is not legal difficulty. Lines connect ordinal-bin rates, not fitted trends. Of the 73 failed development sections, 61 are above 25 nodes and 40 are in the 51+ bin. Table-bearing sections: 13/30 exact (43.3%), 16/30 native-valid (53.3%). Without tables: 114/170 exact (67.1%), 163/170 native-valid (95.9%). Invalid trees and structural errors remain significant deployment risks.
Task comparison and frontier caveats
These are same-cohort original shared-prompt results, not a demonstrated best-prompt frontier comparison. Unlike the statutes series, no clarified-prompt regulation rerun is available here; it would require a separate experiment.
| Model | Sections | Whitespace-tolerant exact | Native-valid |
|---|---|---|---|
| Retained full fine-tune | 200 | 127/200 | 179/200 |
| Selected LoRA | 200 | 101/200 | 179/200 |
| GPT-6 Sol — original shared prompt | 200 | 0/200 | 183/200 |
GPT-6 Sol produced 183/200 native-valid trees and 14/200 matching hierarchies, but zero supported-attribute-exact outputs, hence zero joint-exact outputs. Zero exact success does not imply no useful structure or inferior general legal ability. It received the same frozen prompts via OpenRouter, reasoning disabled, provider- default sampling and an 8,192-token output cap. Prompt suitability, tokenization, stopping and runtime differences limit the comparison. This is not an optimized frontier benchmark or a general intelligence ranking. No output repairs are used.
Appendix: partial vanilla, matched IDs only
Vanilla completed only a nonrandom 126-section prefix on RTX 5090; it is not a complete/hardware-matched 200-section baseline. All models below are restricted to those same 126 IDs; do not mix these denominators with the full200 results.
| Model | Matched sections | Whitespace-tolerant exact | Native-valid |
|---|---|---|---|
| Retained full fine-tune | 126 | 80/126 | 121/126 |
| Selected LoRA | 126 | 61/126 | 117/126 |
| GPT-6 Sol — original shared prompt | 126 | 0/126 | 114/126 |
| Vanilla — partial RTX 5090 | 126 | 0/126 | 0/126 |

Runtime and reproducibility
Local evaluation uses BF16 without quantization, greedy batch-one generation, 32,768-token context, at most 8,192 new tokens, and JSON-object stopping. Retained and LoRA candidates were evaluated on NVIDIA GB10; partial vanilla on RTX 5090. Evaluation used Transformers 5.15.1 and PyTorch 2.13.0+cu130. Quantized variants and every consumer GPU/context combination are not qualified. BF16 weights are roughly 18 GiB before activation/cache overhead.
Development/complexity evidence includes counts,
title/table provenance, report and prediction hashes, and partial-baseline caveats.
Reserved validation and training report
are separate evidence. Weights status records the uploaded
shard hashes and the verified Hub revision. SHA256SUMS.json covers the
documentation artifacts published in this commit.
Selection, limitations, and license
The retained mixed5000, two-epoch seed-102301 candidate is not automatically replaced by later recipes. Development selection is not an unbiased test estimate. No complete training corpus or development predictions are packaged. Supported attributes are restricted; opaque metadata, full USLM schema compliance and legal accuracy are not claimed. Whole titles, oversized sections, OCR/PDF input, arbitrary state conventions and long-context/quantized deployment are not validated. Use official source text as authoritative; review all model-generated structure.
Apache-2.0; the base-model license is included as LICENSE.
Replication dataset
Training and evaluation data: thurstonpowers/xll-regulations-dataset. Use the model-specific contract and splits described in the dataset card.