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)# pip install -U transformers accelerate # 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=256) 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
|
Download README.md from AIJian/TrustSQL-8B: direct link, hf CLI and curl.
- Browser
- Download file 3.68 kB
-
https://huggingface.co/AIJian/TrustSQL-8B/resolve/main/README.md
- Command line
-
hf download hf://AIJian/TrustSQL-8B/README.md
-
curl -L -o README.md https://huggingface.co/AIJian/TrustSQL-8B/resolve/main/README.md
3.68 kB
| license: apache-2.0 | |
| library_name: transformers | |
| pipeline_tag: text-generation | |
| tags: | |
| - text-to-sql | |
| - sql | |
| - unknown-schema | |
| - tool-use | |
| - reinforcement-learning | |
| - qwen3 | |
| base_model: Qwen/Qwen3-8B | |
| # TRUST-SQL-8B | |
| [](https://arxiv.org/abs/2603.16448) | |
| [](https://github.com/JaneEyre0530/TrustSQL) | |
| [](LICENSE) | |
| ## Overview | |
| **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. | |
| ## Model details | |
| - Base model: `Qwen/Qwen3-8B` | |
| - Architecture: `Qwen3ForCausalLM` | |
| - Parameters: 8.2B | |
| - Hidden size: 4096 | |
| - Layers: 36 | |
| - Attention heads: 32 Q heads / 8 KV heads | |
| - Context length: 40,960 tokens | |
| - Precision: bfloat16 | |
| ## Models | |
| | Model | Base | Link | | |
| |---|---|---| | |
| | TrustSQL-4B | Qwen3-4B | [AIJian/TrustSQL-4B](https://huggingface.co/AIJian/TrustSQL-4B) | | |
| | TrustSQL-8B | Qwen3-8B | [AIJian/TrustSQL-8B](https://huggingface.co/AIJian/TrustSQL-8B) | | |
| ## Training | |
| TrustSQL follows a two-stage training pipeline: SFT warm-up followed by Phase-Aware GRPO optimization. The interaction protocol is `Explore → Propose → Generate → Confirm`. | |
| ## Reported results | |
| All results are reported under the Unknown Schema setting. | |
| | Benchmark | Greedy | Majority voting | | |
| |---|---:|---:| | |
| | BIRD-Dev | 65.8 | 67.7 | | |
| | Spider-Test | 83.9 | 86.5 | | |
| | Spider-DK | 72.1 | 75.7 | | |
| | Spider-Syn | 75.4 | 77.4 | | |
| | Spider-Realistic | 82.1 | 84.1 | | |
| The model reaches 65.8 EX on BIRD-Dev with greedy decoding and 67.7 EX with majority voting. | |
| ## Recommended inference setup | |
| This model is intended to run inside a tool-using agent loop: | |
| 1. Explore database metadata and inspect relevant values. | |
| 2. Propose only tables and columns verified by tool output. | |
| 3. Generate and execute a candidate SQL query. | |
| 4. Confirm the final answer, or return to exploration when evidence is insufficient. | |
| The explicit proposal checkpoint is important: it helps prevent schema hallucination and provides a boundary for the phase-aware training objective. | |
| ## Loading | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| model_id = "AIJian/TrustSQL-8B" | |
| tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True) | |
| model = AutoModelForCausalLM.from_pretrained( | |
| model_id, | |
| torch_dtype="auto", | |
| device_map="auto", | |
| trust_remote_code=True, | |
| ) | |
| ``` | |
| For prompts, tool schemas, evaluation scripts, and training details, see `https://github.com/JaneEyre0530/TrustSQL`. | |
| ## Limitations | |
| 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. | |
| ## Citation | |
| ```bibtex | |
| @article{jian2026trustsql, | |
| title = {TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas}, | |
| author = {Jian, Ai and Zhang, Xiaoyun and Du, Wanrou and Ruan, Jingqing and Pei, Jiangbo and Zhang, Weipeng and Zeng, Ke and Cai, Xunliang}, | |
| journal = {arXiv preprint arXiv:2603.16448}, | |
| year = {2026} | |
| } | |
| ``` | |
| ## License | |
| This project is licensed under the Apache 2.0 License. See the `LICENSE` file for details. | |