Update README.md
Browse files
README.md
CHANGED
@@ -16,4 +16,43 @@ language:
|
|
16 |
- en
|
17 |
tags:
|
18 |
- code
|
19 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
- en
|
17 |
tags:
|
18 |
- code
|
19 |
+
---
|
20 |
+
# T5-SQL-Translator
|
21 |
+
|
22 |
+
## Overview
|
23 |
+
T5-SQL-Translator is a fine-tuned version of the Google T5-small model, specialized in translating English natural language queries into SQL SELECT queries. This model is trained to understand English queries and generate corresponding SQL SELECT queries for databases, making it valuable for automating the process of translating natural language to SQL, particularly for SELECT operations.
|
24 |
+
|
25 |
+
## Model Details
|
26 |
+
- **Model Name**: T5-SQL-Translator
|
27 |
+
- **Model Type**: Text-to-Text Transformers
|
28 |
+
- **Base Model**: Google T5-small
|
29 |
+
- **Language**: English
|
30 |
+
- **Task**: English to SQL SELECT Translation
|
31 |
+
- **Training Data**: Combination of English natural language queries paired with corresponding SQL SELECT queries from diverse domains.
|
32 |
+
- **Fine-tuning**: The model has been fine-tuned on a dataset of English-to-SQL SELECT translations to optimize its performance for this specific task.
|
33 |
+
|
34 |
+
## Example Use Cases
|
35 |
+
- Automatically translating English questions into SQL SELECT queries for database querying.
|
36 |
+
|
37 |
+
## How to Use
|
38 |
+
1. **Install Hugging Face Transformers**:
|
39 |
+
```bash
|
40 |
+
pip install transformers
|
41 |
+
```
|
42 |
+
## Inference
|
43 |
+
```python
|
44 |
+
|
45 |
+
def translate_to_sql_select(english_query):
|
46 |
+
input_text = "translate English to SQL: "english_query
|
47 |
+
input_ids = tokenizer.encode(input_text, return_tensors="pt",max_new_tokens=100,do_sample=False)
|
48 |
+
outputs = model.generate(input_ids)
|
49 |
+
sql_query = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
50 |
+
return sql_query
|
51 |
+
|
52 |
+
# Example usage
|
53 |
+
english_query = "Show all employees with salary greater than $50000"
|
54 |
+
sql_query = translate_to_sql_select(english_query)
|
55 |
+
print("SQL SELECT Query:", sql_query)
|
56 |
+
```
|
57 |
+
|
58 |
+
|