This project allows users to ask natural language questions and get answers from a MySQL database by converting the questions into SQL queries using:
- LangChain
- HuggingFace Embeddings
- Ollama LLMs (Qwen2)
It uses few-shot learning, semantic similarity, and local LLM inference for a fast, secure, and intelligent querying experience.
langchain-huggingfacelangchain-ollamalangchain_communitywatchdogcryptographystreamlitpython-dotenv
- The dataset (SQL schema + data) is located in
./dataset/db_creation_atliq_tshirts.sql. - We embed both the schema and its content using HuggingFace’s
"sentence-transformers/all-MiniLM-L6-v2". - We have performed Few-shot training on LLM to train it on edge case queries.
- LLM used: Qwen2 (running via Ollama).
docker run --name atliq-mysql \
-e MYSQL_ROOT_PASSWORD=<password> \
-e MYSQL_DATABASE=atliq_tshirts \
-p 3306:3306 \
-d mysql:8.0
docker cp ./dataset/db_creation_atliq_tshirts.sql atliq-mysql:/db_creation.sql
docker exec -it atliq-mysql bashmysql -u root -p
# Enter: root
USE atliq_tshirts;
SOURCE /db_creation.sql;git clone https://github.com/your-username/text2sql.git
cd text2sqlpython -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activatepip install -r requirements.txttouch .envDB_USER=<db user name>
DB_PASSWORD=<db password>
DB_HOST=<host name>
DB_PORT=3306
DB_NAME=atliq_tshirts
LLM_MODEL_NAME=<model name>
LLM_MODEL_TEMP=<model temp>
LLM_BASE_URL=<llm base url>
EMBEDDING_MODEL_NAME=sentence-transformers/all-MiniLM-L6-v2