Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,38 @@
|
|
1 |
---
|
2 |
license: apache-2.0
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
pipeline_tag: text2text-generation
|
6 |
---
|
7 |
+
|
8 |
+
A text2sql T5 model, finetuned from Flan-t5-base. finetune code: [Link](https://github.com/kevinng77/chat-table-t5/blob/master/prompt.py)
|
9 |
+
|
10 |
+
## Inference Example:
|
11 |
+
|
12 |
+
|
13 |
+
```python
|
14 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration, pipeline
|
15 |
+
|
16 |
+
table_columns = "Transaction_ID, Platform, Product_ID, User_ID, Transaction_Amount, Region, Transaction_Time, Transaction_Unit, User_Comments"
|
17 |
+
|
18 |
+
table_name = "my_data"
|
19 |
+
|
20 |
+
PROMPT_INPUT = f"""
|
21 |
+
Given a SQL table named '{table_name}' with the following columns:
|
22 |
+
{table_columns}
|
23 |
+
|
24 |
+
Construct a SQL query to answer the following question:
|
25 |
+
Q: {{question}}.
|
26 |
+
"""
|
27 |
+
|
28 |
+
model_id = "kevinng77/chat-table-flan-t5"
|
29 |
+
tokenizer = T5Tokenizer.from_pretrained(model_id)
|
30 |
+
model = T5ForConditionalGeneration.from_pretrained(model_id)
|
31 |
+
|
32 |
+
input_text = PROMPT_INPUT.format_map({"question": "How many rows are there in the table?"})
|
33 |
+
|
34 |
+
pipe = pipeline(
|
35 |
+
"text2text-generation",
|
36 |
+
model=model, tokenizer=tokenizer, max_length=512
|
37 |
+
)
|
38 |
+
```
|