AIJian commited on
Commit
b98218e
·
verified ·
1 Parent(s): c383227

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +12 -30
README.md CHANGED
@@ -45,6 +45,14 @@ This model is part of the **TRUST-SQL** series, which focuses on building trustw
45
 
46
  ## Usage
47
 
 
 
 
 
 
 
 
 
48
  ```python
49
  from transformers import AutoTokenizer, AutoModelForCausalLM
50
  import torch
@@ -57,42 +65,16 @@ model = AutoModelForCausalLM.from_pretrained(
57
  device_map="auto"
58
  )
59
 
60
- # Example: Text-to-SQL generation
61
- schema = """
62
- CREATE TABLE employees (
63
- id INT PRIMARY KEY,
64
- name VARCHAR(100),
65
- department VARCHAR(50),
66
- salary DECIMAL(10,2)
67
- );
68
- """
69
-
70
- question = "What is the average salary of employees in the Engineering department?"
71
-
72
- prompt = f"""Given the following database schema:
73
- {schema}
74
-
75
- Generate a SQL query to answer the question: {question}"""
76
-
77
- messages = [{"role": "user", "content": prompt}]
78
  text = tokenizer.apply_chat_template(
79
  messages,
80
  tokenize=False,
81
  add_generation_prompt=True,
82
- enable_thinking=False # Set to True for complex queries requiring reasoning
83
  )
84
-
85
  inputs = tokenizer([text], return_tensors="pt").to(model.device)
86
- outputs = model.generate(
87
- **inputs,
88
- max_new_tokens=512,
89
- temperature=0.7,
90
- top_p=0.9,
91
- )
92
- response = tokenizer.decode(
93
- outputs[0][inputs["input_ids"].shape[1]:],
94
- skip_special_tokens=True
95
- )
96
  print(response)
97
  ```
98
 
 
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
 
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