Making Qwen3-4B a dependable web→JSON extractor with Halo GRPO
ft-hf track · Team lead: @rjaat · Built with Halo
What we did and why
We built a local 4B model that turns messy web pages into schema-valid JSON across three families: product, job, and recipe.
The base model is sloppy: it drops list items, misreads prices in prose, and invents missing values.
We post-trained it with Halo to make extraction more accurate, schema-valid, and grounded in the page.
Method
r = clip(0.4·schema_valid + 0.5·field_F1 − 0.1·fabrication, 0, 1)schema_valid= parses + validates against family schema.field_F1= micro F1 over leaf values with money/K-notation normalisation.fabrication= fraction of non-null values unsupported by the page.
| Source | Role | Rows |
|---|---|---|
| 8 real sites scraped with Firecrawl | real pages with provenance | 243 pages |
| gpt-oss-20b / 120b via OpenRouter | gold labels + noise variants | 247 labels |
| seeded generator | synthetic training pages | 350 rows |
| programmatic noise injection | layout robustness | 75 variants |
Every gold label was schema-validated and every value verified against its page. Near-duplicate clusters were kept whole, with a family-stratified split so no cluster spans train/eval.
Results
| Eval set | Metric | Base | Tuned | Δ |
|---|---|---|---|---|
| real v2 hard (75 pages, unseen domains) | field-F1 | 0.625 | 0.778 | +0.153 |
| real v1 (26 pages) | field-F1 | 0.639 | 0.838 | +0.199 |
| fresh items, new seed 4242 (120 items) | field-F1 | 0.910 | 0.991 | +0.081 |
| real v2 hard | schema-valid | 0.991 | 1.000 | +0.009 |
| real v2 hard | fabrication | 0.0056 | 0.0034 | −0.002 |
| general-ability check (40 items) | overall | 0.925 | 0.925 | 0 |
Three seeds (0, 1, 2), temperature 0.7.
See the difference
Page: Nordic Pulse Headphones 210 — $149.99, in stock. Weight 850 g. Warranty 2 years.
Base Qwen3-4B
{
"name": "Nordic Pulse Headphones 210",
"price": 149.99,
"currency": "USD",
"availability": "in_stock",
"specs": {
"Weight": "850 g"
}
}Tuned (Halo GRPO)
{
"name": "Nordic Pulse Headphones 210",
"price": 149.99,
"currency": "USD",
"availability": "in_stock",
"specs": {
"Weight": "850 g",
"Warranty": "2 years"
}
}The base model drops the warranty field; the tuned model keeps every stated field and invents none.
How to reproduce
torchrun --nproc_per_node=1 scripts/training/grpo/offline.py extraction/configs/extraction-offline-grpo.yaml
python3 extraction/eval_extract.py --model Qwen/Qwen3-4B-Instruct-2507 --data extraction/data/eval_real_v2.jsonl --seeds 0 1 2Platforms used
| Platform | What we used it for |
|---|---|
| Modal | all training and evaluation, 1× H100, offline GRPO |
| Firecrawl | scraped 243 real pages from 8 sites, under 300 credits |
| OpenRouter | gold labelling and noise variants with gpt-oss-20b/120b |
| Baseten | Model APIs: GLM-5.3-Flash re-labelled 90 pages as an independent annotator (87.3% leaf agreement) |
| White Circle | 2 honesty policies scored 4,488 GRPO completions, 173 flagged |
| Lovable | hosts this writeup |
| HuggingFace | model, datasets, writeup mirror |