File size: 1,892 Bytes
d60cb1f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---

title: Olist Text-to-SQL Agent
emoji: πŸ€–
colorFrom: blue
colorTo: purple
sdk: gradio
sdk_version: 4.44.0
app_file: app_gradio.py
pinned: false
license: mit
---


# πŸ€– Olist Text-to-SQL Agent

Convert natural language questions into SQL queries using a **fine-tuned Mistral-7B model**.

## 🎯 Features

- **Fine-Tuned Model**: Mistral-7B-Instruct-v0.2 fine-tuned with QLoRA on Olist e-commerce dataset
- **Natural Language to SQL**: Ask questions in plain English, get executable SQL queries
- **Real Database**: Query against actual Olist e-commerce data (100K+ orders)
- **Interactive UI**: Built with Gradio for easy interaction

## πŸš€ How to Use

1. Type your question in natural language
2. Click "Generate SQL & Execute"
3. View the generated SQL query and results

## πŸ’‘ Example Questions

- "How many orders are there?"
- "What are the top 5 best-selling products?"
- "Show total revenue by customer state"
- "Which sellers have the highest ratings?"
- "List all orders from SΓ£o Paulo"

## πŸ› οΈ Tech Stack

- **Model**: Mistral-7B-Instruct-v0.2 (fine-tuned with QLoRA)
- **Frontend**: Gradio
- **Database**: SQLite (Olist e-commerce dataset)
- **ML Libraries**: PyTorch, Transformers, PEFT, BitsAndBytes

## πŸ“Š Model Details

- **Base Model**: mistralai/Mistral-7B-Instruct-v0.2
- **Fine-Tuned Model**: [mhdakmal80/Olist-SQL-Agent-Final](https://huggingface.co/mhdakmal80/Olist-SQL-Agent-Final)
- **Training Method**: QLoRA (4-bit quantization)
- **Training Data**: 1000+ synthetic question-SQL pairs
- **Accuracy**: 90% on test set

## πŸŽ“ About

This project demonstrates:
- Fine-tuning large language models (7B parameters)
- Parameter-efficient fine-tuning with QLoRA
- Production deployment of ML models
- Full-stack application development

Built by [mhdakmal80](https://huggingface.co/mhdakmal80)