Instructions to use x32/spider-rl-qwen3-4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- MLX
How to use x32/spider-rl-qwen3-4b with MLX:
# Make sure mlx-lm is installed # pip install --upgrade mlx-lm # if on a CUDA device, also pip install mlx[cuda] # Generate text with mlx-lm from mlx_lm import load, generate model, tokenizer = load("x32/spider-rl-qwen3-4b") prompt = "Once upon a time in" text = generate(model, tokenizer, prompt=prompt, verbose=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- LM Studio
- MLX LM
How to use x32/spider-rl-qwen3-4b with MLX LM:
Generate or start a chat session
# Install MLX LM uv tool install mlx-lm # Generate some text mlx_lm.generate --model "x32/spider-rl-qwen3-4b" --prompt "Once upon a time"
spider-rl-qwen3-4b
LoRA adapter trained with GiGPO on Yale Spider 1.0 text-to-SQL benchmark, on top of Qwen/Qwen3-4B-Instruct-2507 (4-bit MLX quantization). Trained on a single Apple Silicon Mac in ~10 hours.
This is the v4 checkpoint โ recommended overall configuration. Two other variants (v7 with 2ร LoRA capacity, v9b with entropy bonus) are documented in the paper.
Results
Greedy decoding (temperature=0), evaluated against gold result-sets via SQLite execution.
| Metric | Baseline | This adapter | ฮ |
|---|---|---|---|
| Dev EX (n=1034) | 44.0% | 51.6% | +7.6pp |
| Test EX (n=128) | 50.0% | 55.5% | +5.5pp |
| answered rate | 90.3% | 98.6% | +8.3pp |
| avg steps/episode | 2.54 | 1.97 | -22% |
Per-hardness on dev (n=1034):
| Bucket | Baseline | v4 |
|---|---|---|
| easy (248) | 60.1% | 70.2% |
| medium (446) | 50.0% | 61.7% |
| hard (174) | 31.0% | 28.7% |
| extra (166) | 17.5% | 21.1% |
Usage
This is a custom MLX-format LoRA delta loaded via the mlx-agent-rl framework, not a PEFT adapter. Standard peft.PeftModel.from_pretrained() will not work.
# git clone github.com/johnhaofu/mlx-agent-rl
from mlx_agent_rl.core.policy import Policy
from huggingface_hub import snapshot_download
adapter_path = snapshot_download(repo_id="x32/spider-rl-qwen3-4b")
policy = Policy(
model_path="Qwen/Qwen3-4B-Instruct-2507", # or local Qwen3-4B-MLX-4bit
lora_rank=8,
lora_layers=4,
)
policy.load_adapters(adapter_path)
The agent expects multi-turn rollouts with <action>sql[โฆ]</action> for exploration and <action>answer[final SELECT]</action> to commit. See the training script for the full prompt template.
Training recipe
| Setting | Value |
|---|---|
| Algorithm | GiGPO (mean-norm advantages) |
| Base model | Qwen3-4B-Instruct-2507 (MLX 4-bit) |
| LoRA | rank=8, last 4 transformer layers |
| Trainable params | ~10M (0.25% of base) |
| Learning rate | 5e-5 |
| KL coefficient | 0 (no anchor) |
| Reward | binary 1.0 / 0.0 (no partial credit) |
| Group size | 8 trajectories per prompt |
| Epochs | 2 over n=300 train questions |
| Wall time | ~10h on M-series Mac |
Counter-intuitive findings (from the full ablation)
- Partial-credit reward hurts vs strict binary โ agents settle for syntactically valid mediocrity. Removing partial credit gave +9.3pp on medium queries.
- KL anchor at 0.001 doesn't lift overall EX, only redistributes across hardness buckets.
- Scaling training data from n=300 to 600 regressed at fixed compute.
- 87% of GiGPO groups had zero reward variance โ the real bottleneck.
Full ablation across 9 experiments: paper on GitHub.
Limitations
- Trained on 4-bit MLX quantized base โ direct comparison to fp16/bf16 baselines requires re-quantization
- Single-seed training (no variance estimates)
- Far below GPT-4-class systems (DAIL-SQL+GPT-4 reaches 86% test EX) โ this adapter targets the compute-constrained / on-device deployment niche
extrahardness bucket (multi-table joins, INTERSECT/EXCEPT) sees minimal lift; capacity ceiling
Code
github.com/johnhaofu/mlx-agent-rl โ MLX-native multi-turn agent RL framework, MIT-licensed.
License
MIT
Quantized
Model tree for x32/spider-rl-qwen3-4b
Base model
Qwen/Qwen3-4B-Instruct-2507Dataset used to train x32/spider-rl-qwen3-4b
Evaluation results
- EX (n=1034 greedy) on Spider 1.0 devself-reported51.600
- answered rate on Spider 1.0 devself-reported98.600
- EX (n=128 greedy) on Spider 1.0 testself-reported55.500