fatemeghasemi98 commited on
Commit
3cf0bd6
·
verified ·
1 Parent(s): 94d71c0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +81 -103
README.md CHANGED
@@ -1,103 +1,81 @@
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
- ---
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - text2sql
5
+ - natural-language-to-sql
6
+ - transformers
7
+ - t5
8
+ - spider-dataset
9
+ ---
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:** OSLLM.ai
20
+ - **Shared by:** OSLLM.ai
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("fatemeghasemi98/text-to-sql")
47
+ tokenizer = T5Tokenizer.from_pretrained("fatemeghasemi98/text-to-sql")
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)]