kubwa(LoudAI)
commited on
Commit
•
333eadc
1
Parent(s):
4a8a7fb
Update README.md
Browse files
README.md
CHANGED
@@ -35,18 +35,17 @@ This model is a fine-tuned version of mistralai/Mistral-7B-Instruct-v0.3. https:
|
|
35 |
### Context:
|
36 |
{schema}
|
37 |
|
38 |
-
### Response
|
39 |
```
|
40 |
|
41 |
## How to Use it
|
42 |
|
43 |
```python
|
44 |
-
from transformers import AutoTokenizer
|
45 |
-
from transformers import AutoModelForCausalLM
|
46 |
import torch
|
47 |
|
48 |
-
model = AutoModelForCausalLM.from_pretrained("kubwa/Mistral-7B-Instruct-SQL-ian"
|
49 |
-
tokenizer = AutoTokenizer.from_pretrained("kubwa/Mistral-7B-Instruct-SQL-ian",
|
50 |
|
51 |
text = """<s>
|
52 |
### Instruction:
|
@@ -55,45 +54,32 @@ What is the total volume of timber sold by each salesperson, sorted by salespers
|
|
55 |
### Context:
|
56 |
CREATE TABLE salesperson (salesperson_id INT, name TEXT, region TEXT); INSERT INTO salesperson (salesperson_id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE timber_sales (sales_id INT, salesperson_id INT, volume REAL, sale_date DATE); INSERT INTO timber_sales (sales_id, salesperson_id, volume, sale_date) VALUES (1, 1, 120, '2021-01-01'), (2, 1, 150, '2021-02-01'), (3, 2, 180, '2021-01-01');
|
57 |
|
58 |
-
### Response
|
59 |
"""
|
|
|
60 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
61 |
-
|
|
|
|
|
|
|
62 |
|
63 |
outputs = model.generate(**inputs, max_new_tokens=300, pad_token_id=tokenizer.eos_token_id)
|
|
|
64 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
|
|
65 |
```
|
66 |
|
67 |
## Example Output
|
68 |
|
69 |
```
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
```sql
|
80 |
-
SELECT salesperson_id, name, SUM(volume) as total_volume
|
81 |
-
FROM timber_sales
|
82 |
-
JOIN salesperson ON timber_sales.salesperson_id = salesperson.salesperson_id
|
83 |
-
GROUP BY salesperson_id, name
|
84 |
-
ORDER BY total_volume DESC;
|
85 |
-
```
|
86 |
-
|
87 |
-
This query will return the following result:
|
88 |
-
|
89 |
-
```
|
90 |
-
salesperson_id | name | total_volume
|
91 |
-
--------------+------------+---------------
|
92 |
-
1 | John Doe | 270
|
93 |
-
2 | Jane Smith | 180
|
94 |
-
```
|
95 |
-
|
96 |
-
This result shows that John Doe sold a total of 270 cubic units of timber, while Jane Smith sold 180 cubic units. The result is sorted by the total volume in descending order.
|
97 |
```
|
98 |
|
99 |
## Hardware and Software
|
|
|
35 |
### Context:
|
36 |
{schema}
|
37 |
|
38 |
+
### Response:
|
39 |
```
|
40 |
|
41 |
## How to Use it
|
42 |
|
43 |
```python
|
44 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
45 |
import torch
|
46 |
|
47 |
+
model = AutoModelForCausalLM.from_pretrained("kubwa/Mistral-7B-Instruct-SQL-ian")
|
48 |
+
tokenizer = AutoTokenizer.from_pretrained("kubwa/Mistral-7B-Instruct-SQL-ian",use_fast=False)
|
49 |
|
50 |
text = """<s>
|
51 |
### Instruction:
|
|
|
54 |
### Context:
|
55 |
CREATE TABLE salesperson (salesperson_id INT, name TEXT, region TEXT); INSERT INTO salesperson (salesperson_id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE timber_sales (sales_id INT, salesperson_id INT, volume REAL, sale_date DATE); INSERT INTO timber_sales (sales_id, salesperson_id, volume, sale_date) VALUES (1, 1, 120, '2021-01-01'), (2, 1, 150, '2021-02-01'), (3, 2, 180, '2021-01-01');
|
56 |
|
57 |
+
### Response:
|
58 |
"""
|
59 |
+
|
60 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
61 |
+
model.to(device)
|
62 |
+
|
63 |
+
inputs = tokenizer(text, return_tensors="pt")
|
64 |
+
inputs = {key: value.to(device) for key, value in inputs.items()}
|
65 |
|
66 |
outputs = model.generate(**inputs, max_new_tokens=300, pad_token_id=tokenizer.eos_token_id)
|
67 |
+
|
68 |
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
69 |
+
|
70 |
```
|
71 |
|
72 |
## Example Output
|
73 |
|
74 |
```
|
75 |
+
### Instruction:
|
76 |
+
What is the total volume of timber sold by each salesperson, sorted by salesperson?
|
77 |
+
|
78 |
+
### Context:
|
79 |
+
CREATE TABLE salesperson (salesperson_id INT, name TEXT, region TEXT); INSERT INTO salesperson (salesperson_id, name, region) VALUES (1, 'John Doe', 'North'), (2, 'Jane Smith', 'South'); CREATE TABLE timber_sales (sales_id INT, salesperson_id INT, volume REAL, sale_date DATE); INSERT INTO timber_sales (sales_id, salesperson_id, volume, sale_date) VALUES (1, 1, 120, '2021-01-01'), (2, 1, 150, '2021-02-01'), (3, 2, 180, '2021-01-01');
|
80 |
+
|
81 |
+
### Response:
|
82 |
+
SELECT salesperson.name, SUM(timber_sales.volume) as total_volume FROM salesperson JOIN timber_sales ON salesperson.salesperson_id = timber_sales.salesperson_id GROUP BY salesperson.name ORDER BY total_volume DESC;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
```
|
84 |
|
85 |
## Hardware and Software
|