This repository provides a Streamlit web app that generates SQL queries from natural language questions using the LLaMA-3-SQLCoder-8B model via Hugging Face Transformers. Users can input a database schema and a question, and the app returns a formatted SQL query.
Add these to your requirements.txt or install with pip install -r requirements.txt:
streamlit>=1.25.0
torch>=2.0.0
transformers>=4.40.0
sqlparse>=0.4.4
Note:
- For best performance, a machine with a GPU supporting
bfloat16is recommended.- The app downloads the model from Hugging Face (
defog/llama-3-sqlcoder-8b). You may need to accept model terms on Hugging Face and may need to authenticate if running in a restricted environment.
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
cd YOUR_REPO_NAME
pip install -r requirements.txt
streamlit run app.py
.
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # This file
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(50),
price DECIMAL(10,2),
quantity INTEGER
);
"Show the names of customers who bought more than 5 products in a single sale."
"Find the average supply price for each product."
"What was the total quantity of products sold by region?"
"List all sales that occurred after January 1, 2024."
"Which suppliers supply products with a price lower than $50?"
"Get the total sales quantity per customer, sorted by highest to lowest."_
SELECT name
FROM products
WHERE price > 100;
@st.cache_resource for faster reloads.This project is for research and educational purposes. Please check the license terms for the LLaMA-3-SQLCoder-8B model on Hugging Face before commercial use.
For questions or issues, please open an issue in this repository.
This repository provides a Streamlit web app that generates SQL queries from natural language questions using the LLaMA-3-SQLCoder-8B model via Hugging Face Transformers. Users can input a database schema and a question, and the app returns a formatted SQL query.
Add these to your requirements.txt or install with pip install -r requirements.txt:
streamlit>=1.25.0
torch>=2.0.0
transformers>=4.40.0
sqlparse>=0.4.4
Note:
- For best performance, a machine with a GPU supporting
bfloat16is recommended.- The app downloads the model from Hugging Face (
defog/llama-3-sqlcoder-8b). You may need to accept model terms on Hugging Face and may need to authenticate if running in a restricted environment.
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git
cd YOUR_REPO_NAME
pip install -r requirements.txt
streamlit run app.py
.
├── app.py # Main Streamlit application
├── requirements.txt # Python dependencies
├── README.md # This file
CREATE TABLE products (
product_id INTEGER PRIMARY KEY,
name VARCHAR(50),
price DECIMAL(10,2),
quantity INTEGER
);
"Show the names of customers who bought more than 5 products in a single sale."
"Find the average supply price for each product."
"What was the total quantity of products sold by region?"
"List all sales that occurred after January 1, 2024."
"Which suppliers supply products with a price lower than $50?"
"Get the total sales quantity per customer, sorted by highest to lowest."_
SELECT name
FROM products
WHERE price > 100;
@st.cache_resource for faster reloads.This project is for research and educational purposes. Please check the license terms for the LLaMA-3-SQLCoder-8B model on Hugging Face before commercial use.
For questions or issues, please open an issue in this repository.