Model Information

This model is the reasoning model for Text2SQL task introduced in Think2SQL: Solving Text2SQL with Reasoning and Partial Scoring Rewards

This model is a fine-tuned version of Qwen/Qwen2.5-Coder-3B-Instruct on the anonymous-2321/bird dataset. It has been trained using TRL.

Quick start

The best model performance are given with its System and User prompt. The model is intended to use with three input: question, evidence and the database schema.

Starting with transformers >= 4.43.0 onward, you can run conversational inference using the Transformers pipeline abstraction or by leveraging the Auto classes with the generate() function.

Make sure to update your transformers installation via pip install --upgrade transformers.

import transformers
import torch
model_id = "anonymous-2321/Think2SQL-3B"
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])

Training procedure

This model was trained with GRPO, a method introduced in DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models.

Framework versions

  • TRL: 0.17.0.dev0
  • Transformers: 4.51.0
  • Pytorch: 2.5.1
  • Datasets: 3.5.0
  • Tokenizers: 0.21.1
Downloads last month
15
Safetensors
Model size
3.09B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for anonymous-2321/Think2SQL-3B

Base model

Qwen/Qwen2.5-3B
Finetuned
(36)
this model
Quantizations
2 models

Dataset used to train anonymous-2321/Think2SQL-3B