🚀 Think2SQL-7B
このモデルは、Text2SQLタスクの推論モデルで、Think2SQL: Reinforce LLM Reasoning Capabilities for Text2SQLで紹介されています。
🚀 クイックスタート
このモデルは、SystemとUserのプロンプトを用いることで最適な性能を発揮します。このモデルは、質問、証拠、データベーススキーマの3つの入力を使用することを想定しています。
transformers >= 4.43.0
以降では、Transformersの pipeline
抽象化を使用するか、generate()
関数を持つAutoクラスを利用して会話型推論を実行できます。
pip install --upgrade transformers
を実行して、transformersのインストールを更新してください。
基本的な使用法
import transformers
import torch
model_id = "simone-papicchio/Think2SQL-7B"
pipeline = transformers.pipeline(
"text-generation",
model=model_id,
model_kwargs={"torch_dtype": torch.bfloat16},
device_map="auto",
)
system_message = (
"You are a helpful AI Assistant that provides well-reasoned and detailed responses. "
"You first think about the reasoning process as an internal monologue and then provide the user with the answer. "
"Respond in the following format: <think>\n...\n</think>\n<answer>\n...\n</answer>"
).strip()
user_message = (
"Answer the following question with the SQL code. Use the piece of evidence and base your answer on the database schema. "
"Given the question, the evidence and the database schema, return in the <answer> tags only the SQL script that addresses the question.\n"
"Question:\n{question}\n\n"
"Evidence:\n{evidence}\n\n"
"Database Schema:\n{schema}\n\n"
"Return only the SQL script enclosed in <answer> tags."
).strip()
messages = [
{"role": "system", "content": system_message},
{"role": "user", "content": user_message},
]
outputs = pipeline(
messages,
max_new_tokens=30_000,
temperature=0.7,
top_p=0.95
)
print(outputs[0]["generated_text"][-1])
📚 ドキュメント
モデル情報
このモデルは、Think2SQL: Reinforce LLM Reasoning Capabilities for Text2SQL で紹介されたText2SQLタスクの推論モデルです。
このモデルは、Qwen/Qwen2.5-Coder-7B-Instruct を simone-papicchio/bird データセットでファインチューニングしたバージョンです。TRL を使用してトレーニングされています。
トレーニング手順

このモデルは、DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models で紹介されたGRPOという方法でトレーニングされています。
フレームワークのバージョン
Property |
Details |
TRL |
0.17.0.dev0 |
Transformers |
4.51.0 |
Pytorch |
2.5.1 |
Datasets |
3.5.0 |
Tokenizers |
0.21.1 |
引用
@misc{papicchio2025think2sqlreinforcellmreasoning,
title={Think2SQL: Reinforce LLM Reasoning Capabilities for Text2SQL},
author={Simone Papicchio and Simone Rossi and Luca Cagliero and Paolo Papotti},
year={2025},
eprint={2504.15077},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/2504.15077},
}
@inproceedings{papicchio2023qatch,
title={QATCH: benchmarking SQL-centric tasks with table representation learning models on your data},
author={Papicchio, Simone and Papotti, Paolo and Cagliero, Luca},
booktitle={Proceedings of the 37th International Conference on Neural Information Processing Systems},
pages={30898--30917},
year={2023}
}
📄 ライセンス
このモデルは、Apache-2.0ライセンスの下で提供されています。