Instructions to use siruenyian/sqlgenerator-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use siruenyian/sqlgenerator-mini with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("./granite-4.0-350b") model = PeftModel.from_pretrained(base_model, "siruenyian/sqlgenerator-mini") - Transformers
How to use siruenyian/sqlgenerator-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="siruenyian/sqlgenerator-mini") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("siruenyian/sqlgenerator-mini", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use siruenyian/sqlgenerator-mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "siruenyian/sqlgenerator-mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "siruenyian/sqlgenerator-mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/siruenyian/sqlgenerator-mini
- SGLang
How to use siruenyian/sqlgenerator-mini 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 "siruenyian/sqlgenerator-mini" \ --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": "siruenyian/sqlgenerator-mini", "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 "siruenyian/sqlgenerator-mini" \ --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": "siruenyian/sqlgenerator-mini", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use siruenyian/sqlgenerator-mini with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for siruenyian/sqlgenerator-mini to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for siruenyian/sqlgenerator-mini to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for siruenyian/sqlgenerator-mini to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="siruenyian/sqlgenerator-mini", max_seq_length=2048, ) - Docker Model Runner
How to use siruenyian/sqlgenerator-mini with Docker Model Runner:
docker model run hf.co/siruenyian/sqlgenerator-mini
Model Card for granite_sql (checkpoint-6000)
LoRA adapter fine-tuning IBM Granite 4.0 350M for text-to-SQL generation: given a
CREATE TABLE schema and a natural-language question, generate the corresponding SQL query.
Model Details
Model Description
This checkpoint (step 6000 of 6432, epoch 2.80/3) is the best-performing checkpoint of the run — lowest eval loss among all saved checkpoints (see Results).
- Model type: LoRA adapter (PEFT) on a causal LM
- Language(s): SQL (generation), English (instructions)
- License: Apache 2.0 (inherited from base model)
- Finetuned from model: unsloth/granite-4.0-350m-unsloth-bnb-4bit (IBM Granite 4.0, 350M, GraniteMoeHybrid)
How to Get Started with the Model
from unsloth import FastLanguageModel
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="/workspace/outputs/granite_sql_train/checkpoint-6000",
load_in_4bit=False,
device_map="cuda:0",
)
FastLanguageModel.for_inference(model)
instruction = """Generate ONLY the SQL query for the following database.
Do not explain your answer.
Do not include markdown.
Do not include any additional text.
Schema:
{schema}
Question:
{question}
SQL:"""
messages = [{"role": "user", "content": [{"type": "text", "text": instruction.format(schema=schema, question=question)}]}]
input_text = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(input_text, add_special_tokens=False, return_tensors="pt").to("cuda")
output = model.generate(**inputs, max_new_tokens=256, use_cache=True, temperature=0.7, top_p=0.8, top_k=20)
Training Details
Training Data
b-mc2/sql-create-context —
schema + natural-language-question + SQL-answer triples. Split via
train_test_split(test_size=10000, seed=42, shuffle=True): remaining rows for train, 10,000 held out for eval.
Training Procedure
LoRA (r=16, alpha=32, dropout=0, bias=none, no rslora) applied to
q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj, shared_mlp.input_linear, shared_mlp.output_linear,
trained with Unsloth + TRL SFTTrainer.
Training Hyperparameters
- Training regime: bf16 mixed precision
- Epochs: 3 | Per-device train batch size: 32 | Per-device eval batch size: 64 | Grad accumulation: 1
- Learning rate: 2e-4, linear schedule, 50 warmup steps
- Optimizer: adamw_8bit, weight decay 0.001, max grad norm 1.0
- Seed: 3407 | Eval every 200 steps | Save every 500 steps
Speeds, Sizes, Times
Full run: 6432 steps / 3 epochs, train_runtime ≈ 2567s. This adapter checkpoint: ~26.7MB (adapter_model.safetensors).
Evaluation
Testing Data & Metrics
10,000-row held-out split of b-mc2/sql-create-context (see Training Data), evaluated by SFT eval loss (cross-entropy) every 200 steps.
Results
| Checkpoint | Step | Eval loss |
|---|---|---|
| checkpoint-4000 | 4000 | 0.02830 |
| checkpoint-5000 | 5000 | 0.02811 |
| checkpoint-6000 | 6000 | 0.02673 (best saved) |
| checkpoint-6432 (final) | 6432 | ~0.02746 (nearest eval at step 6400) |
Lowest eval_loss observed during training was 0.02630 at step 5200, but no checkpoint was
saved at that exact step (checkpoints every 500 steps, eval every 200), so checkpoint-6000
is the closest usable minimum. load_best_model_at_end was not enabled, so this checkpoint
was selected manually by comparing eval_loss across saved checkpoints.
Compute Infrastructure
Hardware
- 1× NVIDIA A100 40GB
Software
- Unsloth
- Transformers
- PyTorch
Model Card Authors
- Yian
Contact
- Downloads last month
- -
Model tree for siruenyian/sqlgenerator-mini
Base model
ibm-granite/granite-4.0-350m-base