Instructions to use amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2") model = AutoModelForCausalLM.from_pretrained("amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2
- SGLang
How to use amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2 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 "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2" \ --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": "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2", "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 "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2" \ --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": "amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2 with Docker Model Runner:
docker model run hf.co/amalnuaimi/sqlcoder-7b-2-6.0bpw-exl2
Update notice
The model weights were updated at 7 AM UTC on Feb 7, 2024. The new model weights lead to a much more performant model โ particularly for joins.
If you downloaded the model before that, please redownload the weights for best performance.
Model Card for SQLCoder-7B-2
A capable large language model for natural language to SQL generation.
Model Details
Model Description
This is the model card of a ๐ค transformers model that has been pushed on the Hub. This model card has been automatically generated.
- Developed by: Defog, Inc
- Model type: [Text to SQL]
- License: [CC-by-SA-4.0]
- Finetuned from model: [CodeLlama-7B]
Model Sources [optional]
Uses
This model is intended to be used by non-technical users to understand data inside their SQL databases. It is meant as an analytics tool, and not as a database admin tool.
This model has not been trained to reject malicious requests from users with write access to databases, and should only be used by users with read-only access.
How to Get Started with the Model
Use the code here to get started with the model.
Prompt
Please use the following prompt for optimal results. Please remember to use do_sample=False and num_beams=4 for optimal results.
### Task
Generate a SQL query to answer [QUESTION]{user_question}[/QUESTION]
### Database Schema
The query will run on a database with the following schema:
{table_metadata_string_DDL_statements}
### Answer
Given the database schema, here is the SQL query that [QUESTION]{user_question}[/QUESTION]
[SQL]
Evaluation
This model was evaluated on SQL-Eval, a PostgreSQL based evaluation framework developed by Defog for testing and alignment of model capabilities.
You can read more about the methodology behind SQLEval here.
Results
We classified each generated question into one of 6 categories. The table displays the percentage of questions answered correctly by each model, broken down by category.
| date | group_by | order_by | ratio | join | where | |
|---|---|---|---|---|---|---|
| sqlcoder-70b | 96 | 91.4 | 97.1 | 85.7 | 97.1 | 91.4 |
| sqlcoder-7b-2 | 96 | 91.4 | 94.3 | 91.4 | 94.3 | 77.1 |
| sqlcoder-34b | 80 | 94.3 | 85.7 | 77.1 | 85.7 | 80 |
| gpt-4 | 72 | 94.3 | 97.1 | 80 | 91.4 | 80 |
| gpt-4-turbo | 76 | 91.4 | 91.4 | 62.8 | 88.6 | 77.1 |
| natural-sql-7b | 56 | 88.6 | 85.7 | 60 | 88.6 | 80 |
| sqlcoder-7b | 64 | 82.9 | 74.3 | 54.3 | 74.3 | 74.3 |
| gpt-3.5 | 72 | 77.1 | 82.8 | 34.3 | 65.7 | 71.4 |
| claude-2 | 52 | 71.4 | 74.3 | 57.1 | 65.7 | 62.9 |
Model Card Contact
Contact us on X at @defogdata, or on email at founders@defog.ai
- Downloads last month
- 2
