Update README.md
Browse files
README.md
CHANGED
@@ -10,198 +10,142 @@ datasets:
|
|
10 |
- flytech/python-codes-25k
|
11 |
---
|
12 |
|
13 |
-
#
|
14 |
-
|
15 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
16 |
|
|
|
17 |
|
18 |
|
19 |
## Model Details
|
20 |
|
21 |
### Model Description
|
22 |
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
- **Developed by:** [More Information Needed]
|
28 |
-
- **Funded by [optional]:** [More Information Needed]
|
29 |
-
- **Shared by [optional]:** [More Information Needed]
|
30 |
-
- **Model type:** [More Information Needed]
|
31 |
-
- **Language(s) (NLP):** [More Information Needed]
|
32 |
-
- **License:** [More Information Needed]
|
33 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
34 |
-
|
35 |
-
### Model Sources [optional]
|
36 |
-
|
37 |
-
<!-- Provide the basic links for the model. -->
|
38 |
|
39 |
-
- **Repository:** [More Information Needed]
|
40 |
-
- **Paper [optional]:** [More Information Needed]
|
41 |
-
- **Demo [optional]:** [More Information Needed]
|
42 |
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
|
45 |
-
|
46 |
|
47 |
-
|
48 |
|
49 |
-
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
|
|
|
|
54 |
|
55 |
-
|
56 |
|
57 |
-
|
58 |
|
59 |
-
|
|
|
60 |
|
61 |
-
|
62 |
|
63 |
-
|
|
|
64 |
|
65 |
-
|
|
|
66 |
|
67 |
-
|
|
|
68 |
|
69 |
-
|
|
|
|
|
70 |
|
71 |
-
### Recommendations
|
72 |
-
|
73 |
-
<!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
|
74 |
-
|
75 |
-
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
|
76 |
-
|
77 |
-
## How to Get Started with the Model
|
78 |
-
|
79 |
-
Use the code below to get started with the model.
|
80 |
-
|
81 |
-
[More Information Needed]
|
82 |
|
83 |
## Training Details
|
84 |
|
85 |
### Training Data
|
86 |
|
87 |
-
|
88 |
-
|
89 |
-
[More Information Needed]
|
90 |
|
91 |
### Training Procedure
|
92 |
|
93 |
-
|
94 |
|
95 |
-
#### Preprocessing
|
96 |
|
97 |
-
[
|
|
|
98 |
|
99 |
|
100 |
#### Training Hyperparameters
|
101 |
|
102 |
-
- **
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
[More Information Needed]
|
109 |
-
|
110 |
-
## Evaluation
|
111 |
-
|
112 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
113 |
-
|
114 |
-
### Testing Data, Factors & Metrics
|
115 |
-
|
116 |
-
#### Testing Data
|
117 |
-
|
118 |
-
<!-- This should link to a Dataset Card if possible. -->
|
119 |
-
|
120 |
-
[More Information Needed]
|
121 |
-
|
122 |
-
#### Factors
|
123 |
-
|
124 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
125 |
-
|
126 |
-
[More Information Needed]
|
127 |
|
128 |
-
#### Metrics
|
129 |
-
|
130 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
131 |
-
|
132 |
-
[More Information Needed]
|
133 |
-
|
134 |
-
### Results
|
135 |
-
|
136 |
-
[More Information Needed]
|
137 |
-
|
138 |
-
#### Summary
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
## Model Examination [optional]
|
143 |
-
|
144 |
-
<!-- Relevant interpretability work for the model goes here -->
|
145 |
-
|
146 |
-
[More Information Needed]
|
147 |
-
|
148 |
-
## Environmental Impact
|
149 |
-
|
150 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
151 |
-
|
152 |
-
Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
|
153 |
-
|
154 |
-
- **Hardware Type:** [More Information Needed]
|
155 |
-
- **Hours used:** [More Information Needed]
|
156 |
-
- **Cloud Provider:** [More Information Needed]
|
157 |
-
- **Compute Region:** [More Information Needed]
|
158 |
-
- **Carbon Emitted:** [More Information Needed]
|
159 |
-
|
160 |
-
## Technical Specifications [optional]
|
161 |
-
|
162 |
-
### Model Architecture and Objective
|
163 |
-
|
164 |
-
[More Information Needed]
|
165 |
-
|
166 |
-
### Compute Infrastructure
|
167 |
-
|
168 |
-
[More Information Needed]
|
169 |
|
170 |
#### Hardware
|
171 |
|
172 |
-
|
173 |
-
|
174 |
-
#### Software
|
175 |
-
|
176 |
-
[More Information Needed]
|
177 |
-
|
178 |
-
## Citation [optional]
|
179 |
-
|
180 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
181 |
-
|
182 |
-
**BibTeX:**
|
183 |
|
184 |
-
[More Information Needed]
|
185 |
|
186 |
-
|
187 |
|
188 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
|
190 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
191 |
|
192 |
-
|
193 |
|
194 |
-
|
195 |
|
196 |
-
|
197 |
|
198 |
-
|
199 |
|
200 |
-
|
|
|
201 |
|
202 |
-
[More Information Needed]
|
203 |
|
204 |
-
## Model Card
|
205 |
|
206 |
-
|
207 |
-
### Framework versions
|
|
|
10 |
- flytech/python-codes-25k
|
11 |
---
|
12 |
|
13 |
+
# BART-LARGE-CNN fine-tuned on SYNTHETIC_TEXT_TO_SQL
|
|
|
|
|
14 |
|
15 |
+
Generate SQL query from Natural Language question with a SQL context.
|
16 |
|
17 |
|
18 |
## Model Details
|
19 |
|
20 |
### Model Description
|
21 |
|
22 |
+
BART from facebook/bart-large-cnn is fintuned on gretelai/synthetic_text_to_sql dataset to generate SQL from NL and SQL context
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
|
|
|
|
|
|
24 |
|
25 |
+
- **Model type:** BART
|
26 |
+
- **Language(s) (NLP):** English
|
27 |
+
- **License:** openrail
|
28 |
+
- **Finetuned from model [facebook/bart-large-cnn](https://huggingface.co/facebook/bart-large-cnn?text=The+tower+is+324+metres+%281%2C063+ft%29+tall%2C+about+the+same+height+as+an+81-storey+building%2C+and+the+tallest+structure+in+Paris.+Its+base+is+square%2C+measuring+125+metres+%28410+ft%29+on+each+side.+During+its+construction%2C+the+Eiffel+Tower+surpassed+the+Washington+Monument+to+become+the+tallest+man-made+structure+in+the+world%2C+a+title+it+held+for+41+years+until+the+Chrysler+Building+in+New+York+City+was+finished+in+1930.+It+was+the+first+structure+to+reach+a+height+of+300+metres.+Due+to+the+addition+of+a+broadcasting+aerial+at+the+top+of+the+tower+in+1957%2C+it+is+now+taller+than+the+Chrysler+Building+by+5.2+metres+%2817+ft%29.+Excluding+transmitters%2C+the+Eiffel+Tower+is+the+second+tallest+free-standing+structure+in+France+after+the+Millau+Viaduct.)**
|
29 |
+
- **Dataset:** [gretelai/synthetic_text_to_sql](https://huggingface.co/datasets/gretelai/synthetic_text_to_sql)
|
30 |
|
31 |
+
## Intended uses & limitations
|
32 |
|
33 |
+
Addressing the power of LLM in fintuned downstream task. Implemented as a personal Project.
|
34 |
|
35 |
+
### How to use
|
36 |
|
37 |
+
```python
|
38 |
+
query_question_with_context = """sql_prompt: Which economic diversification efforts in
|
39 |
+
the 'diversification' table have a higher budget than the average budget for all economic diversification efforts in the 'budget' table?
|
40 |
+
sql_context: CREATE TABLE diversification (id INT, effort VARCHAR(50), budget FLOAT); CREATE TABLE
|
41 |
+
budget (diversification_id INT, diversification_effort VARCHAR(50), amount FLOAT);"""
|
42 |
+
```
|
43 |
|
44 |
+
# Use a pipeline as a high-level helper
|
45 |
+
```python
|
46 |
+
from transformers import pipeline
|
47 |
|
48 |
+
sql_generator = pipeline("text2text-generation", model="SwastikM/bart-large-nl2sql")
|
49 |
|
50 |
+
sql = sql_generator(query_question_with_context)[0]['generated_text']
|
51 |
|
52 |
+
print(sql)
|
53 |
+
```
|
54 |
|
55 |
+
# Load model directly
|
56 |
|
57 |
+
```python
|
58 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
59 |
|
60 |
+
tokenizer = AutoTokenizer.from_pretrained("SwastikM/bart-large-nl2sql")
|
61 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("SwastikM/bart-large-nl2sql")
|
62 |
|
63 |
+
inputs = tokenizer(query_question_with_context, return_tensors="pt").input_ids
|
64 |
+
outputs = model.generate(inputs, max_new_tokens=100, do_sample=False)
|
65 |
|
66 |
+
sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
67 |
+
print(sql)
|
68 |
+
```
|
69 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
|
71 |
## Training Details
|
72 |
|
73 |
### Training Data
|
74 |
|
75 |
+
[gretelai/synthetic_text_to_sql](https://huggingface.co/datasets/gretelai/synthetic_text_to_sql)
|
|
|
|
|
76 |
|
77 |
### Training Procedure
|
78 |
|
79 |
+
HuggingFace Accelerate with Training Loop.
|
80 |
|
81 |
+
#### Preprocessing
|
82 |
|
83 |
+
- ***Encoder Input:*** "sql_prompt: " + data['sql_prompt']+" sql_context: "+data['sql_context']
|
84 |
+
- ***Decoder Input:*** data['sql']
|
85 |
|
86 |
|
87 |
#### Training Hyperparameters
|
88 |
|
89 |
+
- **Optimizer:** AdamW
|
90 |
+
- **lr:** 2e-5
|
91 |
+
- **decay:** linear
|
92 |
+
- **num_warmup_steps:** 0
|
93 |
+
- **batch_size:** 8
|
94 |
+
- **num_training_steps:** 12500
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
|
97 |
#### Hardware
|
98 |
|
99 |
+
- **GPU:** P100
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
|
|
|
101 |
|
102 |
+
### Citing Dataset and BaseModel
|
103 |
|
104 |
+
```
|
105 |
+
@software{gretel-synthetic-text-to-sql-2024,
|
106 |
+
author = {Meyer, Yev and Emadi, Marjan and Nathawani, Dhruv and Ramaswamy, Lipika and Boyd, Kendrick and Van Segbroeck, Maarten and Grossman, Matthew and Mlocek, Piotr and Newberry, Drew},
|
107 |
+
title = {{Synthetic-Text-To-SQL}: A synthetic dataset for training language models to generate SQL queries from natural language prompts},
|
108 |
+
month = {April},
|
109 |
+
year = {2024},
|
110 |
+
url = {https://huggingface.co/datasets/gretelai/synthetic-text-to-sql}
|
111 |
+
}
|
112 |
+
```
|
113 |
|
114 |
+
```
|
115 |
+
@article{DBLP:journals/corr/abs-1910-13461,
|
116 |
+
author = {Mike Lewis and
|
117 |
+
Yinhan Liu and
|
118 |
+
Naman Goyal and
|
119 |
+
Marjan Ghazvininejad and
|
120 |
+
Abdelrahman Mohamed and
|
121 |
+
Omer Levy and
|
122 |
+
Veselin Stoyanov and
|
123 |
+
Luke Zettlemoyer},
|
124 |
+
title = {{BART:} Denoising Sequence-to-Sequence Pre-training for Natural Language
|
125 |
+
Generation, Translation, and Comprehension},
|
126 |
+
journal = {CoRR},
|
127 |
+
volume = {abs/1910.13461},
|
128 |
+
year = {2019},
|
129 |
+
url = {http://arxiv.org/abs/1910.13461},
|
130 |
+
eprinttype = {arXiv},
|
131 |
+
eprint = {1910.13461},
|
132 |
+
timestamp = {Thu, 31 Oct 2019 14:02:26 +0100},
|
133 |
+
biburl = {https://dblp.org/rec/journals/corr/abs-1910-13461.bib},
|
134 |
+
bibsource = {dblp computer science bibliography, https://dblp.org}
|
135 |
+
}
|
136 |
|
137 |
+
```
|
138 |
|
139 |
+
## Additional Information
|
140 |
|
141 |
+
- ***Github:*** [Repository](https://github.com/swastikmaiti/SwastikM-bart-large-nl2sql.git)
|
142 |
|
143 |
+
## Acknowledgment
|
144 |
|
145 |
+
Thanks to [@AI at Meta](https://huggingface.co/facebook) for adding the Pre Trained Model.
|
146 |
+
Thanks to [@Gretel.ai](https://huggingface.co/gretelai) for adding the datset.
|
147 |
|
|
|
148 |
|
149 |
+
## Model Card Authors
|
150 |
|
151 |
+
Swastik Maiti
|
|