Update README.md
Browse files
README.md
CHANGED
|
@@ -1,100 +1,120 @@
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
-
tags: []
|
| 4 |
---
|
| 5 |
|
| 6 |
-
# Model Card for
|
| 7 |
-
|
| 8 |
-
<!-- Provide a quick summary of what the model is/does. -->
|
| 9 |
-
|
| 10 |
-
|
| 11 |
|
| 12 |
## Model Details
|
| 13 |
|
| 14 |
### Model Description
|
| 15 |
|
| 16 |
-
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
- **
|
| 21 |
-
- **Funded by [optional]:** [More Information Needed]
|
| 22 |
-
- **Shared by [optional]:** [More Information Needed]
|
| 23 |
-
- **Model type:** T5-based Natural Language to SQL Model
|
| 24 |
-
- **Language(s) (NLP):** English
|
| 25 |
-
- **License:** MIT
|
| 26 |
-
- **Finetuned from model [optional]:** `t5-large`
|
| 27 |
|
| 28 |
-
|
| 29 |
|
| 30 |
-
|
| 31 |
|
| 32 |
-
|
|
|
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
- **Paper [optional]:** [More Information Needed]
|
| 36 |
-
- **Demo [optional]:** [More Information Needed]
|
| 37 |
|
| 38 |
## Uses
|
| 39 |
|
| 40 |
-
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 41 |
-
|
| 42 |
### Direct Use
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
### Downstream Use [optional]
|
| 49 |
|
| 50 |
-
|
| 51 |
|
| 52 |
-
|
|
|
|
| 53 |
|
| 54 |
### Out-of-Scope Use
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
## Bias, Risks, and Limitations
|
| 61 |
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
|
| 66 |
### Recommendations
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
| 69 |
|
| 70 |
-
|
| 71 |
|
| 72 |
## How to Get Started with the Model
|
| 73 |
|
| 74 |
-
Use the code below to
|
| 75 |
|
| 76 |
-
|
|
|
|
| 77 |
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
| 83 |
|
| 84 |
-
|
|
|
|
| 85 |
|
| 86 |
-
### Training Procedure
|
| 87 |
|
| 88 |
-
|
| 89 |
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
|
| 92 |
-
[More Information Needed]
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
|
| 95 |
#### Training Hyperparameters
|
| 96 |
|
| 97 |
-
|
|
|
|
| 98 |
|
| 99 |
#### Speeds, Sizes, Times [optional]
|
| 100 |
|
|
@@ -172,7 +192,14 @@ Carbon emissions can be estimated using the [Machine Learning Impact calculator]
|
|
| 172 |
|
| 173 |
## Citation [optional]
|
| 174 |
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
**BibTeX:**
|
| 178 |
|
|
|
|
| 1 |
---
|
| 2 |
library_name: transformers
|
| 3 |
+
tags: [text2sql, sql-generation, t5, natural-language-processing]
|
| 4 |
---
|
| 5 |
|
| 6 |
+
# Model Card for ThotaBhanu/t5_sql_askdb
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
## Model Details
|
| 9 |
|
| 10 |
### Model Description
|
| 11 |
|
| 12 |
+
This model is a **T5-based Natural Language to SQL** converter, fine-tuned on the **WikiSQL dataset**. It is designed to convert **English natural language queries** into **SQL queries** that can be executed on relational databases.
|
| 13 |
|
| 14 |
+
- **Developed by:** Bhanu Prasad Thota
|
| 15 |
+
- **Funded by [optional]:** Independent
|
| 16 |
+
- **Shared by [optional]:** Bhanu Prasad Thota
|
| 17 |
+
- **Model type:** T5-based Sequence-to-Sequence Model
|
| 18 |
+
- **Language(s):** English
|
| 19 |
+
- **License:** MIT
|
| 20 |
+
- **Finetuned from model:** `t5-large`
|
| 21 |
|
| 22 |
+
This model is particularly useful for **text-to-SQL applications**, allowing users to **query databases using plain English** instead of writing SQL.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
---
|
| 25 |
|
| 26 |
+
## Model Sources
|
| 27 |
|
| 28 |
+
- **Repository:** [https://huggingface.co/ThotaBhanu/t5_sql_askdb](https://huggingface.co/ThotaBhanu/t5_sql_askdb)
|
| 29 |
+
- **Paper [optional]:** N/A
|
| 30 |
+
- **Demo [optional]:** Coming soon
|
| 31 |
|
| 32 |
+
---
|
|
|
|
|
|
|
| 33 |
|
| 34 |
## Uses
|
| 35 |
|
|
|
|
|
|
|
| 36 |
### Direct Use
|
| 37 |
|
| 38 |
+
- Convert **natural language questions** into **SQL queries**
|
| 39 |
+
- Assist in **database query automation**
|
| 40 |
+
- Can be used in **chatbots, data analytics tools, and enterprise database search systems**
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
### Downstream Use
|
| 43 |
|
| 44 |
+
- Can be **fine-tuned** further on **custom datasets** to improve domain-specific SQL generation
|
| 45 |
+
- Can be integrated into **business intelligence tools** for better user interaction
|
| 46 |
|
| 47 |
### Out-of-Scope Use
|
| 48 |
|
| 49 |
+
- The model does **not infer database schema** automatically
|
| 50 |
+
- May generate incorrect SQL for **complex nested queries or multi-table joins**
|
| 51 |
+
- Not suitable for **non-relational (NoSQL) databases**
|
| 52 |
|
| 53 |
+
---
|
| 54 |
|
| 55 |
## Bias, Risks, and Limitations
|
| 56 |
|
| 57 |
+
- The model may not **always generate valid SQL** for **custom database schemas**
|
| 58 |
+
- Assumes **consistent column naming**, which may not always be the case in enterprise databases
|
| 59 |
+
- Performance depends on **how well the input query aligns** with the training data format
|
| 60 |
|
| 61 |
### Recommendations
|
| 62 |
|
| 63 |
+
- Always **validate generated SQL** before executing on a live database
|
| 64 |
+
- Use **schema-aware** validation methods for production environments
|
| 65 |
+
- Consider **fine-tuning the model** on domain-specific SQL queries
|
| 66 |
|
| 67 |
+
---
|
| 68 |
|
| 69 |
## How to Get Started with the Model
|
| 70 |
|
| 71 |
+
Use the code below to generate SQL queries from natural language:
|
| 72 |
|
| 73 |
+
```python
|
| 74 |
+
from transformers import T5Tokenizer, T5ForConditionalGeneration
|
| 75 |
|
| 76 |
+
# Load model and tokenizer
|
| 77 |
+
model_name = "ThotaBhanu/t5_sql_askdb"
|
| 78 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
| 79 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
| 80 |
|
| 81 |
+
# Function to convert query to SQL
|
| 82 |
+
def generate_sql(query):
|
| 83 |
+
input_text = f"Convert to SQL: {query}"
|
| 84 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 85 |
+
output = model.generate(**inputs)
|
| 86 |
+
return tokenizer.decode(output[0], skip_special_tokens=True)
|
| 87 |
|
| 88 |
+
# Example usage
|
| 89 |
+
query = "Find all employees who joined in 2020"
|
| 90 |
+
sql_query = generate_sql(query)
|
| 91 |
|
| 92 |
+
print(f"📝 Query: {query}")
|
| 93 |
+
print(f"🛠 Generated SQL: {sql_query}")
|
| 94 |
|
|
|
|
| 95 |
|
| 96 |
+
## Training Details
|
| 97 |
|
| 98 |
+
### Training Data
|
| 99 |
+
|
| 100 |
+
Dataset: WikiSQL
|
| 101 |
+
Size: 80,654 pairs of natural language questions and SQL queries
|
| 102 |
+
Preprocessing: Tokenization using T5Tokenizer, max length 128
|
| 103 |
|
|
|
|
| 104 |
|
| 105 |
+
### Training Procedure
|
| 106 |
+
|
| 107 |
+
Training framework: Hugging Face Transformers + PyTorch
|
| 108 |
+
Hardware used: NVIDIA V100 GPU
|
| 109 |
+
Optimizer: AdamW
|
| 110 |
+
Learning rate: 5e-5
|
| 111 |
+
Batch size: 8
|
| 112 |
+
Epochs: 5
|
| 113 |
|
| 114 |
#### Training Hyperparameters
|
| 115 |
|
| 116 |
+
Training precision: Mixed precision (fp16)
|
| 117 |
+
Gradient accumulation: Yes (to handle large batch sizes)
|
| 118 |
|
| 119 |
#### Speeds, Sizes, Times [optional]
|
| 120 |
|
|
|
|
| 192 |
|
| 193 |
## Citation [optional]
|
| 194 |
|
| 195 |
+
@misc{t5_sql_askdb,
|
| 196 |
+
author = {Bhanu Prasad Thota},
|
| 197 |
+
title = {T5-SQL AskDB Model},
|
| 198 |
+
year = {2025},
|
| 199 |
+
publisher = {Hugging Face},
|
| 200 |
+
howpublished = {\url{https://huggingface.co/ThotaBhanu/t5_sql_askdb}}
|
| 201 |
+
}
|
| 202 |
+
|
| 203 |
|
| 204 |
**BibTeX:**
|
| 205 |
|