Text Generation
Transformers
Safetensors
qwen3
text-to-sql
sql
unknown-schema
tool-use
reinforcement-learning
conversational
text-generation-inference
Instructions to use AIJian/TrustSQL-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AIJian/TrustSQL-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AIJian/TrustSQL-8B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AIJian/TrustSQL-8B") model = AutoModelForCausalLM.from_pretrained("AIJian/TrustSQL-8B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AIJian/TrustSQL-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AIJian/TrustSQL-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AIJian/TrustSQL-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AIJian/TrustSQL-8B
- SGLang
How to use AIJian/TrustSQL-8B 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 "AIJian/TrustSQL-8B" \ --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": "AIJian/TrustSQL-8B", "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 "AIJian/TrustSQL-8B" \ --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": "AIJian/TrustSQL-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AIJian/TrustSQL-8B with Docker Model Runner:
docker model run hf.co/AIJian/TrustSQL-8B
Update TrustSQL-8B model card
Browse files
README.md
CHANGED
|
@@ -1,17 +1,18 @@
|
|
| 1 |
---
|
| 2 |
-
library_name: transformers
|
| 3 |
license: apache-2.0
|
|
|
|
| 4 |
pipeline_tag: text-generation
|
| 5 |
-
base_model:
|
| 6 |
-
- Qwen/Qwen3-8B
|
| 7 |
tags:
|
| 8 |
-
-
|
| 9 |
-
- sql
|
| 10 |
-
-
|
| 11 |
-
-
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
| 15 |
|
| 16 |
[](https://arxiv.org/abs/2603.16448)
|
| 17 |
[](https://github.com/JaneEyre0530/TrustSQL)
|
|
@@ -19,85 +20,88 @@ tags:
|
|
| 19 |
|
| 20 |
## Overview
|
| 21 |
|
| 22 |
-
**TrustSQL-8B** is a fine-tuned Text-to-SQL model based on [Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B), introduced in
|
| 23 |
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
| Layers | 36 |
|
| 35 |
-
| Attention Heads | 32 (Q) / 8 (KV, GQA) |
|
| 36 |
-
| Context Length | 40,960 tokens |
|
| 37 |
-
| Precision | bfloat16 |
|
| 38 |
|
| 39 |
## Models
|
| 40 |
|
| 41 |
| Model | Base | Link |
|
| 42 |
-
|---
|
| 43 |
| TrustSQL-4B | Qwen3-4B | [AIJian/TrustSQL-4B](https://huggingface.co/AIJian/TrustSQL-4B) |
|
| 44 |
| TrustSQL-8B | Qwen3-8B | [AIJian/TrustSQL-8B](https://huggingface.co/AIJian/TrustSQL-8B) |
|
| 45 |
|
| 46 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
```python
|
| 57 |
-
from transformers import
|
| 58 |
-
import torch
|
| 59 |
|
| 60 |
-
|
| 61 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 62 |
-
model = AutoModelForCausalLM.from_pretrained(
|
| 63 |
-
model_name,
|
| 64 |
-
torch_dtype=torch.bfloat16,
|
| 65 |
-
device_map="auto"
|
| 66 |
-
)
|
| 67 |
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
)
|
| 75 |
-
inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 76 |
-
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 77 |
-
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
|
| 78 |
-
print(response)
|
| 79 |
```
|
| 80 |
|
| 81 |
-
|
| 82 |
|
| 83 |
-
|
| 84 |
|
| 85 |
-
|
| 86 |
|
| 87 |
-
|
| 88 |
|
| 89 |
```bibtex
|
| 90 |
-
@
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
archivePrefix={arXiv},
|
| 96 |
-
primaryClass={cs.AI},
|
| 97 |
-
url={https://arxiv.org/abs/2603.16448},
|
| 98 |
}
|
| 99 |
```
|
| 100 |
|
| 101 |
## License
|
| 102 |
|
| 103 |
-
This project is licensed under the Apache 2.0 License. See the
|
|
|
|
| 1 |
---
|
|
|
|
| 2 |
license: apache-2.0
|
| 3 |
+
library_name: transformers
|
| 4 |
pipeline_tag: text-generation
|
|
|
|
|
|
|
| 5 |
tags:
|
| 6 |
+
- text-to-sql
|
| 7 |
+
- sql
|
| 8 |
+
- unknown-schema
|
| 9 |
+
- tool-use
|
| 10 |
+
- reinforcement-learning
|
| 11 |
+
- qwen3
|
| 12 |
+
base_model: Qwen/Qwen3-8B
|
| 13 |
---
|
| 14 |
|
| 15 |
+
# TRUST-SQL-8B
|
| 16 |
|
| 17 |
[](https://arxiv.org/abs/2603.16448)
|
| 18 |
[](https://github.com/JaneEyre0530/TrustSQL)
|
|
|
|
| 20 |
|
| 21 |
## Overview
|
| 22 |
|
| 23 |
+
**TrustSQL-8B** is a fine-tuned Text-to-SQL model based on [Qwen3-8B](https://huggingface.co/Qwen/Qwen3-8B), introduced in [TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas](https://arxiv.org/abs/2603.16448). The model is trained with multi-turn reinforcement learning and tool integration for Text-to-SQL over unknown database schemas.
|
| 24 |
|
| 25 |
+
## Model details
|
| 26 |
|
| 27 |
+
- Base model: `Qwen/Qwen3-8B`
|
| 28 |
+
- Architecture: `Qwen3ForCausalLM`
|
| 29 |
+
- Parameters: 8.2B
|
| 30 |
+
- Hidden size: 4096
|
| 31 |
+
- Layers: 36
|
| 32 |
+
- Attention heads: 32 Q heads / 8 KV heads
|
| 33 |
+
- Context length: 40,960 tokens
|
| 34 |
+
- Precision: bfloat16
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
| 36 |
## Models
|
| 37 |
|
| 38 |
| Model | Base | Link |
|
| 39 |
+
|---|---|---|
|
| 40 |
| TrustSQL-4B | Qwen3-4B | [AIJian/TrustSQL-4B](https://huggingface.co/AIJian/TrustSQL-4B) |
|
| 41 |
| TrustSQL-8B | Qwen3-8B | [AIJian/TrustSQL-8B](https://huggingface.co/AIJian/TrustSQL-8B) |
|
| 42 |
|
| 43 |
+
## Training
|
| 44 |
+
|
| 45 |
+
TrustSQL follows a two-stage training pipeline: SFT warm-up followed by Phase-Aware GRPO optimization. The interaction protocol is `Explore → Propose → Generate → Confirm`.
|
| 46 |
+
|
| 47 |
+
## Reported results
|
| 48 |
+
|
| 49 |
+
All results are reported under the Unknown Schema setting.
|
| 50 |
+
|
| 51 |
+
| Benchmark | Greedy | Majority voting |
|
| 52 |
+
|---|---:|---:|
|
| 53 |
+
| BIRD-Dev | 65.8 | 67.7 |
|
| 54 |
+
| Spider-Test | 83.9 | 86.5 |
|
| 55 |
+
| Spider-DK | 72.1 | 75.7 |
|
| 56 |
+
| Spider-Syn | 75.4 | 77.4 |
|
| 57 |
+
| Spider-Realistic | 82.1 | 84.1 |
|
| 58 |
|
| 59 |
+
The model reaches 65.8 EX on BIRD-Dev with greedy decoding and 67.7 EX with majority voting.
|
| 60 |
|
| 61 |
+
## Recommended inference setup
|
| 62 |
|
| 63 |
+
This model is intended to run inside a tool-using agent loop:
|
| 64 |
|
| 65 |
+
1. Explore database metadata and inspect relevant values.
|
| 66 |
+
2. Propose only tables and columns verified by tool output.
|
| 67 |
+
3. Generate and execute a candidate SQL query.
|
| 68 |
+
4. Confirm the final answer, or return to exploration when evidence is insufficient.
|
| 69 |
+
|
| 70 |
+
The explicit proposal checkpoint is important: it helps prevent schema hallucination and provides a boundary for the phase-aware training objective.
|
| 71 |
+
|
| 72 |
+
## Loading
|
| 73 |
|
| 74 |
```python
|
| 75 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
|
|
| 76 |
|
| 77 |
+
model_id = "AIJian/TrustSQL-8B"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
| 80 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 81 |
+
model_id,
|
| 82 |
+
torch_dtype="auto",
|
| 83 |
+
device_map="auto",
|
| 84 |
+
trust_remote_code=True,
|
| 85 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
```
|
| 87 |
|
| 88 |
+
For prompts, tool schemas, evaluation scripts, and training details, see `https://github.com/JaneEyre0530/TrustSQL`.
|
| 89 |
|
| 90 |
+
## Limitations
|
| 91 |
|
| 92 |
+
This checkpoint was trained and evaluated with SQLite-based benchmarks. Inference requires a live and safe metadata/execution environment. Always validate generated SQL and use read-only permissions unless write access is explicitly required and controlled.
|
| 93 |
|
| 94 |
+
## Citation
|
| 95 |
|
| 96 |
```bibtex
|
| 97 |
+
@article{jian2026trustsql,
|
| 98 |
+
title = {TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas},
|
| 99 |
+
author = {Jian, Ai and Zhang, Xiaoyun and Du, Wanrou and Ruan, Jingqing and Pei, Jiangbo and Zhang, Weipeng and Zeng, Ke and Cai, Xunliang},
|
| 100 |
+
journal = {arXiv preprint arXiv:2603.16448},
|
| 101 |
+
year = {2026}
|
|
|
|
|
|
|
|
|
|
| 102 |
}
|
| 103 |
```
|
| 104 |
|
| 105 |
## License
|
| 106 |
|
| 107 |
+
This project is licensed under the Apache 2.0 License. See the `LICENSE` file for details.
|