In Part 1 of this series, we trained Microsoft Phi-1 to translate natural language into SQL queries.
Now, it’s time to put that model to work generating, validating, and executing queries against a live MySQLdatabase.
This article focuses on:
- Loading the fine-tuned Phi-1 model
- Generating SQL queries dynamically
- Performing basic validation to ensure query safety
- Executing those queries in MySQL
- Exposing the entire process through a Flask API
By the end of this part, you’ll have an API endpoint that can take any natural language question like:
“Show me the total income of Nabil Bank in 2024”
and return the executed results directly from your database.
.png&w=3840&q=75)






