Usage
Use the prompt the model was trained with, and turn thinking off:
from transformers import AutoModelForCausalLM, AutoTokenizer model_id = "scrapegraphai/sgai-qwen3-1.7b"tokenizer = AutoTokenizer.from_pretrained(model_id)model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype="auto", device_map="auto") schema = '{"type": "object", "properties": {"title": {"type": "string"}, "price": {"type": "number"}}, "required": ["title", "price"]}'content = "# Blue Mug\n\nCeramic, 350 ml. **Price: 12.90 EUR**" prompt = f"""Extract data from the content according to the JSON schema.Schema: {schema}Content: {content}Return ONLY valid JSON matching the schema.""" inputs = tokenizer.apply_chat_template( [{"role": "user", "content": prompt}], add_generation_prompt=True, enable_thinking=False, return_tensors="pt",).to(model.device)out = model.generate(inputs, max_new_tokens=1024, do_sample=False, repetition_penalty=1.1)print(tokenizer.decode(out[0][inputs.shape[-1]:], skip_special_tokens=True))
With vLLM: vllm serve scrapegraphai/sgai-qwen3-1.7b, then pass chat_template_kwargs={"enable_thinking": false} per request.
Training
Table | |
|---|
| Base | unsloth/Qwen3-1.7B (mirror of Qwen/Qwen3-1.7B) |
| Data | scrapegraph-100k-finetuning v1.0 train (25,244 examples, 5% held out for eval) |
| Targets | GPT-5-nano (gpt-5-nano-2025-08-07) regenerations, all schema-valid |
| Method | QLoRA with Unsloth, r=16, alpha=16, dropout 0, all attention + MLP projections, loss on completions only |
| Schedule | 2 epochs, lr 1e-4 cosine, 100 warmup steps, AdamW 8-bit, weight decay 0.01, batch 8 × grad-accum 2, max sequence 8,192 tokens, seed 42 |
| Hardware | 1× A100 80GB (Modal) |
Code: modelling/train.py, and modelling/merge_lora.py for the merge.
Evaluation
These numbers are on the test split (2,761 examples after the 8,192-token prompt filter), with plain generation (no constrained decoding), temperature 0 and repetition penalty 1.1. Compliant = output parses and validates against the schema. Key-F1 is measured against the GPT-5-nano targets, so it measures agreement with the teacher, not absolute correctness. Frontier models use native structured-output mode.
Table with columns: Schema bucket, sgai-qwen3-1.7b compliant / key-F1, gpt-5.6 compliant / key-F1| Schema bucket | sgai-qwen3-1.7b compliant / key-F1 | gpt-5.6 compliant / key-F1 |
|---|
| overall | 0.919 / 0.887 | 0.988 / 0.929 |
| depth ≥ 7 | 0.853 / 0.795 | 0.980 / 0.841 |
| keys ≥ 200 | 0.722 / 0.708 | 0.903 / 0.732 |
Full breakdown by complexity: tables/frontier_comparison.md. The paper has the full analysis, including the 30B-A3B reference.
Intended use and limitations
- Intended: structured extraction from web content into a user-supplied JSON schema, especially where a small, self-hosted model is preferred over an API.
- Trained to imitate a teacher, so it inherits GPT-5-nano's errors. Compliance drops on deep (depth ≥ 7) and very large (≥ 200 keys) schemas.
- Plain generation can produce schema-invalid JSON (about 8% overall). Validate the output, or use constrained decoding.
- The training content is mostly English and e-commerce-heavy, and comes from public web pages. Do not use it to profile individuals, and respect website Terms of Service, robots.txt and applicable law when scraping.
Authors
William Brach (Slovak University of Technology in Bratislava), Francesco Zuppichini, Marco Vinciguerra, Lorenzo Padoan (ScrapeGraphAI). Contact: support@scrapegraphai.com · GitHub issues
Citation
@misc{brach2026scrapegraphai100kdatasetschemaconstrainedllm, title={ScrapeGraphAI-100k: Dataset for Schema-Constrained LLM Generation}, author={William Brach and Francesco Zuppichini and Marco Vinciguerra and Lorenzo Padoan}, year={2026}, eprint={2602.15189}, archivePrefix={arXiv}, primaryClass={cs.IR}, url={https://arxiv.org/abs/2602.15189},}