AIJian commited on
Commit
0a16ea4
·
verified ·
1 Parent(s): 6362b1f

Update TrustSQL-8B model card

Browse files
Files changed (1) hide show
  1. README.md +64 -60
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
- - text2sql
9
- - sql
10
- - trustworthy
11
- - qwen3
 
 
 
12
  ---
13
 
14
- # TrustSQL-8B
15
 
16
  [![arXiv](https://img.shields.io/badge/arXiv-2603.16448-b31b1b.svg)](https://arxiv.org/abs/2603.16448)
17
  [![GitHub](https://img.shields.io/badge/GitHub-TrustSQL-black?logo=github)](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 the paper [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 via multi-turn reinforcement learning with tool integration, enabling accurate SQL generation over unknown database schemas.
23
 
24
- This model is part of the **TRUST-SQL** series, which focuses on building trustworthy Text-to-SQL systems capable of handling real-world scenarios where the database schema is not fully known in advance.
25
 
26
- ## Model Details
27
-
28
- | Attribute | Value |
29
- |-----------|-------|
30
- | Base Model | Qwen/Qwen3-8B |
31
- | Architecture | Qwen3ForCausalLM |
32
- | Parameters | 8.2B |
33
- | Hidden Size | 4096 |
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
- ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
 
48
- TrustSQL models are designed for **multi-turn, tool-integrated Text-to-SQL** over unknown schemas. The model explores the database schema via SQL tool calls before generating the final answer.
49
 
50
- For the full evaluation pipeline, rollout protocol, reward design, and training scripts, please refer to the GitHub repository:
51
 
52
- 👉 **[github.com/JaneEyre0530/TrustSQL](https://github.com/JaneEyre0530/TrustSQL)**
53
 
54
- ### Quick inference
 
 
 
 
 
 
 
55
 
56
  ```python
57
- from transformers import AutoTokenizer, AutoModelForCausalLM
58
- import torch
59
 
60
- model_name = "AIJian/TrustSQL-8B"
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
- messages = [{"role": "user", "content": "Your NL2SQL prompt here"}]
69
- text = tokenizer.apply_chat_template(
70
- messages,
71
- tokenize=False,
72
- add_generation_prompt=True,
73
- enable_thinking=False
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
- ## Training Data
82
 
83
- The model was trained on `all_models_training_data.jsonl`, a curated dataset of ~70k Text-to-SQL examples covering diverse database schemas and natural language questions. The training data includes multi-turn SQL generation scenarios with responses from multiple model sources (DeepSeek-R1, GPT-4o-mini, GPT-4.1-mini, etc.), ensuring broad coverage of SQL patterns and query complexity.
84
 
85
- ## Citation
86
 
87
- If you find TRUST-SQL useful in your research, please cite our paper:
88
 
89
  ```bibtex
90
- @misc{jian2026trustsqltoolintegratedmultiturnreinforcement,
91
- title={TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas},
92
- author={Ai Jian and Xiaoyun Zhang and Wanrou Du and Jingqing Ruan and Jiangbo Pei and Weipeng Zhang and Ke Zeng and Xunliang Cai},
93
- year={2026},
94
- eprint={2603.16448},
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 [LICENSE](LICENSE) file for details.
 
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
  [![arXiv](https://img.shields.io/badge/arXiv-2603.16448-b31b1b.svg)](https://arxiv.org/abs/2603.16448)
18
  [![GitHub](https://img.shields.io/badge/GitHub-TrustSQL-black?logo=github)](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.