Instructions to use ay2r/sqlforge-3b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ay2r/sqlforge-3b with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ay2r/sqlforge-3b") 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("ay2r/sqlforge-3b") model = AutoModelForCausalLM.from_pretrained("ay2r/sqlforge-3b", 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]:])) - PEFT
How to use ay2r/sqlforge-3b with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use ay2r/sqlforge-3b 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 ay2r/sqlforge-3b:Q4_K_M # Run inference directly in the terminal: llama cli -hf ay2r/sqlforge-3b:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf ay2r/sqlforge-3b:Q4_K_M # Run inference directly in the terminal: llama cli -hf ay2r/sqlforge-3b:Q4_K_M
Build from source code
git clone https://github.com/ggml-org/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-app # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama serve -hf ay2r/sqlforge-3b:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama cli -hf ay2r/sqlforge-3b:Q4_K_M
Use Docker
docker model run hf.co/ay2r/sqlforge-3b:Q4_K_M
- Llama new
- LM Studio
- Jan
- vLLM
How to use ay2r/sqlforge-3b with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ay2r/sqlforge-3b" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ay2r/sqlforge-3b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ay2r/sqlforge-3b:Q4_K_M
- SGLang
How to use ay2r/sqlforge-3b 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 "ay2r/sqlforge-3b" \ --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": "ay2r/sqlforge-3b", "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 "ay2r/sqlforge-3b" \ --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": "ay2r/sqlforge-3b", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use ay2r/sqlforge-3b with Ollama:
ollama run hf.co/ay2r/sqlforge-3b:Q4_K_M
- Unsloth Desktop
- Pi
How to use ay2r/sqlforge-3b with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ay2r/sqlforge-3b:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:9931/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "ay2r/sqlforge-3b:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use ay2r/sqlforge-3b with Docker Model Runner:
docker model run hf.co/ay2r/sqlforge-3b:Q4_K_M
- Lemonade
How to use ay2r/sqlforge-3b with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull ay2r/sqlforge-3b:Q4_K_M
Run and chat with the model
lemonade run user.sqlforge-3b-Q4_K_M
List all available models
lemonade list
- Hermes Agent
How to use ay2r/sqlforge-3b with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ay2r/sqlforge-3b:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:9931/v1 hermes config set model.default ay2r/sqlforge-3b:Q4_K_M
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use ay2r/sqlforge-3b with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf ay2r/sqlforge-3b:Q4_K_M
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:9931/v1 \ --custom-model-id "ay2r/sqlforge-3b:Q4_K_M" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
SQLForge-3B
A 3B text-to-SQL model for SQLite: Qwen2.5-Coder-3B-Instruct fine-tuned with QLoRA on Spider and BIRD training data, built on a single 8 GB laptop GPU.
Part of the SQLForge project, which also includes an evaluation harness, serving with vLLM and quantization, guardrails, self-correction and an observability stack. See the project README for the full write-up.
Results
Execution accuracy (EX): the predicted query's result set matches the gold query's.
Greedy decoding, schema given as CREATE TABLE DDL plus 3 sample rows per table.
| Model | Spider dev EX | BIRD dev EX* |
|---|---|---|
| Qwen2.5-Coder-3B-Instruct (base) | 71.8 | 41.7 |
| SQLForge-3B run 1 (Spider only) | 78.0 | 43.5 |
| SQLForge-3B (this model) | 78.5 | 53.1 |
| + deterministic column fix + execution-guided self-correction | 80.5 | 54.1 |
*Fixed random 500-question subset of BIRD dev (seed 42); evidence hints included in the prompt.
Quantized variants:
| Variant | Size | Spider EX | BIRD EX |
|---|---|---|---|
| bf16 | 5.8 GB | 78.5 | 53.1 |
| FP8 (vLLM, online) | weights 3.2 GB in VRAM | 78.6 | 52.7 |
| GGUF Q8_0 | 3.3 GB | 78.4 | 52.5 |
| GGUF Q4_K_M | 1.8 GB | 76.6 | 52.7 |
| AWQ W4A16 | 2.0 GB | 75.2 | 51.9 |
Prompt format
Use the chat template with this system prompt and user message (the model was trained on exactly this):
[system] You are an expert SQLite engineer. Given a database schema and a question, write a single
correct SQLite SELECT query that answers it. Return only the SQL, with no explanation.
[user]
### Database schema
CREATE TABLE singer (
Singer_ID INTEGER,
Name TEXT,
...
);
-- sample rows (Singer_ID | Name | ...):
-- 1 | Joe Sharp | ...
### Question
How many singers are there?
### Hint <- optional, BIRD-style domain knowledge
...
### SQL
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("ay2r/sqlforge-3b")
model = AutoModelForCausalLM.from_pretrained("ay2r/sqlforge-3b", dtype="bfloat16", device_map="auto")
messages = [{"role": "system", "content": SYSTEM_PROMPT}, {"role": "user", "content": user_prompt}]
ids = tok.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
print(tok.decode(model.generate(ids, max_new_tokens=256, do_sample=False)[0, ids.shape[1]:], skip_special_tokens=True))
With vLLM: vllm serve ay2r/sqlforge-3b --quantization fp8 --enable-prefix-caching. Prefix
caching matters here: questions on the same database share the schema prefix, which gave 4.7ร
throughput on BIRD.
Training
- Data:
- 16,218 examples: Spider train (8,140) and BIRD train (8,078), from 201 databases.
- BIRD examples whose gold SQL fails to execute were dropped (478).
formula_1was excluded because it overlaps BIRD dev.- No dev databases or questions appear in training; a contamination check confirms this.
- Method:
- QLoRA: NF4 4-bit base, LoRA r=16, ฮฑ=32, dropout 0.05, on all attention and MLP projections (0.96% of parameters).
- Loss on the SQL completion only.
- Hyperparameters: 1 epoch (1,014 steps), learning rate 2e-4 with cosine decay, effective batch 16, max length 2,048, paged AdamW 8-bit, gradient checkpointing.
- Compute: one RTX 5060 Laptop GPU (8 GB): 7.2 h, peak 3.5 GB.
- Checkpoint: the final checkpoint. On full Spider and BIRD it beat the checkpoint chosen by validation execution accuracy.
Limitations
- SQLite dialect only. It was trained and evaluated on SQLite; other dialects will need adaptation.
- It hallucinates column names. This is the main remaining failure mode, with 66 of 1,034 Spider dev and 53 of 500 BIRD answers affected. On Spider most are near-misses (
pet_typeforPetType) that a deterministic post-processing step fixes. On BIRD they're mostly invented. - Harder questions and value semantics. It's weaker on BIRD "challenging" questions (36% EX) and on questions that need value-level domain knowledge without a hint.
- Schema size. Prompts over about 8k tokens (very wide schemas) need schema linking, which is in the project's serving pipeline.
- Not safe to run unchecked. Like any LLM, it can be prompt-injected into emitting destructive SQL; this was observed with
DROP TABLE. Never run its output on a database without guardrails. The project ships a read-only guardrail layer for this.
License and attribution
The weights derive from Qwen2.5-Coder-3B-Instruct; check its license before redistribution. Training data: Spider (CC BY-SA 4.0) and BIRD (CC BY-SA 4.0).
- Downloads last month
- -
Model tree for ay2r/sqlforge-3b
Dataset used to train ay2r/sqlforge-3b
Evaluation results
- Execution accuracy (greedy) on Spider 1.0 devself-reported78.500
- Execution accuracy (+ column fix + self-correction) on Spider 1.0 devself-reported80.500
- Execution accuracy (greedy) on BIRD dev (500-question subset)self-reported53.100
- Execution accuracy (+ self-correction) on BIRD dev (500-question subset)self-reported54.100