JacksonLark
commited on
Commit
•
922603b
1
Parent(s):
b8ff058
Update README.md
Browse files
README.md
CHANGED
@@ -7,4 +7,22 @@ language:
|
|
7 |
pipeline_tag: text2text-generation
|
8 |
tags:
|
9 |
- nl2sql
|
10 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
pipeline_tag: text2text-generation
|
8 |
tags:
|
9 |
- nl2sql
|
10 |
+
---
|
11 |
+
|
12 |
+
# How to Use
|
13 |
+
|
14 |
+
```
|
15 |
+
import torch
|
16 |
+
from transformers import T5ForConditionalGeneration, AutoTokenizer
|
17 |
+
|
18 |
+
device = torch.device("cuda:0")
|
19 |
+
|
20 |
+
tokenizer = AutoTokenizer.from_pretrained("LarkAI/codet5p-770m_nl2sql_oig")
|
21 |
+
model = T5ForConditionalGeneration.from_pretrained("LarkAI/codet5p-770m_nl2sql_oig").to(device)
|
22 |
+
|
23 |
+
text = "Given the following schema:\nroad (road_name, state_name)\nstate (state_name, capital, population, area, country_name, density)\nhighlow (state_name, highest_point, highest_elevation, lowest_point, lowest_elevation)\nlake (lake_name, area, state_name, country_name)\nriver (river_name, length, traverse, country_name)\nborder_info (state_name, border)\nmountain (mountain_name, mountain_altitude, state_name, country_name)\ncity (city_name, state_name, population, country_name)\nWrite a SQL query to what states does the mississippi river run throug"
|
24 |
+
inputs = tokenizer.encode(text, return_tensors="pt").to(device)
|
25 |
+
output_ids = model.generate(inputs, max_length=512)
|
26 |
+
response_text = self.tokenizer.decode(outputs[0], skip_special_tokens=True)
|
27 |
+
# SELECT traverse FROM river WHERE river_name = \"mississippi\" ;
|
28 |
+
```
|