Update README.md
Browse files
README.md
CHANGED
|
@@ -20,13 +20,35 @@ pip install torch==2.2.2
|
|
| 20 |
|
| 21 |
## Usage
|
| 22 |
|
| 23 |
-
|
| 24 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
```
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
| 28 |
```
|
| 29 |
|
| 30 |
-
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
```
|
|
|
|
| 20 |
|
| 21 |
## Usage
|
| 22 |
|
| 23 |
+
Please exercise caution when formatting the input.
|
| 24 |
|
| 25 |
+
```python
|
| 26 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 27 |
+
|
| 28 |
+
tokenizer = AutoTokenizer.from_pretrained("alpecevit/flan-t5-base-text2sql")
|
| 29 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("alpecevit/flan-t5-base-text2sql")
|
| 30 |
+
|
| 31 |
+
input_text = """
|
| 32 |
+
transform question and schema to SQL query. question: Who are the top 5 most paid employess by first name, last name, and salary ? schema: employee(salary, bdate, dno, ssn, fname, sex, superssn, address, minit, lname), department(dnumber, mgrstartdate, dname, mgrssn), dept_locations(dnumber, dlocation), project(pnumber, dnum, pname, plocation), works_on(pno, hours, essn), dependent(bdate, essn, dependent_name, sex, relationship).
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
token_input = tokenizer(input_text, return_tensors="pt").input_ids
|
| 36 |
+
output = model.generate(token_input, max_new_tokens=128)
|
| 37 |
+
query = tokenizer.decode(output[0], skip_special_tokens=True)
|
| 38 |
+
|
| 39 |
+
print("Predicted Query:", query)
|
| 40 |
```
|
| 41 |
+
|
| 42 |
+
*Output:*
|
| 43 |
+
|
| 44 |
+
```
|
| 45 |
+
SELECT fname, lname, salary FROM employee ORDER BY salary DESC LIMIT 5
|
| 46 |
```
|
| 47 |
|
| 48 |
+
## Evaluation
|
| 49 |
|
| 50 |
+
The fine-tuned model was evaluated using the combination of test splits of the above datasets. [ROUGE](https://huggingface.co/spaces/evaluate-metric/rouge) metrics were utilized for the assessment, and the results are outlined below.
|
| 51 |
+
|
| 52 |
+
```
|
| 53 |
+
{'rouge1': 0.8740305983060861, 'rouge2': 0.7763397400315798, 'rougeL': 0.8449832130213266, 'rougeLsum': 0.8447120646910007}
|
| 54 |
```
|