Nest · Base model · Dataset · Benchmarks
A 4-billion-parameter model that writes a single read-only SQLite query that answers a question over a given database schema. Nest fine-tuned Qwen3.5-4B with LoRA and benchmarked it against the untuned base model and a frontier model, GPT-5.6 Terra. On the held-out test set it matches the frontier model: 76.67% execution accuracy against 74.17% for GPT-5.6 Terra and 72.50% for the base model.
| Model | Adaptation | Test execution accuracy | Test valid SQL | Validation execution accuracy |
|---|---|---|---|---|
| This model | Nest LoRA | 76.67% | 99.17% | 80.00% |
| GPT-5.6 Terra | zero-shot | 74.17% | 97.92% | 77.50% |
| Qwen3.5-4B (base) | none | 72.50% | 98.33% | 77.50% |
Test: 240 questions. Validation: 160 questions. Valid SQL is the share of outputs that parse and run. LoRA − Terra on test execution accuracy: +2.5 pp, paired bootstrap 95% CI [−2.1, +7.1] pp. The interval includes zero: on this benchmark the adapter matches Terra; it does not significantly beat it.
inference_config.json.Requires transformers>=5.5, peft>=0.21, torch and accelerate. The base weights are downloaded from the Hub; this repository holds only the adapter.
import json
import torch
from huggingface_hub import hf_hub_download
from peft import PeftModel
from transformers import AutoModelForImageTextToText, AutoTokenizer
repo = "guistmartin/qwen3.5-4b-gretel-sql-lora"
config = json.load(open(hf_hub_download(repo, "inference_config.json")))
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3.5-4B")
base = AutoModelForImageTextToText.from_pretrained("Qwen/Qwen3.5-4B", dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, repo).eval() # keep the adapter attached: do not merge_and_unload()
schema = "CREATE TABLE orders (id INTEGER, customer TEXT, total REAL);"
question = "What is the total revenue per customer?"
messages = [
{"role": "system", "content": config["system_prompt"]},
{"role": "user", "content": config["user_template"].format(sql_context=schema, sql_prompt=question)},
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=False,
return_dict=True, return_tensors="pt").to(model.device)
with torch.inference_mode():
output = model.generate(**inputs, max_new_tokens=config["max_new_tokens"], do_sample=False)
print(tokenizer.decode(output[0, inputs.input_ids.shape[-1]:], skip_special_tokens=True).strip())
| Developed by | Nest |
| Model type | LoRA adapter (PEFT) for a causal language model |
| Base model | Qwen/Qwen3.5-4B |
| Task | Text-to-SQL (SQLite, read-only) |
| Language | English |
| Dataset | Gretel synthetic_text_to_sql (Apache 2.0) |
| License | Apache 2.0 |
| Method | Supervised LoRA fine-tuning on Tinker, one round |
| Steps | 250 optimizer steps, 2 epochs, batch size 128 |
| Training data | 16,000 real Gretel examples, no synthetic or teacher data |
| LoRA rank / learning rate | 16 / 2e-4 |
| Seed | 42 |
The adapter was converted from the native Tinker checkpoint to PEFT, preserving LoRA scaling, fusing Q/K/V updates into the Qwen3.5 layout and keeping the output-head adapter separate from the tied input embeddings. Nest verified projection equivalence, every saved tensor and PEFT loading on the exact base architecture. Keep the adapter attached rather than calling merge_and_unload().
| File | Contents |
|---|---|
adapter_model.safetensors, adapter_config.json |
The LoRA adapter |
inference_config.json |
Exact system prompt, renderer and decoding settings |
metrics.json |
Aggregate scores, training counts and provenance hashes |
data_manifest.json |
Dataset revision, split hashes and counts |
base_test_metrics.json |
The untuned base model's test scores (post-hoc run) |
benchmark.png |
The benchmark card above |
@misc{nestgretelsql2026,
title = {Qwen3.5-4B Gretel SQL: a Nest LoRA for text-to-SQL (SQLite, read-only)},
author = {Nest},
year = {2026},
url = {https://huggingface.co/guistmartin/qwen3.5-4b-gretel-sql-lora}
}
Nest turns the narrow, repeated LLM calls inside an agent into small models trained for that one task: same quality or better, at a fraction of the cost and latency. More results at nest.technology/benchmarks.
Qwen/Qwen3.5-4B