CoolFace
Modelpublic

shoron07/qwen3-4b-spider-unsloth

sourceHugging Faceupdated 16d agoView on Hugging Face
0likes25downloads
Model Card

Qwen3-4B Spider Text-to-SQL - Unsloth QLoRA

A text-to-SQL adapter fine-tuned from unsloth/Qwen3-4B-unsloth-bnb-4bit using Unsloth-accelerated 4-bit QLoRA.

The model accepts a SQLite database schema and a natural-language question and generates a SQL query.

Evaluation Results

Evaluation used all 1,034 Spider validation examples. Training and validation databases were completely separated.

MetricBaseFine-tunedChange
Normalized exact match22.63%39.46%+16.83 points
SQL syntax validity99.61%100.00%+0.39 points
SQL-only compliance99.71%100.00%+0.29 points

Normalized exact match improved by approximately 74.4% relative over the untouched base model.

The reported exact match is a strict SQLGlot-normalized metric, not execution accuracy. Semantically equivalent queries may still be counted as different.

Training Configuration

SettingValue
FrameworkUnsloth
Method4-bit QLoRA
LoRA rank / alpha16 / 32
Trainable parameters33,030,144 (0.81%)
Training examples8,555
Validation examples1,034
Maximum sequence length2,048
Training steps100
Effective batch size8
Learning rate2e-4
OptimizerAdamW 8-bit
PrecisionFP16
Training time18.15 minutes
Peak training GPU memory4.77 GB
HardwareSingle Tesla T4

This was a compact 100-step portfolio experiment and did not complete a full training epoch.

Dataset Preparation

  • —Database-level train-validation separation
  • —Zero overlapping databases between splits
  • —Missing-value and duplicate validation
  • —Eight exact training duplicates removed
  • —Qwen3 conversational formatting
  • —Response-only assistant training
  • —Token-length auditing
  • —96 overlength training examples removed

Example

Input

text
Schema: CREATE TABLE singer (name TEXT, age INTEGER);
Question: How many singers are older than 30?

Output

sql
SELECT COUNT(*) FROM singer WHERE age > 30

Intended Use

  • —Text-to-SQL demonstrations
  • —SQLite query-generation experiments
  • —Parameter-efficient fine-tuning examples
  • —Unsloth and QLoRA workflow demonstrations

Limitations

  • —The adapter was trained for only 100 steps.
  • —Evaluation used normalized exact match, not execution accuracy.
  • —Syntactically valid SQL may still be logically incorrect.
  • —Performance outside English Spider-style SQLite tasks is unknown.
  • —Queries should be validated before database execution.

Artifacts

The results directory contains the training history, evaluation summary, comparison metrics, and project summary.

Acknowledgements

Built with Qwen3, Unsloth, Hugging Face PEFT, TRL, the Spider benchmark, and SQLGlot.