pardeephck commited on
Commit
845170e
·
verified ·
1 Parent(s): ef2f009

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +1 -22
README.md CHANGED
@@ -6,26 +6,5 @@ widget:
6
  - text: "question: get employee name with age equal 25 table: id, name, age"
7
  ---
8
  ```python
9
- from typing import List
10
- from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
11
-
12
- tokenizer = AutoTokenizer.from_pretrained("juierror/text-to-sql-with-table-schema")
13
- model = AutoModelForSeq2SeqLM.from_pretrained("juierror/text-to-sql-with-table-schema")
14
-
15
- def prepare_input(question: str, table: List[str]):
16
- table_prefix = "table:"
17
- question_prefix = "question:"
18
- join_table = ",".join(table)
19
- inputs = f"{question_prefix} {question} {table_prefix} {join_table}"
20
- input_ids = tokenizer(inputs, max_length=700, return_tensors="pt").input_ids
21
- return input_ids
22
-
23
- def inference(question: str, table: List[str]) -> str:
24
- input_data = prepare_input(question=question, table=table)
25
- input_data = input_data.to(model.device)
26
- outputs = model.generate(inputs=input_data, num_beams=10, top_k=10, max_length=700)
27
- result = tokenizer.decode(token_ids=outputs[0], skip_special_tokens=True)
28
- return result
29
-
30
- print(inference(question="get people name with age equal 25", table=["id", "name", "age"]))
31
  ```
 
6
  - text: "question: get employee name with age equal 25 table: id, name, age"
7
  ---
8
  ```python
9
+ This model generate sql query from a table with schema details provided in parameter
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  ```