Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,11 +1,102 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
---
|
| 10 |
|
| 11 |
-
|
|
|
|
| 1 |
+
# SQLGPT
|
| 2 |
+
|
| 3 |
+
SQLGPT is a powerful model designed to generate SQL queries based on your table information and specific questions. Simply provide the context of your table, ask a question, and SQLGPT will generate the corresponding SQL query for you.
|
| 4 |
+
|
| 5 |
+
### Live
|
| 6 |
+
You can interact with it live here: `https://sqlgpt-hazel.vercel.app/`
|
| 7 |
+
But as its deployed on huggingface spaces with 1 thread available and its running on CPU so be patient ;) it can take time (secret!! it can take upto 1 min)
|
| 8 |
+
|
| 9 |
+
## Features
|
| 10 |
+
|
| 11 |
+
- **SQL Query Generation:** Input table details and your query; the model generates the appropriate SQL command.
|
| 12 |
+
- **Fine-Tunning:** The model is fine-tuned on Google's Gemma 2b using the dataset available [here](https://huggingface.co/datasets/b-mc2/sql-create-context) on Hugging Face.
|
| 13 |
+
- **Model Availability:** The model is available on both Kaggle and Hugging Face.
|
| 14 |
+
- **Quantization:** The finetunned model is being quantized to 4-bit in GGUF format using llama.cpp
|
| 15 |
+
|
| 16 |
+
## Getting Started
|
| 17 |
+
|
| 18 |
+
### Running the UI Interface on Unix Distributions (Linux, macOS)
|
| 19 |
+
|
| 20 |
+
1. **Clone the Repository:**
|
| 21 |
+
|
| 22 |
+
```bash
|
| 23 |
+
git clone https://github.com/awaistahseen009/SQLGPT
|
| 24 |
+
```
|
| 25 |
+
|
| 26 |
+
2. **Install the Requirements:**
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
pip install -r requirements.txt
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
3. **Download the Quantized Model Setup:**
|
| 33 |
+
|
| 34 |
+
Download the quantized model from [Hugging Face](https://huggingface.co/spaces/awais009/SQLGPT/tree/main).
|
| 35 |
+
|
| 36 |
+
4. **Run the UI Interface:**
|
| 37 |
+
|
| 38 |
+
- Update the API request URL in `App.jsx`:
|
| 39 |
+
|
| 40 |
+
```javascript
|
| 41 |
+
// Change this line in App.jsx
|
| 42 |
+
const apiUrl = "http://localhost:8000/query";
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
- Start the server:
|
| 46 |
+
|
| 47 |
+
```bash
|
| 48 |
+
uvicorn main:app
|
| 49 |
+
```
|
| 50 |
+
|
| 51 |
+
5. **Launch the UI:**
|
| 52 |
+
Run npm run dev in ui folder's terminal and
|
| 53 |
+
Open the UI in your browser to interact with the model.
|
| 54 |
+
on `http://localhost:8000`
|
| 55 |
+
|
| 56 |
+
### Windows Users
|
| 57 |
+
|
| 58 |
+
If you're using Windows, the `llama-cpp` package is not available, so you will need to follow these steps:
|
| 59 |
+
|
| 60 |
+
1. **Clone the llama.cpp Repository:**
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
git clone https://github.com/ggerganov/llama.cpp
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
2. **Download the Quantized Model:**
|
| 67 |
+
|
| 68 |
+
Download the quantized model from [Hugging Face](https://huggingface.co/spaces/awais009/SQLGPT/tree/main/quantized_model).
|
| 69 |
+
|
| 70 |
+
3. **Run the Model:**
|
| 71 |
+
|
| 72 |
+
In your terminal, execute the following command:
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
./llama.cpp/llama-cli -m ./quantized_model/sql_gpt_quantized.gguf -n 256 -p "### QUESTION:\n{question_here}\n\n### CONTEXT:\n{context_here}\n\n### [RESPONSE]:\n"
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
4. **Prompt Template:**
|
| 79 |
+
|
| 80 |
+
Use the following prompt template when interacting with the model:
|
| 81 |
+
|
| 82 |
+
```text
|
| 83 |
+
### QUESTION:
|
| 84 |
+
{question_here}
|
| 85 |
+
|
| 86 |
+
### CONTEXT:
|
| 87 |
+
{context_here}
|
| 88 |
+
|
| 89 |
+
### [RESPONSE]:
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
## Fine-Tuned and Quantization Files
|
| 93 |
+
|
| 94 |
+
You can download the fine-tuned model and quantization files from the [SQLGPT Fine Tune Material Repository](https://github.com/awaistahseen009/SQLGPTFineTuneMaterial).
|
| 95 |
+
|
| 96 |
+
## Contributing
|
| 97 |
+
|
| 98 |
+
Contributions are welcome! Feel free to fork the project, make improvements, and submit a pull request.
|
| 99 |
+
|
| 100 |
---
|
| 101 |
|
| 102 |
+
Happy querying with SQLGPT!
|