Text Generation
Transformers
Safetensors
English
llama
distillation
knowledge-distillation
json-extraction
structured-output
information-extraction
gemma-4
minicpm5
edge-ai
schemaforge
conversational
text-generation-inference
Instructions to use arrochi112/SchemaForge-1B-JSON-Extractor with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use arrochi112/SchemaForge-1B-JSON-Extractor with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="arrochi112/SchemaForge-1B-JSON-Extractor") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("arrochi112/SchemaForge-1B-JSON-Extractor") model = AutoModelForCausalLM.from_pretrained("arrochi112/SchemaForge-1B-JSON-Extractor", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use arrochi112/SchemaForge-1B-JSON-Extractor with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "arrochi112/SchemaForge-1B-JSON-Extractor" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arrochi112/SchemaForge-1B-JSON-Extractor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/arrochi112/SchemaForge-1B-JSON-Extractor
- SGLang
How to use arrochi112/SchemaForge-1B-JSON-Extractor with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "arrochi112/SchemaForge-1B-JSON-Extractor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arrochi112/SchemaForge-1B-JSON-Extractor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "arrochi112/SchemaForge-1B-JSON-Extractor" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arrochi112/SchemaForge-1B-JSON-Extractor", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use arrochi112/SchemaForge-1B-JSON-Extractor with Docker Model Runner:
docker model run hf.co/arrochi112/SchemaForge-1B-JSON-Extractor
File size: 11,905 Bytes
3d9f5ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 | ---
language:
- en
license: apache-2.0
tags:
- distillation
- knowledge-distillation
- json-extraction
- structured-output
- information-extraction
- gemma-4
- minicpm5
- edge-ai
- schemaforge
pipeline_tag: text-generation
base_model: openbmb/MiniCPM5-1B
library_name: transformers
metrics:
- accuracy
- f1
- throughput
---
# SchemaForge-1B β JSON Extractor
**A 1.08B-parameter edge SLM distilled from Gemma-4 for zero-shot enterprise JSON extraction.**
SchemaForge-1B converts unstructured business documents β invoices, bills of lading, requisitions, receipts β into strongly-typed, schema-conformant JSON. It was distilled from **`google/gemma-4-31B`** and **`google/gemma-4-E4B-it`** into **`openbmb/MiniCPM5-1B`** using a multi-task objective combining hard cross-entropy with temperature-scaled, log-space soft-logit KL divergence ($\alpha = 0.5$, $\tau = 2.0$), trained on an NVIDIA RTX PRO 6000 Blackwell Edition (96 GB).
| | 31B Teacher | **SchemaForge-1B** |
|---|---|---|
| In-domain JSON syntax error rate *(n = 5 docs)* | 0.0 % | **0.0 %** |
| In-domain extraction F1 *(n = 5 docs)* | 1.000 | **1.000** |
| Zero-shot validity (`suneeldk/text-json`) | β | **70.0 %** |
| Throughput | 12.40 tok/s | **61.91 β 76.27 tok/s** |
| Peak VRAM | β38.5 GB | **β2.4 GB** |
| Workers per 96 GB GPU | 2 | **36** |
**16.0Γ smaller Β· 5.0Γ faster Β· ~110Γ aggregate system throughput**
---
## β οΈ Read This First: The Prompt Template Is Not Optional
This model was distilled on **one exact prompt template**. Because it is a 1.08B student trained on a narrow task, it binds its behavior to the **literal surface form** of that prefix. In our experiments, changing only the instruction header dropped zero-shot validity from **70.0 % to 0.0 %** β worse than the *untrained* base model.
Use this string, byte for byte:
```python
TEMPLATE = "Extract structured JSON from the text:\n{doc}\nJSON Output:"
```
Do not wrap it in chat tokens. Do not prepend a system persona. Do not add a trailing newline. Treat it as a versioned API contract.
---
## π Benchmark Evidence
### 1. Throughput and VRAM

*Figure 1: **5.0Γ throughput speedup** (61.91 vs. 12.40 tok/s, matched harness) and **16.0Γ VRAM reduction** (β2.4 GB vs. β38.5 GB), measured on identical hardware.*
### 2. Zero-shot accuracy across distillation iterations

*Figure 2: Validity on `suneeldk/text-json`. Iterations 1 and 3 differ from the winning Iteration 2 **only in prompt header** β and both collapse to 0.0 %.*
### 3. Training convergence

*Figure 3: Loss over 3 epochs, Gemma-4-31B teacher. Iteration 2 (released): 9,132.9 β 6,962.3 β 6,612.7 (β27.6 %). Summed losses β comparable within a run, not across runs.*
---
## Quickstart
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
model_id = "arrochi112/SchemaForge-1B-JSON-Extractor"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.bfloat16 if torch.cuda.is_available() else torch.float32,
).to("cuda" if torch.cuda.is_available() else "cpu")
# No trust_remote_code needed β MiniCPM5-1B is a stock LlamaForCausalLM.
# CANONICAL TEMPLATE β do not modify
prompt = (
"Extract structured JSON from the text:\n"
"INVOICE #INV-1001. Vendor: Acme Supply Co. Date: 2026-04-10. "
"Subtotal: $480.00. Tax (8%): $38.40. Total: $518.40.\n"
"JSON Output:"
)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].size(1):],
skip_special_tokens=True))
```
Expected:
```json
{
"invoice_number": "INV-1001",
"vendor_name": "Acme Supply Co",
"invoice_date": "2026-04-10",
"subtotal": 480.00,
"tax": 38.40,
"grand_total": 518.40
}
```
---
## Production Serving (vLLM)
```python
from vllm import LLM, SamplingParams
llm = LLM(
model="arrochi112/SchemaForge-1B-JSON-Extractor",
dtype="bfloat16",
gpu_memory_utilization=0.90,
max_model_len=2048,
max_num_seqs=36, # 36 workers fit in 96 GB at 2.4 GB each
)
sampling_params = SamplingParams(temperature=0.0, max_tokens=256)
TEMPLATE = "Extract structured JSON from the text:\n{doc}\nJSON Output:"
docs = [
"Invoice #INV-881, Vendor: Globex Corp, Date: 2026-08-03, Total: $450.00",
"Invoice #INV-882, Vendor: Initech LLC, Date: 2026-08-04, Total: $1200.00",
]
for out in llm.generate([TEMPLATE.format(doc=d) for d in docs], sampling_params):
print(out.outputs[0].text)
```
### Recommended: layer schema-constrained decoding
Distillation supplies *semantics*; FSM-guided decoding guarantees *syntax*. Run both.
```python
from pydantic import BaseModel
from vllm.sampling_params import GuidedDecodingParams
class Invoice(BaseModel):
invoice_number: str
vendor_name: str
invoice_date: str
subtotal: float
tax: float
grand_total: float
sampling_params = SamplingParams(
temperature=0.0,
max_tokens=256,
guided_decoding=GuidedDecodingParams(json=Invoice.model_json_schema()),
)
```
---
## Evaluation
### Five-domain enterprise suite (in-domain, n = 5 documents)
| Domain | Document type | Base MiniCPM5-1B | **SchemaForge-1B** | F1 | Throughput |
|---|---|---|---|---|---|
| BMK-01 Finance | Tax invoices | 65.8 % | **100.0 %** | 1.000 | 61.91 tok/s |
| BMK-02 Supply chain | Bills of lading | 67.1 % | **100.0 %** | 1.000 | 62.40 tok/s |
| BMK-03 IT hardware | Procurement bills | 64.2 % | **100.0 %** | 1.000 | 61.80 tok/s |
| BMK-04 Biomedical | Lab requisitions | 66.5 % | **100.0 %** | 1.000 | 62.15 tok/s |
| BMK-05 Cloud ops | Billing records | 65.4 % | **100.0 %** | 1.000 | 62.05 tok/s |
### Model comparison
| Variant | Teacher | JSON error rate | F1 | Throughput | VRAM |
|---|---|---|---|---|---|
| Base MiniCPM5-1B | none | 34.2 % | 0.612 | 62.00 tok/s | β2.4 GB |
| **SchemaForge-1B** | `gemma-4-E4B-it` | **0.0 %** | **1.000** | **61.91 tok/s** | **β2.4 GB** |
| **SchemaForge-1B** | `gemma-4-31B` | **0.0 %** | **1.000** | 56.12 tok/s | **β2.4 GB** |
| Gemma-4-31B | reference | 0.0 % | 1.000 | 12.40 tok/s | β38.5 GB |
Teacher scale conferred **no measurable quality advantage** on this task β the 4B teacher is the cost-effective choice.
### Out-of-domain (`suneeldk/text-json`)
| Iteration | Prompt template | Validity | Throughput |
|---|---|---|---|
| iter1 | chat tokens (`<start_of_turn>`) | 0.0 % | 76.94 tok/s |
| **iter2 (this model)** | **canonical** | **70.0 %** | **76.27 tok/s** |
| iter3 | system persona header | 0.0 % | 74.12 tok/s |
| base | canonical | 34.2 % | 62.00 tok/s |
---
## Training Details
| | |
|---|---|
| Architecture | `LlamaForCausalLM` β 24 layers, hidden 1536, GQA 16/2 heads, vocab 130,560 |
| Parameters | 1,080,632,832 total (679,552,512 non-embedding) |
| Objective | $\mathcal{L}_{KD} = \alpha\mathcal{L}_{CE} + (1-\alpha)\tau^2\mathcal{L}_{KL}$ |
| $\alpha$ / $\tau$ | 0.5 / 2.0 |
| Vocabulary projection | 256,000 β 130,560 (shared-subspace truncation) |
| Optimizer | AdamW, lr 2e-5, cosine, warmup 0.05 |
| Epochs | 3 (early-stopped on val loss) |
| Runtime | bfloat16, single-GPU PyTorch, eager attention (no ZeRO-3 / FlashAttention-2) |
| Max sequence length | 2,048 |
| Hardware | 1 Γ NVIDIA RTX PRO 6000 Blackwell Edition (96 GB), Nebius AI Cloud |
| Software | Python 3.12 Β· PyTorch 2.5 Β· transformers 5.x |
Full methodology, mathematics, compatibility patches, and ablations: **[`SCHEMAFORGE_WHITEPAPER.md`](./SCHEMAFORGE_WHITEPAPER.md)**.
---
## Limitations
Please read these before deploying.
- **Evaluation scale is small.** The in-domain suite is **n = 5 documents** (one per domain). The 100 % validity / 1.000 F1 figures are exact-match results on a small curated set, not population estimates β the Wilson 95 % CI on 5/5 is **[56.6 %, 100.0 %]**.
- **Training scale is small.** This checkpoint was distilled on **n = 5 samples**. An SFT control ($\alpha = 1.0$, no teacher logits) was **not run**, so we cannot presently separate the contribution of knowledge distillation from that of prompt-format conditioning.
- **Single seed.** No variance estimates or error bars. Sub-2B models vary substantially run-to-run on small datasets.
- **Prompt-template brittleness.** The headline failure mode. Deviating from the canonical template drops accuracy to ~0, not to a degraded-but-usable level.
- **Out-of-domain ceiling β 70 %.** Roughly 30 % of unseen real-world documents produce unparseable output. Use constrained decoding in production.
- **Synthetic in-domain documents.** Clean ASCII, consistent labeling, no OCR noise, English-only. Real scanned documents will be harder.
- **Teacher outputs as targets.** Where the teacher was wrong, the student learned the error. No human-annotated gold standard exists for this checkpoint.
- **Not evaluated against alternatives.** No comparison to Qwen2.5-1.5B, Phi-3-mini, rule-based extractors, or commercial document-AI APIs.
**Intended use:** structured extraction from short English business documents, behind a schema-validation layer.
**Out of scope:** open-domain chat, reasoning, code, multilingual input, medical/legal decision-making, or any use where an unvalidated extraction reaches a system of record.
### Planned v2 run
This is a **v1 release**, and the accuracy numbers above should be read as provisional. A second training and evaluation campaign is planned to address the limitations listed here directly:
- **Real-world evaluation corpus** replacing the synthetic 5-document suite β $n \geq 500$ held-out documents per domain, including OCR-noisy scans, multi-column layouts, and non-English fields, with a **human-annotated gold subset** so accuracy is no longer measured against teacher output.
- **The SFT control** ($\alpha = 1.0$, no teacher logits) to determine whether the distillation objective contributes anything beyond prompt-format conditioning.
- **Competitive baselines** β Qwen2.5-1.5B, Phi-3-mini, prompt-engineered base MiniCPM5-1B with constrained decoding, and a rule-based extractor β under one unified harness.
- **Multi-seed runs** (β₯3) with reported variance and confidence intervals on every metric.
- **Expanded metrics** beyond validity/F1/throughput/VRAM: per-field accuracy, schema-conformance rate, hallucinated-key rate, time-to-first-token, p50/p95 latency under concurrency, and cost per thousand documents.
Results will be published as a v2 card revision with the v1 numbers retained for comparison rather than quietly replaced.
---
## Citation
```bibtex
@techreport{ty2026schemaforge,
title = {SchemaForge: Distilling Ultra-Large Foundation Models into Edge SLMs
for Real-Time Enterprise JSON Extraction --
A Comparative Study of Gemma-4 Teachers and MiniCPM5-1B},
author = {Ty, Arjhine A.},
year = {2026},
note = {Model: SchemaForge-1B (schemaforge-1b-iter2)},
url = {https://huggingface.co/arrochi112/SchemaForge-1B-JSON-Extractor}
}
```
## Acknowledgements
Teachers: `google/gemma-4-31B`, `google/gemma-4-E4B-it`. Student architecture: `openbmb/MiniCPM5-1B`. Compute: Nebius AI Cloud. Serving: vLLM. Constrained decoding: Outlines.
**License:** Apache 2.0 β subject to the upstream licenses of the base and teacher models.
|