Measured results
Table with columns: Evaluation, Untouched Qwen3-4B, v0.5 adapter| Evaluation | Untouched Qwen3-4B | v0.5 adapter |
|---|
| Synthetic holdout | 28/80 (35%) | 80/80 (100%) |
| Previously examined manual regression cases | 5/8 (62.5%) | 7/8 (87.5%) |
| Synthetic insufficient-information cases | 6/20 | 20/20 |
| Synthetic future-regime cases | 0/20 | 20/20 |
Adapter macro-F1: 1.0 synthetic, 0.9142857142857143 regression; no invalid contract outputs on 88 cases. Raw answers and manifests are preserved.
Known failure: FROZEN-004, investment advice without execution, returned REPORTABLE; expected NOT_REPORTABLE under the experiment's rules.
These are synthetic variations of the supervision rules and eight previously examined cases, not independent legal validation. Inputs contain structured facts including explicit instrument scope. Arbitrary natural-language questions and the old ask/API prompts are outside this measured contract. This is not production reporting software, legal advice, an authoritative regulatory database, or a reliable independent regulatory decision engine.
Historical failures remain relevant: v0.1 fresh verification was 1/6 full contract; v0.2 scored 37/50 synthetic and 3/8 manual; v0.3 scored 37/80 synthetic and 3/8 manual; v0.4 scored 30/80 synthetic. Prompts, datasets and metric definitions changed, so these are not controlled cross-version comparisons. Historical deterministic rules/hybrid 50/50 and 8/8 scores are not standalone adapter scores.
Training and artifact
- Base:
Qwen/Qwen3-4B, revision 1cfa9a7208912126459214e8b04321603b3df60c.
- Run
20260910-200943: NF4 QLoRA, double quantization, FP16 compute, gradient checkpointing.
- LoRA rank 8, alpha 16, dropout 0.05; targets
q_proj, k_proj, v_proj, o_proj.
- Learning rate 0.0001, batch 1, accumulation 16, warmup ratio 0.1, seed 45,
paged_adamw_8bit, max length 512.
- 200 contrastive families / 800 examples; whole-family splits 640/80/80. Each training class contains 160 distinct model inputs. Semantic duplicate and family overlap checks passed and dataset hashes match preflight.
- Only answer and stop tokens contribute to loss; input tokens are masked. The same non-thinking Qwen chat prefix is used at inference. Longest example: 157 tokens.
- Maximum four epochs; balanced 40-case validation gate every 25 steps; patience two, minimum macro-F1 improvement 0.01. Selected step 75, stopped at step 125 / epoch 3.125. Both selected validation safety classes passed the 80% threshold.
- Runtime 11973.0642 seconds (~3.33 hours). Final-run training loss 0.12272339483659016; step-125 validation loss 0.00017209183715749532. These are not the selected step-75 losses or regulatory accuracy.
- Adapter: 11,834,776 bytes; SHA-256
bed2dcdf49e6909f4581f42c4cdd06e87c0a30b597048efe370fe2ede476bb5f.
See configuration and manifest. Earlier runs' environment versions are not asserted as a separately captured v0.5 environment. Source handling and deterministic labels are described in the included source; no copyrighted regulatory documents are bundled.
Loading and the evaluated prompt
For the simplest local showcase after cloning the GitHub repository, use:
.\.venv\Scripts\python.exe -m mifidbrain.cli v05-demo --case reportable
This is the measured v0.5 structured prompt and pins the Hub adapter revision.
The legacy ask command uses an older unmeasured prompt.
Install compatible PyTorch, Transformers, PEFT and bitsandbytes. The 4-bit profile requires CUDA. On a sufficiently large device, unquantized PEFT loading uses the same code with quantization_config omitted and an appropriate dtype/device.
import jsonimport torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig base_id = "Qwen/Qwen3-4B"revision = "1cfa9a7208912126459214e8b04321603b3df60c"adapter_id = "thunderjordi/mifidbrain-qwen3-4b-lora-v0"tokenizer = AutoTokenizer.from_pretrained(base_id, revision=revision)base = AutoModelForCausalLM.from_pretrained( base_id, revision=revision, device_map={"": 0}, dtype=torch.float16, quantization_config=BitsAndBytesConfig( load_in_4bit=True, bnb_4bit_quant_type="nf4", bnb_4bit_use_double_quant=True, bnb_4bit_compute_dtype=torch.float16, ),)model = PeftModel.from_pretrained(base, adapter_id, revision="v0.5").eval()facts = { "as_of_date": "2026-08-31", "firm_type": "UK investment firm", "firm_jurisdiction": "UK", "activity": "purchase", "instrument_reportable": True, "transmitted_order": False, "transmission_conditions_met": None, "venue_country": "GB", "execution_decision_country": "GB", "asset_class": "equity",}prompt = ( "Classify supplied facts under the MiFIDBrain simplified research rules. " "Return only JSON with key determination and one of: " "REPORTABLE, NOT_REPORTABLE, INSUFFICIENT_INFORMATION, FUTURE_RULES_UNPUBLISHED" ". Unknown is distinct from false. Do not infer instrument scope from venue.\n" + json.dumps(facts, separators=(",", ":"), ensure_ascii=False))text = tokenizer.apply_chat_template( [{"role": "user", "content": prompt}], tokenize=False, add_generation_prompt=True, enable_thinking=False,)inputs = tokenizer(text, return_tensors="pt").to(model.device)with torch.inference_mode(): output = model.generate(**inputs, max_new_tokens=64, do_sample=False)print(tokenizer.decode(output[0, inputs.input_ids.shape[1]:], skip_special_tokens=True))
Accept only a JSON object with the single determination key and one of the four enumerated values; reject other output. FUTURE_RULES_UNPUBLISHED maps to the project's long future status. It represents this experiment's frozen temporal policy, not a claim about the current publication status of future technical rules.
Reproducibility and licensing
Use the runbook and scripts/run_v0_5.ps1 in the included source snapshot. Training needs compatible CUDA packages and several hours. Source/data tests run without GPU. The GitHub project contains regulatory-source handling, rules, datasets, benchmarks and the training pipeline.
Adapter: Apache-2.0. Qwen3-4B base: Apache-2.0 (verified at the pinned revision). MiFIDBrain code: MIT. The MIT licence does not apply to Qwen weights. No base weights or optimizer states are included.
Recommended application architecture retains deterministic temporal, completeness and regulatory checks, with model assistance. More blind, diverse and professionally reviewed tests are needed before wider reliability claims.