Instructions to use smoll-swarm/SmollExtractor-1.7B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use smoll-swarm/SmollExtractor-1.7B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="smoll-swarm/SmollExtractor-1.7B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("smoll-swarm/SmollExtractor-1.7B") model = AutoModelForCausalLM.from_pretrained("smoll-swarm/SmollExtractor-1.7B", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use smoll-swarm/SmollExtractor-1.7B with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M # Run inference directly in the terminal: llama cli -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M # Run inference directly in the terminal: llama cli -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf smoll-swarm/SmollExtractor-1.7B:Q4_K_M
Use Docker
docker model run hf.co/smoll-swarm/SmollExtractor-1.7B:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use smoll-swarm/SmollExtractor-1.7B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "smoll-swarm/SmollExtractor-1.7B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "smoll-swarm/SmollExtractor-1.7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/smoll-swarm/SmollExtractor-1.7B:Q4_K_M
- SGLang
How to use smoll-swarm/SmollExtractor-1.7B 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 "smoll-swarm/SmollExtractor-1.7B" \ --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": "smoll-swarm/SmollExtractor-1.7B", "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 "smoll-swarm/SmollExtractor-1.7B" \ --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": "smoll-swarm/SmollExtractor-1.7B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use smoll-swarm/SmollExtractor-1.7B with Ollama:
ollama run hf.co/smoll-swarm/SmollExtractor-1.7B:Q4_K_M
- Unsloth Desktop
- Docker Model Runner
How to use smoll-swarm/SmollExtractor-1.7B with Docker Model Runner:
docker model run hf.co/smoll-swarm/SmollExtractor-1.7B:Q4_K_M
- Lemonade
How to use smoll-swarm/SmollExtractor-1.7B with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull smoll-swarm/SmollExtractor-1.7B:Q4_K_M
Run and chat with the model
lemonade run user.SmollExtractor-1.7B-Q4_K_M
List all available models
lemonade list
- Atomic Chat
π SMOL EXTRACTOR 1.7B
Deterministic JSON Schema Extraction Engine for local multi-agent systems
1.71B Parameters Β· Native JSON Format Β· Lossless Schema Mapping Β· Local-First Deployment
π Overview
SmolExtractor-1.7B is a specialized causal language model fine-tuned for deterministic, structured schema extraction from messy, unstructured text. Built as a core worker node for the Smol Swarm local multi-agent architecture, the model forces the extraction of raw, valid JSON conforming exactly to a user-provided schema.
Unlike general-purpose models, SmolExtractor is explicitly trained to eliminate conversational artifacts (e.g., "Sure! Here is your JSON"), ignore output formatting padding, and generate typed properties (strings, integers, floats, booleans) without wrapping the response in markdown backticks.
| Target Domain | Typical Input | Target Output Format |
|---|---|---|
| Invoices & Receipts | Billing text, taxes, transaction IDs, statuses | {"invoice_id": "string", "vendor": "string", "amount": "number", "tax": "number", "status": "string"} |
| System & Security Logs | System dumps, warnings, stack traces | {"level": "string", "service": "string", "status_code": "number", "error_message": "string", "retry_count": "number"} |
| E-Commerce Logistics | Purchase records, customer notes, item quantities | {"order_number": "number", "buyer": "string", "quantity": "number", "item": "string", "is_expedited": "boolean"} |
| Ticketing Systems | Customer complaints, prioritize, emails | {"ticket_id": "string", "requester_email": "string", "priority": "string", "subject": "string", "is_urgent": "boolean"} |
| Vitals & Clinical Data | Clinical summaries, doctor observations | {"name": "string", "age": "number", "bp": "string", "pulse_bpm": "number", "condition": "string"} |
Installation
pip install transformers torch accelerate
Python Inference Script
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_ID = "smoll-swarm/SmolExtractor-1.7B"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.float16,
device_map="auto"
)
SYSTEM_PROMPT = """You are SmolExtractor, a deterministic data extraction engine.
Extract data from the provided text to strictly match the requested JSON schema.
Output ONLY a raw, valid JSON object matching the exact keys and types. Do not output markdown, code blocks, or explanations."""
raw_text = "URGENT: Invoice INV-9821 issued by Stripe Inc to Alice Smith on 2025-04-18. Total due: $1820.50, Tax: $85.00. Status: PAID."
schema = {
"invoice_id": "string",
"vendor": "string",
"customer": "string",
"amount": "number",
"tax": "number",
"is_urgent": "boolean",
"status": "string"
}
user_content = f"Text: \"{raw_text}\"\nSchema: {json.dumps(schema)}"
messages = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_content}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=150,
do_sample=False, # Enforce deterministic greedy decoding
pad_token_id=tokenizer.eos_token_id
)
output_ids = outputs[0][inputs.input_ids.shape[1]:]
extracted_json = tokenizer.decode(output_ids, skip_special_tokens=True).strip()
result = json.loads(extracted_json)
print(result)
# Output:
# {'invoice_id': 'INV-9821', 'vendor': 'Stripe Inc', 'customer': 'Alice Smith', 'amount': 1820.5, 'tax': 85.0, 'is_urgent': True, 'status': 'PAID'}
Raw ChatML Prompt Structure
<|im_start|>system
You are SmolExtractor, a deterministic data extraction engine.
Extract data from the provided text to strictly match the requested JSON schema.
Output ONLY a raw, valid JSON object matching the exact keys and types. Do not output markdown, code blocks, or explanations.<|im_end|>
<|im_start|>user
Text: "Order #84210 placed by Tony Stark. Items: 4x 'Mechanical Keyboard'. Expedited shipping: true. Destination City: 'Austin'."
Schema: {"order_number": "number", "buyer": "string", "quantity": "number", "item": "string", "is_expedited": "boolean", "city": "string"}<|im_end|>
<|im_start|>assistant
Deterministic Response
{"order_number": 84210, "buyer": "Tony Stark", "quantity": 4, "item": "Mechanical Keyboard", "is_expedited": true, "city": "Austin"}<|im_end|>
In production, SmolExtractor-1.7B executes requests routed by SmolRouter-135M in a pipeline:
Incoming User Request
β
βΌ
ββββββββββββββββββββ
β SmolRouter-135M β ~2ms latency classification
βββββββββββ¬βββββββββ
β
βββββββββββββββββββββ΄ββββββββββββββββββββ
βΌ route == 'extractor' βΌ other route
βββββββββββββββββββββββββ βββββββββββββββββββββββββ
β SmolExtractor-1.7B β β Other Swarm Agent β
β (JSON Parser Engine) β β (Summarizer/Coder/etc)β
βββββββββββββ¬ββββββββββββ βββββββββββββββββββββββββ
β
βΌ
Strict Typed JSON
The model was trained using Parameter-Efficient Fine-Tuning (PEFT) with Low-Rank Adaptation (LoRA), and adapters were fused back to baseline weights prior to serialization.
- Dataset Size: 1,500 balanced data extraction conversations across 5 high-priority verticals.
- Masking Objective: Loss calculated strictly on target tokens; system prompt, input text, and target schemas are masked from the loss calculation using a
-100label bias. - LoRA Configuration: $r=16, \alpha=32$, dropout $= 0.05$.
- Target Projections:
q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj(all linear modules of the self-attention block and MLP layers). - Optimization Strategy: AdamW ($\beta_1=0.9, \beta_2=0.999$, weight decay $= 0.01$).
- Learning Rate: $2 \times 10^{-4}$ with a cosine schedule and 20 warmup steps.
- Precision Parameters: 16-bit Automatic Mixed Precision (AMP) with torch gradient scaling.
- Convergence Loss: Final training loss settled at
~0.00across 3 epochs.
| Parameter | Metric |
|---|---|
| Tuned Parameters | 1,729,464,320 |
| Trainable LoRA Weight % | 1.04% (18,087,936 parameters) |
| Context Length Window | 2,048 tokens |
| Output Type | Strict JSON (Greedy Generation) |
| License Agreement | Apache 2.0 |
- Greedy Sampling Recommendation: To ensure strict alignment with formatting rules, generation parameters must disable sampling:
do_sample=Falseortemperature=0.0. - Schema Integrity: The model relies on valid datatypes (
string,number,boolean,array) in the schema parameter. Highly complex, deeply nested, custom objects may occasionally experience schema misalignment. - Language Context: The fine-tuning target dataset consisted exclusively of English prompts. Performance on other languages is uncalibrated.
@misc{smolextractor2025,
title = {SmolExtractor-1.7B: A Deterministic Schema-Constrained Extraction Model},
author = {SmolSwarm Contributors},
year = {2026},
url = {https://huggingface.co/smoll-swarm/SmollExtractor-1.7B}
}
- Downloads last month
- 50
Model tree for smoll-swarm/SmollExtractor-1.7B
Base model
HuggingFaceTB/SmolLM2-1.7B