Instructions to use QuantFactory/sqlcoder-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use QuantFactory/sqlcoder-GGUF with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="QuantFactory/sqlcoder-GGUF")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("QuantFactory/sqlcoder-GGUF", dtype="auto") - llama-cpp-python
How to use QuantFactory/sqlcoder-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="QuantFactory/sqlcoder-GGUF", filename="sqlcoder.Q2_K.gguf", )
output = llm( "Once upon a time,", max_tokens=512, echo=True ) print(output)
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use QuantFactory/sqlcoder-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/sqlcoder-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/sqlcoder-GGUF:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf QuantFactory/sqlcoder-GGUF:Q4_K_M # Run inference directly in the terminal: llama-cli -hf QuantFactory/sqlcoder-GGUF:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf QuantFactory/sqlcoder-GGUF:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf QuantFactory/sqlcoder-GGUF:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf QuantFactory/sqlcoder-GGUF:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf QuantFactory/sqlcoder-GGUF:Q4_K_M
Use Docker
docker model run hf.co/QuantFactory/sqlcoder-GGUF:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use QuantFactory/sqlcoder-GGUF with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "QuantFactory/sqlcoder-GGUF" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/sqlcoder-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/QuantFactory/sqlcoder-GGUF:Q4_K_M
- SGLang
How to use QuantFactory/sqlcoder-GGUF with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "QuantFactory/sqlcoder-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/sqlcoder-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "QuantFactory/sqlcoder-GGUF" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "QuantFactory/sqlcoder-GGUF", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Ollama
How to use QuantFactory/sqlcoder-GGUF with Ollama:
ollama run hf.co/QuantFactory/sqlcoder-GGUF:Q4_K_M
- Unsloth Studio new
How to use QuantFactory/sqlcoder-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/sqlcoder-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for QuantFactory/sqlcoder-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for QuantFactory/sqlcoder-GGUF to start chatting
- Docker Model Runner
How to use QuantFactory/sqlcoder-GGUF with Docker Model Runner:
docker model run hf.co/QuantFactory/sqlcoder-GGUF:Q4_K_M
- Lemonade
How to use QuantFactory/sqlcoder-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull QuantFactory/sqlcoder-GGUF:Q4_K_M
Run and chat with the model
lemonade run user.sqlcoder-GGUF-Q4_K_M
List all available models
lemonade list
Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
---
|
| 3 |
+
|
| 4 |
+
license: other
|
| 5 |
+
language:
|
| 6 |
+
- en
|
| 7 |
+
metrics:
|
| 8 |
+
- code_eval
|
| 9 |
+
library_name: transformers
|
| 10 |
+
pipeline_tag: text-generation
|
| 11 |
+
tags:
|
| 12 |
+
- code
|
| 13 |
+
inference: false
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
[](https://hf.co/QuantFactory)
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# QuantFactory/sqlcoder-GGUF
|
| 21 |
+
This is quantized version of [defog/sqlcoder](https://huggingface.co/defog/sqlcoder) created using llama.cpp
|
| 22 |
+
|
| 23 |
+
# Original Model Card
|
| 24 |
+
|
| 25 |
+
# ARCHIVE NOTICE
|
| 26 |
+
This repository is now significantly outdated. You should use the repository at [sqlcoder-7b-2](https://huggingface.co/defog/sqlcoder-7b-2) instead. It is significantly better and consumes fewer GPU resources.
|
| 27 |
+
|
| 28 |
+
# Defog SQLCoder
|
| 29 |
+
Defog's SQLCoder is a state-of-the-art LLM for converting natural language questions to SQL queries.
|
| 30 |
+
|
| 31 |
+
[Interactive Demo](https://defog.ai/sqlcoder-demo) | [♾️ Colab](https://colab.research.google.com/drive/1z4rmOEiFkxkMiecAWeTUlPl0OmKgfEu7) | [🐦 Twitter](https://twitter.com/defogdata)
|
| 32 |
+
|
| 33 |
+
## TL;DR
|
| 34 |
+
SQLCoder is a 15B parameter model that slightly outperforms `gpt-3.5-turbo` for natural language to SQL generation tasks on our [sql-eval](https://github.com/defog-ai/sql-eval) framework, and significantly outperforms all popular open-source models. It also significantly outperforms `text-davinci-003`, a model that's more than 10 times its size.
|
| 35 |
+
|
| 36 |
+
SQLCoder is fine-tuned on a base StarCoder model.
|
| 37 |
+
|
| 38 |
+
## Results on novel datasets not seen in training
|
| 39 |
+
| model | perc_correct |
|
| 40 |
+
|-|-|
|
| 41 |
+
| gpt-4 | 74.3 |
|
| 42 |
+
| defog-sqlcoder | 64.6 |
|
| 43 |
+
| gpt-3.5-turbo | 60.6 |
|
| 44 |
+
| defog-easysql | 57.1 |
|
| 45 |
+
| text-davinci-003 | 54.3 |
|
| 46 |
+
| wizardcoder | 52.0 |
|
| 47 |
+
| starcoder | 45.1 |
|
| 48 |
+
|
| 49 |
+
## License
|
| 50 |
+
The model weights have a `CC BY-SA 4.0` license, with OpenRAIL-M clauses for responsible use attached. The TL;DR is that you can use and modify the model for any purpose – including commercial use. However, if you modify the weights (for example, by fine-tuning), you must open-source your modified weights under the same `CC BY-SA 4.0` license terms.
|
| 51 |
+
|
| 52 |
+
## Training
|
| 53 |
+
Defog was trained on 10,537 human-curated questions across 2 epochs. These questions were based on 10 different schemas. None of the schemas in the training data were included in our evaluation framework.
|
| 54 |
+
|
| 55 |
+
Training happened in 2 phases. The first phase was on questions that were classified as "easy" or "medium" difficulty, and the second phase was on questions that were classified as "hard" or "extra hard" difficulty.
|
| 56 |
+
|
| 57 |
+
The results of training on our easy+medium data were stored in a model called `defog-easy`. We found that the additional training on hard+extra-hard data led to a 7 percentage point increase in performance.
|
| 58 |
+
|
| 59 |
+
## Results by question category
|
| 60 |
+
We classified each generated question into one of 5 categories. The table displays the percentage of questions answered correctly by each model, broken down by category.
|
| 61 |
+
| query_category | gpt-4 | defog-sqlcoder | gpt-3.5-turbo | defog-easy | text-davinci-003 | wizard-coder | star-coder |
|
| 62 |
+
|-|-|-|-|-|-|-|-|
|
| 63 |
+
| group_by | 82.9 | 77.1 | 71.4 | 62.9 | 62.9 | 68.6 | 54.3 |
|
| 64 |
+
| order_by | 71.4 | 65.7 | 60.0 | 68.6 | 60.0 | 54.3 | 57.1 |
|
| 65 |
+
| ratio | 62.9 | 57.1 | 48.6 | 40.0 | 37.1 | 22.9 | 17.1 |
|
| 66 |
+
| table_join | 74.3 | 57.1 | 60.0 | 54.3 | 51.4 | 54.3 | 51.4 |
|
| 67 |
+
| where | 80.0 | 65.7 | 62.9 | 60.0 | 60.0 | 60.0 | 45.7 |
|
| 68 |
+
|
| 69 |
+
## Using SQLCoder
|
| 70 |
+
You can use SQLCoder via the `transformers` library by downloading our model weights from the HuggingFace repo. We have added sample code for inference [here](./inference.py). You can also use a demo on our website [here](https://defog.ai/sqlcoder-demo), or run SQLCoder in Colab [here](https://colab.research.google.com/drive/13BIKsqHnPOBcQ-ba2p77L5saiepTIwu0#scrollTo=ZpbVgVHMkJvC)
|
| 71 |
+
|
| 72 |
+
## Hardware Requirements
|
| 73 |
+
SQLCoder has been tested on an A100 40GB GPU with `bfloat16` weights. You can also load an 8-bit quantized version of the model on consumer GPUs with 20GB or more of memory – like RTX 4090, RTX 3090, and Apple M2 Pro, M2 Max, or M2 Ultra Chips with 20GB or more of memory.
|
| 74 |
+
|
| 75 |
+
## Todo
|
| 76 |
+
|
| 77 |
+
- [x] Open-source the v1 model weights
|
| 78 |
+
- [ ] Train the model on more data, with higher data variance
|
| 79 |
+
- [ ] Tune the model further with Reward Modelling and RLHF
|
| 80 |
+
- [ ] Pretrain a model from scratch that specializes in SQL analysis
|