đ Text-to-SQL Translation Model - Millennials
This Text-to-SQL Translation Model is fine - tuned for text - to - SQL tasks. It aims to transform how systems understand and translate natural language instructions into SQL queries. Built on Mistral 7B, it's fine - tuned with a curated 100k SQL query generation instruction dataset, ensuring high - quality and precise results.
⨠Features
- Specialized in converting natural language text to SQL queries.
- Fine - tuned on a diverse set of 100k SQL query generation instructions.
- Easy to integrate and use for generating SQL queries on the fly.
đ Quick Start
Once your model is fine - tuned, you can generate SQL queries from natural language instructions. Use the generate.py
script, which allows for quick inference and can fetch models directly from the Hugging Face model hub.
đģ Usage Examples
Basic Usage
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("budecosystem/sql-millennials-7b")
model = AutoModelForCausalLM.from_pretrained("budecosystem/sql-millennials-7b")
prompt = "A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions.
USER: Create SQL query for the given table schema and question ASSISTANT:"
inputs = tokenizer(prompt, return_tensors="pt")
sample = model.generate(**inputs, max_length=128)
print(tokenizer.decode(sample[0]))
This script runs inference using the pre - trained model from the Hugging Face model hub and prints the generated SQL query.
đ§ Technical Details
Training Details
The model is trained on 4 A100 80GB GPUs for approximately 30 hours.
Property |
Details |
per_device_train_batch_size |
4 |
gradient_accumulation_steps |
1 |
epoch |
3 |
steps |
19206 |
learning_rate |
2e - 5 |
lr schedular type |
cosine |
warmup steps |
2000 |
optimizer |
adamw |
fp16 |
True |
GPU |
4 A100 80GB |
đ Documentation
Why millennials?
1. Automated Database Management for Businesses
Scenario: Small to medium - sized enterprises (SMEs) often lack dedicated IT teams for database queries, making it hard to retrieve specific data quickly for analysis and decision - making.
Use Case: Integrate the text - to - SQL model into a company's internal systems. Staff without SQL knowledge can input natural language requests like "Get a list of all transactions above $10,000 in the last quarter", and the system will convert it into a SQL query to retrieve the data.
2. Automating Data Analytics Processes
Scenario: Data analysts and business professionals face bottlenecks in generating insights due to SQL query formulation complexities, especially for immediate or repetitive data retrieval and analysis.
Use Case: The text - to - SQL model serves as an intermediary. By integrating it into data analytics systems, professionals can input natural language requests such as "Show the trend of online sales growth over the past five years". The system will convert it into a SQL query, retrieve data, and integrate it into visualization tools for instant insights.
3. Enhancing CMS Interfaces
Scenario: Content managers in Content Management Systems (CMS) often find it non - intuitive to handle complex data retrieval or database management.
Use Case: CMS providers can use the model to enhance the backend interface. Content managers can input natural language requests like "Find all blog posts in May 2023 with more than 500 views", and the model will generate the appropriate SQL query.
4. Customer Support Optimization
Scenario: Customer support centers need to retrieve client or product information from databases, which usually requires basic SQL knowledge.
Use Case: Integrate the model into support ticketing systems. Support personnel can input natural language requests such as "Show all open tickets from customers in New York filed this month" to get the data quickly.
5. Data Journalism and Research
Scenario: Journalists and researchers rely on complex databases but may lack SQL knowledge.
Use Case: Integrate the model into research software or journalistic tools. Professionals can input natural language queries like "Retrieve the average household income in Texas in 2022" to access data efficiently.
đ¤ Contributing
We welcome contributions to improve the model or address issues. Please submit pull requests or open issues to discuss changes or improvements.
đ Acknowledgments
We thank the open - source community and the researchers whose foundational work led to this model.
đ License
This project is licensed under the Apache - 2.0 license.