This is Version 2 of the sirunchained/text-to-sql-model, fine-tuned from google/gemma-3-270m-it for Text-to-SQL generation.
In this version, the model is merged with the LoRA adapter – you can load it directly with pipeline() (no PEFT required).
Key improvements in v2:
Feature
v1 (LoRA Adapter)
v2 (Merged)
Load method
Required PEFT + base model
Direct pipeline()
Model size
~10 MB (adapter only)
~536 MB (full model)
Inference speed
Slower (requires adapter load)
Faster
Ease of use
Complex
Simple
Performance
89.7% accuracy
✅ Same
🧠 Task
Text-to-SQL Generation
Converts natural language questions into SQL queries. Supports:
Best validation loss was achieved at epoch 9 (0.617). Highest mean token accuracy on validation was at epoch 8 (85.1%).
💻 Quick Start
Using Pipeline (Recommended)
fromtransformersimportpipelinegenerator=pipeline("text-generation",model="sirunchained/text-to-sql-model-v2",device=0# or "cuda")# Example with schemaprompt="""<start_of_turn>user
# Schema
customers(id, name, email, country)
# Text
Find customers from USA.<end_of_turn>
<start_of_turn>model
"""result=generator(prompt,max_new_tokens=128)print(result[0]["generated_text"])
With Chat Template
fromtransformersimportpipelinepipe=pipeline("text-generation",model="sirunchained/text-to-sql-model-v2")messages=[{"role":"user","content":"# Schema\ncustomers(id, name, email)\n\n# Text\nFind customers with gmail emails."}]outputs=pipe(pipe.tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True),max_new_tokens=128)print(outputs[0]["generated_text"])
LoRA adapter only (not directly loadable with pipeline)
v2
2026-07-23
Merged version – fully loadable with pipeline()
🛠️ Training Configuration
# LoRA ConfigurationLoraConfig(r=8,lora_alpha=16,lora_dropout=0.05,bias="none",task_type=TaskType.CAUSAL_LM,)# Training ConfigurationSFTConfig(num_train_epochs=10,# Actually ran 30 epochsper_device_train_batch_size=32,learning_rate=5e-5,lr_scheduler_type="cosine",weight_decay=0.01,load_best_model_at_end=True,metric_for_best_model="eval_loss",greater_is_better=False,)
⚠️ Important Notes
This is a small language model (270M parameters) – works on T4 GPUs
Provide schema only when needed– works with or without it
For non-SQL requests, the model outputs INVALID_QUERY (trained with negative samples)
The model handles INSERT, UPDATE, and DELETE queries correctly