Update README.md
Browse files
README.md
CHANGED
|
@@ -3,21 +3,72 @@ tags:
|
|
| 3 |
- gguf
|
| 4 |
- llama.cpp
|
| 5 |
- unsloth
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
|
|
|
| 10 |
|
| 11 |
-
|
| 12 |
|
| 13 |
-
|
| 14 |
-
- For text only LLMs: `./llama.cpp/llama-cli -hf mrcmilo/phi3-text2sql-lora --jinja`
|
| 15 |
-
- For multimodal models: `./llama.cpp/llama-mtmd-cli -hf mrcmilo/phi3-text2sql-lora --jinja`
|
| 16 |
|
| 17 |
-
|
| 18 |
-
- `phi-3-mini-4k-instruct.Q5_K.gguf`
|
| 19 |
|
| 20 |
-
|
| 21 |
-
An Ollama Modelfile is included for easy deployment.
|
| 22 |
-
This was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
|
| 23 |
-
[<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
|
|
|
|
| 3 |
- gguf
|
| 4 |
- llama.cpp
|
| 5 |
- unsloth
|
| 6 |
+
license: mit
|
| 7 |
+
datasets:
|
| 8 |
+
- b-mc2/sql-create-context
|
| 9 |
+
language:
|
| 10 |
+
- en
|
| 11 |
+
metrics:
|
| 12 |
+
- accuracy
|
| 13 |
+
base_model:
|
| 14 |
+
- microsoft/Phi-3-mini-4k-instruct
|
| 15 |
---
|
| 16 |
+
This is a specialized **Text-to-SQL** model fine-tuned from the **Microsoft Phi-3-mini-4k-instruct** architecture. It has been optimized using **Unsloth** to provide high-accuracy SQL generation while remaining lightweight enough to run on consumer hardware.
|
| 17 |
+
|
| 18 |
+
## Key Features
|
| 19 |
+
- **Architecture:** Phi-3-mini (3.8B parameters)
|
| 20 |
+
- **Quantization:** Q4_K_M GGUF & Q5_K_M
|
| 21 |
+
- **Training Technique:** Fine-tuned using Lora with [Unsloth](https://github.com/unslothai/unsloth).
|
| 22 |
+
- **Format:** GGUF (Ready for Ollama, LM Studio, and llama.cpp)
|
| 23 |
+
- **phi-3-mini-4k-instruct.Q4_K_M.gguf**
|
| 24 |
+
- **phi-3-mini-4k-instruct.Q5_K_M.gguf**
|
| 25 |
+
|
| 26 |
+
## Usage Instructions
|
| 27 |
+
|
| 28 |
+
### Ollama (Recommended)
|
| 29 |
+
To deploy locally:
|
| 30 |
+
|
| 31 |
+
1. Download the `.gguf` file.
|
| 32 |
+
|
| 33 |
+
2. Create the Modelfile with the following instructions
|
| 34 |
+
|
| 35 |
+
```Dockerfile
|
| 36 |
+
FROM ./phi-3-mini-4k-instruct.Q4_K_M.gguf
|
| 37 |
+
|
| 38 |
+
SYSTEM """You are a specialized SQL assistant. Your goal is to produce valid SQL queries based on the provided schema and question. Output only the SQL code and nothing else."""
|
| 39 |
+
|
| 40 |
+
TEMPLATE """<|system|>
|
| 41 |
+
{{ .System }}<|end|>
|
| 42 |
+
<|user|>
|
| 43 |
+
{{ .Prompt }}<|end|>
|
| 44 |
+
<|assistant|>
|
| 45 |
+
"""
|
| 46 |
+
|
| 47 |
+
PARAMETER stop "<|end|>"
|
| 48 |
+
PARAMETER temperature 0.1
|
| 49 |
+
PARAMETER num_ctx 2048
|
| 50 |
+
PARAMETER repeat_penalty 1.2
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
3. Run ```ollama create phi3-sql-expert -f Modelfile```
|
| 54 |
+
|
| 55 |
+
5. Run ```ollama run phi3-sql-expert```
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
## Evaluation Data
|
| 59 |
+
The model was fine-tuned on the sql-create-context dataset, focusing on:
|
| 60 |
+
|
| 61 |
+
- Mapping natural language to complex SELECT, WHERE, and JOIN statements.
|
| 62 |
+
- Understanding table schemas provided in the prompt.
|
| 63 |
+
- Maintaining strict SQL syntax.
|
| 64 |
|
| 65 |
+
## Recommended Settings
|
| 66 |
+
Temperature: 0.0 or 0.1 (SQL requires deterministic output).
|
| 67 |
|
| 68 |
+
Stop Tokens: Ensure <|end|> is set as a stop sequence to prevent "infinite looping" generation.
|
| 69 |
|
| 70 |
+
Context Window: 2048 tokens.
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
**Model Developer**: [msquared](https://github.com/mrcmilano)
|
|
|
|
| 73 |
|
| 74 |
+
Base Model: [Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct)
|
|
|
|
|
|
|
|
|