dbernsohn commited on
Commit
61eeb77
·
1 Parent(s): 20e1559

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +34 -0
README.md ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # t5_wikisql_en2SQL
2
+ ---
3
+ language: en
4
+ datasets:
5
+ - wikisql
6
+ ---
7
+
8
+ This is a [t5-small](https://ai.googleblog.com/2020/02/exploring-transfer-learning-with-t5.html) fine-tuned version on the [wikisql dataset](https://huggingface.co/datasets/wikisql) for **English** to **SQL** **translation** text2text mission.
9
+
10
+ To load the model:
11
+ (necessary packages: !pip install transformers sentencepiece)
12
+ ```python
13
+ from transformers import AutoTokenizer, AutoModelWithLMHead
14
+ tokenizer = AutoTokenizer.from_pretrained("dbernsohn/t5_wikisql_en2SQL")
15
+ model = AutoModelWithLMHead.from_pretrained("dbernsohn/t5_wikisql_en2SQL")
16
+ ```
17
+
18
+ You can then use this model to translate SQL queries into plain english.
19
+
20
+ ```python
21
+ query = "what is the name of all the people in the USA?"
22
+ input_text = f"translate English to Sql: {query} </s>"
23
+ features = tokenizer([input_text], return_tensors='pt')
24
+
25
+ output = model.generate(input_ids=features['input_ids'].cuda(),
26
+ attention_mask=features['attention_mask'].cuda())
27
+
28
+ tokenizer.decode(output[0])
29
+ ```
30
+ Output: "SELECT Name FROM table WHERE Country = USA"
31
+
32
+ The whole training process and hyperparameters are in my [GitHub repo](https://github.com/DorBernsohn/SQLM)
33
+
34
+ > Created by [Dor Bernsohn](https://www.linkedin.com/in/dor-bernsohn-70b2b1146/)