This project implements a text-to-SQL system that allows users to interact with databases using natural language queries. It leverages transformer-based models like BERT and T5 to convert user queries into accurate SQL statements. The system is integrated with Flask/FastAPI for real-time query execution.
- Converts natural language queries into SQL statements.
- Built with transformer-based architectures like BERT and T5 for natural language understanding and SQL generation.
- Integrated with Flask/FastAPI for real-time query execution.
- Supports complex SQL queries and domain-specific use cases.
- Uses techniques like beam search and attention mechanisms to enhance performance and accuracy.
- Trained on the Spider dataset for a wide range of SQL queries.
- Python 3.7+
- Flask or FastAPI
- PyTorch (for model implementation)
- Hugging Face Transformers library
-
Clone this repository:
git clone https://github.com/yourusername/simplifying-sql-with-nl.git cd simplifying-sql-with-nl -
Install dependencies:
pip install -r requirements.txt
-
Run the server:
For Flask:
python app.py
For FastAPI:
uvicorn app:app --reload
-
Start the backend server (Flask or FastAPI).
-
Send a POST request to the
/queryendpoint with a natural language query:Example input:
{ "query": "What is the total revenue for the last quarter?" } -
The response will be the corresponding SQL query:
SELECT SUM(revenue) FROM sales WHERE quarter = 'last' AND year = CURRENT_YEAR;
- The model is trained on the Spider dataset, which contains diverse SQL queries and schemas.
- Fine-tuned with domain-specific data to improve performance for complex queries.
- Natural Language Processing (NLP): BERT, T5
- Backend Frameworks: Flask/FastAPI
- Modeling Framework: PyTorch, Hugging Face Transformers
- Dataset: Spider dataset
Feel free to open issues or submit pull requests. Contributions are always welcome!
This project is licensed under the MIT License - see the LICENSE file for details.