Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
@@ -1,199 +1,103 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
tags:
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
- **
|
21 |
-
- **
|
22 |
-
- **
|
23 |
-
- **
|
24 |
-
- **
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
###
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
-
|
33 |
-
|
34 |
-
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
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 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
<!-- This section describes the evaluation protocols and provides the results. -->
|
106 |
-
|
107 |
-
### Testing Data, Factors & Metrics
|
108 |
-
|
109 |
-
#### Testing Data
|
110 |
-
|
111 |
-
<!-- This should link to a Dataset Card if possible. -->
|
112 |
-
|
113 |
-
[More Information Needed]
|
114 |
-
|
115 |
-
#### Factors
|
116 |
-
|
117 |
-
<!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
|
118 |
-
|
119 |
-
[More Information Needed]
|
120 |
-
|
121 |
-
#### Metrics
|
122 |
-
|
123 |
-
<!-- These are the evaluation metrics being used, ideally with a description of why. -->
|
124 |
-
|
125 |
-
[More Information Needed]
|
126 |
-
|
127 |
-
### Results
|
128 |
-
|
129 |
-
[More Information Needed]
|
130 |
-
|
131 |
-
#### Summary
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
## Model Examination [optional]
|
136 |
-
|
137 |
-
<!-- Relevant interpretability work for the model goes here -->
|
138 |
-
|
139 |
-
[More Information Needed]
|
140 |
-
|
141 |
-
## Environmental Impact
|
142 |
-
|
143 |
-
<!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
|
144 |
-
|
145 |
-
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).
|
146 |
-
|
147 |
-
- **Hardware Type:** [More Information Needed]
|
148 |
-
- **Hours used:** [More Information Needed]
|
149 |
-
- **Cloud Provider:** [More Information Needed]
|
150 |
-
- **Compute Region:** [More Information Needed]
|
151 |
-
- **Carbon Emitted:** [More Information Needed]
|
152 |
-
|
153 |
-
## Technical Specifications [optional]
|
154 |
-
|
155 |
-
### Model Architecture and Objective
|
156 |
-
|
157 |
-
[More Information Needed]
|
158 |
-
|
159 |
-
### Compute Infrastructure
|
160 |
-
|
161 |
-
[More Information Needed]
|
162 |
-
|
163 |
-
#### Hardware
|
164 |
-
|
165 |
-
[More Information Needed]
|
166 |
-
|
167 |
-
#### Software
|
168 |
-
|
169 |
-
[More Information Needed]
|
170 |
-
|
171 |
-
## Citation [optional]
|
172 |
-
|
173 |
-
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
|
174 |
-
|
175 |
-
**BibTeX:**
|
176 |
-
|
177 |
-
[More Information Needed]
|
178 |
-
|
179 |
-
**APA:**
|
180 |
-
|
181 |
-
[More Information Needed]
|
182 |
-
|
183 |
-
## Glossary [optional]
|
184 |
-
|
185 |
-
<!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
|
186 |
-
|
187 |
-
[More Information Needed]
|
188 |
-
|
189 |
-
## More Information [optional]
|
190 |
-
|
191 |
-
[More Information Needed]
|
192 |
-
|
193 |
-
## Model Card Authors [optional]
|
194 |
-
|
195 |
-
[More Information Needed]
|
196 |
-
|
197 |
-
## Model Card Contact
|
198 |
-
|
199 |
-
[More Information Needed]
|
|
|
1 |
+
```markdown
|
2 |
+
---
|
3 |
+
tags:
|
4 |
+
- text2sql
|
5 |
+
- natural-language-to-sql
|
6 |
+
- transformers
|
7 |
+
- t5
|
8 |
+
- spider-dataset
|
9 |
+
license: apache-2.0
|
10 |
+
---
|
11 |
+
|
12 |
+
# Model Card for Fine-Tuned T5 for Text-to-SQL
|
13 |
+
|
14 |
+
## Model Details
|
15 |
+
|
16 |
+
### Model Description
|
17 |
+
This is a fine-tuned T5-small model for generating SQL queries from natural language. It was trained on the [Spider dataset](https://huggingface.co/datasets/spider), a benchmark dataset for text-to-SQL tasks.
|
18 |
+
|
19 |
+
- **Developed by:** [Your Name]
|
20 |
+
- **Shared by:** [Your Organization (optional)]
|
21 |
+
- **Model type:** Text-to-SQL (Sequence-to-Sequence)
|
22 |
+
- **Language(s):** English
|
23 |
+
- **License:** Apache 2.0
|
24 |
+
- **Finetuned from:** [t5-small](https://huggingface.co/t5-small)
|
25 |
+
|
26 |
+
## Uses
|
27 |
+
|
28 |
+
### Direct Use
|
29 |
+
This model can be used to generate SQL queries from natural language questions. It is particularly useful for developers building natural language interfaces to databases.
|
30 |
+
|
31 |
+
### Downstream Use
|
32 |
+
The model can be fine-tuned further on domain-specific datasets for improved performance.
|
33 |
+
|
34 |
+
### Out-of-Scope Use
|
35 |
+
This model is not suitable for generating SQL queries for databases with highly specialized schemas or non-standard SQL dialects.
|
36 |
+
|
37 |
+
## Bias, Risks, and Limitations
|
38 |
+
The model may generate incorrect or unsafe SQL queries if the input question is ambiguous or outside the scope of the training data. Always validate the generated SQL before executing it on a production database.
|
39 |
+
|
40 |
+
## How to Get Started with the Model
|
41 |
+
|
42 |
+
```python
|
43 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
44 |
+
|
45 |
+
# Load the fine-tuned model
|
46 |
+
model = T5ForConditionalGeneration.from_pretrained("your-huggingface-username/your-model-name")
|
47 |
+
tokenizer = T5Tokenizer.from_pretrained("your-huggingface-username/your-model-name")
|
48 |
+
|
49 |
+
# Generate SQL query
|
50 |
+
def generate_sql_query(question):
|
51 |
+
input_text = f"translate English to SQL: {question}"
|
52 |
+
input_ids = tokenizer(input_text, return_tensors="pt", max_length=512, truncation=True, padding="max_length").input_ids
|
53 |
+
outputs = model.generate(input_ids)
|
54 |
+
return tokenizer.decode(outputs[0], skip_special_tokens=True)
|
55 |
+
|
56 |
+
# Example usage
|
57 |
+
question = "Find all the customers who live in New York."
|
58 |
+
sql_query = generate_sql_query(question)
|
59 |
+
print(sql_query)
|
60 |
+
```
|
61 |
+
|
62 |
+
## Training Details
|
63 |
+
|
64 |
+
### Training Data
|
65 |
+
The model was trained on the [Spider dataset](https://huggingface.co/datasets/spider), which contains 10,181 questions and 5,693 unique complex SQL queries across 200 databases.
|
66 |
+
|
67 |
+
### Training Procedure
|
68 |
+
- **Preprocessing:** Questions were prefixed with "translate English to SQL:" and tokenized using the T5 tokenizer.
|
69 |
+
- **Training Hyperparameters:**
|
70 |
+
- Learning Rate: 2e-5
|
71 |
+
- Batch Size: 8
|
72 |
+
- Epochs: 3
|
73 |
+
- Mixed Precision: FP16
|
74 |
+
|
75 |
+
## Evaluation
|
76 |
+
The model was evaluated on the Spider validation set. Metrics such as exact match accuracy and execution accuracy can be used to assess performance.
|
77 |
+
|
78 |
+
## Environmental Impact
|
79 |
+
- **Hardware:** 1x NVIDIA T4 GPU (Google Colab)
|
80 |
+
- **Hours Used:** ~3 hours
|
81 |
+
- **Carbon Emitted:** [Estimate using the [ML CO2 Impact Calculator](https://mlco2.github.io/impact)]
|
82 |
+
|
83 |
+
## Citation
|
84 |
+
If you use this model, please cite the following:
|
85 |
+
|
86 |
+
```bibtex
|
87 |
+
@misc{your-model-name,
|
88 |
+
author = {Your Name},
|
89 |
+
title = {Fine-Tuned T5 for Text-to-SQL},
|
90 |
+
year = {2023},
|
91 |
+
publisher = {Hugging Face},
|
92 |
+
howpublished = {\url{https://huggingface.co/your-huggingface-username/your-model-name}}
|
93 |
+
}
|
94 |
+
```
|
95 |
+
|
96 |
+
## Model Card Authors
|
97 |
+
[Your Name]
|
98 |
+
|
99 |
+
## Model Card Contact
|
100 |
+
[Your Email or Contact Information]
|
101 |
+
```
|
102 |
+
|
103 |
+
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|