This is a small-dataset seed adapter intended as a portfolio demonstration of code-domain fine-tuning. The fine-tune-quality measurement against the base model is below the 50/50 line on this volume of data (see Evaluation), and is documented honestly. A larger refresh round on real schema-grounded query pairs is the recommended path to production-grade text-to-SQL.
Numbers are pulled directly from the local benchmark JSON. No invented values.
Honest read: at 697 training examples the adapter does not beat the base model in pairwise judge quality. Spider EM (execution match) on the held-out dev set has not yet been measured against an actual database; that is the appropriate domain-specific eval and is the recommended next step. The pipeline runs end-to-end and the artifacts ship, but production text-to-SQL on a real schema requires a substantially larger and more schema-diverse corpus.
The 20% false positive rate on benign controls indicates over-blocking on benign analytical SQL prompts. A DPO alignment pass with refusal-behavior pairs that distinguishes "DROP TABLE users" (block) from "SELECT count(*) FROM users WHERE deleted = true" (allow) would reduce this. Recommended next step before this adapter routes real production traffic.
1from peft import PeftModel
2from transformers import AutoModelForCausalLM, AutoTokenizer
3import torch
4
5base_id = "meta-llama/Llama-3.1-8B-Instruct"
6adapter_id = "pyloxsystems/sql-spider-llama-3.1-8b-lora"
7
8tokenizer = AutoTokenizer.from_pretrained(base_id)
9model = AutoModelForCausalLM.from_pretrained(
10 base_id, torch_dtype=torch.bfloat16, device_map="auto"
11)
12model = PeftModel.from_pretrained(model, adapter_id)
13
14schema = """
15CREATE TABLE orders (id INT PRIMARY KEY, customer_id INT, total NUMERIC, created_at TIMESTAMP);
16CREATE TABLE customers (id INT PRIMARY KEY, name TEXT, country TEXT);
17"""
18messages = [
19 {"role": "system", "content": f"You translate natural language to PostgreSQL SQL.\n\nSchema:\n{schema}"},
20 {"role": "user", "content": "Total revenue from Canadian customers in the last 30 days?"},
21]
22inputs = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
23out = model.generate(inputs, max_new_tokens=256, do_sample=False)
24print(tokenizer.decode(out[0], skip_special_tokens=True))
1vllm serve nvidia/Llama-3.1-8B-Instruct-NVFP4 \
2 --enable-lora \
3 --lora-modules sql-spider=pyloxsystems/sql-spider-llama-3.1-8b-lora \
4 --speculative-config '{
5 "method": "eagle3",
6 "model": "RedHatAI/Llama-3.1-8B-Instruct-speculator.eagle3",
7 "num_speculative_tokens": 5
8 }'
1@misc{pylox_sql_spider_2026,
2 author = {Girard, Emilio},
3 title = {Pylox Text-to-SQL 8B (sql-spider)},
4 year = {2026},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/pyloxsystems/sql-spider-llama-3.1-8b-lora}}
7}
Pylox Forge is a solo-operated LLM fine-tuning lab on NVIDIA Grace Blackwell. Site:
pyloxforge.com. Other adapters:
pyloxsystems on Hugging Face.