Run this model with HF Jobs
Run cardohso/granite-rail-extract-lora on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/cardohso/granite-rail-extract-lora. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/cardohso/granite-rail-extract-lora on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use cardohso/granite-rail-extract-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use cardohso/granite-rail-extract-lora with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
rail-extract LoRA adapters (granite-4.2-3b)
LoRA adapters that extract measurable requirements from passages of EU railway Technical Specifications for Interoperability (TSIs). Each requirement has a parameter, a comparator, a value or range, a unit, conditions and a verbatim quote, and the output is JSON. The adapters were made for a pre-registered comparison of fine-tuning vs prompting. Code, data, predictions and the full report are at https://github.com/cardohso/rail-extract-lora.
This is a research artefact, not a compliance tool. Do not use it to decide whether anything meets a regulation.
Contents
| Folder | Seed | SHA-256 of adapter_model.safetensors |
|---|---|---|
C2-s1 |
1 | a14c3873aa511642c90b4e9b2ae755986f713e885aac91fd7c153d9c00e09489 |
C2-s2 |
2 | a392abecc188304c85493429d3946729cee558452d1e6b2b08322800d3b8f83a |
C2-s3 |
3 | 63ae4327cbc711de903c1a1e1bee61f3576efc8c66b02cc39817a9738b7c3ac1 |
These are the exact files used in the final test run (results/freeze.json in the GitHub repo).
No seed was selected; the reported results average all three.
Use
Base model: ibm-granite/granite-4.2-3b, revision 4e9c275e232f10211ec88644d106a1f6a1b60e06.
The adapter expects the training instruction (prompt v1) and the chat template with thinking off.
rail_extract.prompts.build_messages in the GitHub repo builds the messages.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base = "ibm-granite/granite-4.2-3b"
rev = "4e9c275e232f10211ec88644d106a1f6a1b60e06"
tok = AutoTokenizer.from_pretrained(base, revision=rev)
model = AutoModelForCausalLM.from_pretrained(base, revision=rev, torch_dtype="auto")
model = PeftModel.from_pretrained(model, "cardohso/granite-rail-extract-lora", subfolder="C2-s1")
Results were produced with greedy decoding in fp16 on one T4 GPU, with at most 2,048 new tokens.
Training
- 250 training passages from 7 TSIs and the Interoperability Directive. The INF TSI was held out.
- LoRA r 16, alpha 32, dropout 0.05, on
q_proj,k_proj,v_proj,o_proj(10.5 M trainable parameters). AdamW, learning rate 1e-4, 10% linear warm-up, 4 epochs, batch size 4, fp16. - About 24 to 29 minutes per seed on one Tesla T4, peak 11.6 GB.
- The configuration (C2) was the best of 8 on validation.
Results (main test set, 70 passages, field micro-F1, 95% bootstrap CI)
| System | F1 |
|---|---|
| These adapters, unconstrained, mean of 3 seeds | 0.690 [0.562, 0.802] |
| Same, with schema-constrained decoding | 0.726 [0.621, 0.809] |
| Same base model, best prompt, no adapter | 0.392 [0.265, 0.502] |
gemini-3.5-flash-lite, schema-enforced |
0.592 [0.416, 0.753] |
| Regular expressions | 0.347 [0.224, 0.463] |
- Against prompting the same base model: +0.298 [+0.147, +0.443].
- Against the API model, the two cannot be told apart.
- On the held-out INF TSI (30 passages), F1 is 0.455 [0.180, 0.788], and the gain over prompting is not clear.
- With 4-bit NF4 quantisation, test F1 falls to 0.534.
Limitations
- All labels were made by LLMs (Claude Sonnet 5.5 and Opus 5.5) and never checked by a human. The scores measure agreement with those labels, not with verified ground truth.
- The data are small (250 train, 70 test, 30 held-out passages), and the text is English only.
- The adapters miss conditions more than any other field.
- Consolidated EUR-Lex texts have no legal effect, and nothing here is legal advice.
Licence and sources
The adapters are released under Apache 2.0, the base model's licence. Training passages come from EUR-Lex, © European Union, reused under Commission Decision 2011/833/EU.
- Downloads last month
- -
Model tree for cardohso/granite-rail-extract-lora
Base model
ibm-granite/granite-4.1-3b-base