Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,83 @@
|
|
1 |
-
---
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model: Qwen/Qwen2.5-Coder-3B-Instruct
|
3 |
+
datasets: anonymous-2321/bird
|
4 |
+
library_name: transformers
|
5 |
+
tags:
|
6 |
+
- generated_from_trainer
|
7 |
+
- open-r1
|
8 |
+
- Text2SQL
|
9 |
+
- Reasoning
|
10 |
+
licence: apache-2.0
|
11 |
+
---
|
12 |
+
|
13 |
+
# Model Information
|
14 |
+
|
15 |
+
This model is the reasoning model for Text2SQL task introduced in [Think2SQL: Solving Text2SQL with Reasoning and Partial Scoring Rewards]()
|
16 |
+
|
17 |
+
|
18 |
+
This model is a fine-tuned version of [Qwen/Qwen2.5-Coder-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-Coder-3B-Instruct) on the [anonymous-2321/bird](https://huggingface.co/datasets/anonymous-2321/bird) dataset.
|
19 |
+
It has been trained using [TRL](https://github.com/huggingface/trl).
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
## Quick start
|
24 |
+
|
25 |
+
The best model performance are given with its System and User prompt.
|
26 |
+
The model is intended to use with three input: question, evidence and the database schema.
|
27 |
+
|
28 |
+
|
29 |
+
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.
|
30 |
+
|
31 |
+
Make sure to update your transformers installation via `pip install --upgrade transformers`.
|
32 |
+
|
33 |
+
```python
|
34 |
+
import transformers
|
35 |
+
import torch
|
36 |
+
model_id = "anonymous-2321/Think2SQL-3B"
|
37 |
+
pipeline = transformers.pipeline(
|
38 |
+
"text-generation",
|
39 |
+
model=model_id,
|
40 |
+
model_kwargs={"torch_dtype": torch.bfloat16},
|
41 |
+
device_map="auto",
|
42 |
+
)
|
43 |
+
|
44 |
+
system_message = (
|
45 |
+
"You are a helpful AI Assistant that provides well-reasoned and detailed responses. "
|
46 |
+
"You first think about the reasoning process as an internal monologue and then provide the user with the answer. "
|
47 |
+
"Respond in the following format: <think>\n...\n</think>\n<answer>\n...\n</answer>"
|
48 |
+
).strip()
|
49 |
+
|
50 |
+
user_message = (
|
51 |
+
"Answer the following question with the SQL code. Use the piece of evidence and base your answer on the database schema. "
|
52 |
+
"Given the question, the evidence and the database schema, return in the <answer> tags only the SQL script that addresses the question.\n"
|
53 |
+
"Question:\n{question}\n\n"
|
54 |
+
"Evidence:\n{evidence}\n\n"
|
55 |
+
"Database Schema:\n{schema}\n\n"
|
56 |
+
"Return only the SQL script enclosed in <answer> tags."
|
57 |
+
).strip()
|
58 |
+
|
59 |
+
messages = [
|
60 |
+
{"role": "system", "content": system_message},
|
61 |
+
{"role": "user", "content": user_message},
|
62 |
+
]
|
63 |
+
|
64 |
+
outputs = pipeline(
|
65 |
+
messages,
|
66 |
+
max_new_tokens=30_000,
|
67 |
+
temperature=0.7,
|
68 |
+
top_p=0.95
|
69 |
+
)
|
70 |
+
print(outputs[0]["generated_text"][-1])
|
71 |
+
```
|
72 |
+
|
73 |
+
## Training procedure
|
74 |
+
|
75 |
+
This model was trained with GRPO, a method introduced in [DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models](https://huggingface.co/papers/2402.03300).
|
76 |
+
|
77 |
+
### Framework versions
|
78 |
+
|
79 |
+
- TRL: 0.17.0.dev0
|
80 |
+
- Transformers: 4.51.0
|
81 |
+
- Pytorch: 2.5.1
|
82 |
+
- Datasets: 3.5.0
|
83 |
+
- Tokenizers: 0.21.1
|