mrcmilo/phi3-text2sql-lora
035
1---2tags:3- gguf4- llama.cpp5- unsloth6license: mit7datasets:8- b-mc2/sql-create-context9language:10- en11metrics:12- accuracy13base_model:14- microsoft/Phi-3-mini-4k-instruct15---16This 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 Features19- **Architecture:** Phi-3-mini (3.8B parameters)20- **Quantization:** Q4_K_M GGUF & Q5_K_M21- **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.gguf**25 26## Usage Instructions27 28### Ollama (Recommended)29To deploy locally:30 311. Download the `.gguf` file (Q4 or Q5).32 332. Create the Modelfile with the following instructions34 35```Dockerfile36FROM ./phi-3-mini-4k-instruct.Q4_K_M.gguf37 38TEMPLATE """<s><|user|>39Schema: {{ .System }}40Question: {{ .Prompt }}<|end|>41<|assistant|>42"""43 44# Parameters for SQL stability45PARAMETER stop "<|end|>"46PARAMETER stop "<s>"47PARAMETER stop "</s>"48PARAMETER temperature 0.049```50 513. Run ```ollama create phi3-sql-expert -f Modelfile```52 535. Run ```ollama run phi3-sql-expert "schema: CREATE TABLE table_name_7 (nba_draft VARCHAR, school VARCHAR) question: What was the NBA draft status for Northeast High School?"```54 556. The answer should be ```SELECT nba_draft FROM table_name_7 WHERE school = "Northeast"```56 57## Evaluation Data58The model was fine-tuned on the [sql-create-context dataset](https://huggingface.co/datasets/b-mc2/sql-create-context), focusing on:59 60- Mapping natural language to SQL queries with SELECT, WHERE, and JOIN statements.61- Understanding table schemas provided in the prompt.62- Maintaining strict SQL syntax in the response.63 64## Recommended Settings65Temperature: 0.0 or 0.1 (SQL requires deterministic output).66 67Stop Tokens: Ensure <|end|> is set as a stop sequence to prevent "infinite looping" generation.68 69Context Window: 2048 tokens.70 71**Model Developer**: [msquared](https://github.com/mrcmilano)72 73Base Model: [Phi-3-mini-4k-instruct](https://huggingface.co/microsoft/Phi-3-mini-4k-instruct) 