Instructions to use mirzakhojayev/t2sql-uz-qwen3.5-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use mirzakhojayev/t2sql-uz-qwen3.5-4B with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B") model = PeftModel.from_pretrained(base_model, "mirzakhojayev/t2sql-uz-qwen3.5-4B") - Notebooks
- Google Colab
- Kaggle
t2sql-uz-qwen3.5-4B
A LoRA adapter for Qwen3.5-4B that turns questions in English,
Russian and Uzbek (Latin or Cyrillic) into PostgreSQL. It was also trained on SQLite questions, but only
PostgreSQL was evaluated. Code and full write-up: t2sql-uz-qwen3.5-4B.
Results
Execution accuracy on the standard set of uzbird
(500 BIRD dev questions; PostgreSQL), no thinking, first answer:
| English | Russian | Uzbek Latin | Uzbek Cyrillic | All | |
|---|---|---|---|---|---|
| Qwen3.5-4B | 54.4 | 53.0 | 44.4 | 45.0 | 50.2 |
| This adapter | 60.8 | 59.4 | 57.4 | 50.0 | 58.6 |
| Change | +6.4 | +6.4 | +13.0 | +5.0 | +8.4 |
- All changes except Uzbek Cyrillic (100 questions) are very unlikely to be chance (paired McNemar test, p < 0.005; overall p < 10⁻¹⁰).
- With a majority vote over 5 sampled answers: 55.4 → 60.7.
- It also beats the base model with thinking turned on (55.3), while writing only the query.
How to use
The model expects the prompt format it was trained on: a system prompt, then the schema with column descriptions and
sample values, the database values that match the question, BIRD-style evidence, and the question. Turn thinking
off. The repo builds these prompts from a database (t2sql/final.py, t2sql/describe.py).
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
tok = AutoTokenizer.from_pretrained("Qwen/Qwen3.5-4B")
base = AutoModelForCausalLM.from_pretrained("Qwen/Qwen3.5-4B", dtype=torch.bfloat16, device_map="auto")
model = PeftModel.from_pretrained(base, "mirzakhojayev/t2sql-uz-qwen3.5-4B")
system = ("You are an expert data analyst. Write one SQL query that answers the question for the given database. "
"Use only tables and columns from the schema, and the SQL dialect named in the prompt. "
"Briefly explain your reasoning, then give the final query in a ```sql code block.")
user = """Dialect: PostgreSQL
Schema:
CREATE TABLE schools (
cdscode TEXT PRIMARY KEY, -- e.g. '01100170109835', '01100170112607'
county TEXT, -- e.g. 'Los Angeles', 'San Diego', 'Orange'
charter BIGINT -- whether it is a charter school (1: yes, 0: no); e.g. 0, 1
);
Values in the database that match the question:
schools.county: 'Los Angeles'
Question: Los Angeles okrugida nechta charter maktab bor?"""
text = tok.apply_chat_template([{"role": "system", "content": system}, {"role": "user", "content": user}],
tokenize=False, add_generation_prompt=True, enable_thinking=False)
inputs = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.8, top_k=20)
print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)) # the query in a ```sql block
The schema above is a shortened illustration; real prompts list every table.
vLLM: merge first (model.merge_and_unload().save_pretrained("merged") plus the tokenizer), then load the
merged folder. The reported scores used vLLM with temperature 0.7, top-p 0.8, top-k 20 and a 4,096-token limit.
Training
| Method | LoRA, rank 32, alpha 64, dropout 0.05, on all linear layers (including the DeltaNet projections) |
| Target | The gold SQL only (no reasoning), thinking off |
| Data | 26,249 examples from uzbird train: BIRD train and SynSQL-2.5M questions in English, Russian, Uzbek Latin and Cyrillic (examples over 6,000 tokens and a 2% holdout left out) |
| Prompt | Schema with column descriptions and sample values, matching database values, evidence, question |
| Schedule | 1 epoch, learning rate 1e-4, warmup 5% then cosine, about 20 examples per step (1,321 steps) |
| Precision | bf16 compute; base weights frozen, 0.06B adapter parameters trained |
| Hardware | 1× A100 40GB, 4.7 hours (peak memory 32.7 GB) |
| Holdout loss | 0.131 |
Five earlier runs that trained on reasoning written by DeepSeek or by the model itself all lowered accuracy. Training on gold SQL only, with LoRA and descriptive prompts, is what worked. The repo's write-up has the details.
License
Apache 2.0, like Qwen3.5-4B. The training data comes from BIRD (CC BY-SA 4.0) and SynSQL-2.5M (Apache 2.0).
- Downloads last month
- 45