Model reference · open weights
sqlcoder-2 is an open-weight language model from defog. sqlcoder-7b-2 (FP16) weighs 4.8 GB; the smallest configuration that runs it is RTX 3060 12 GB.
For self-hosting, compare this build's requirements below with the GPU you plan to rent.
Summary of the defog/sqlcoder-7b-2 model card, 2026-10-01
What it is
| Released by | defog |
|---|---|
| Released | 2024-02-05 |
| Parameters | 6.7B |
| VRAM | 4.8 GB for the weights |
What it runs on
| Card | Requests at once | Context max | Memory |
|---|---|---|---|
| 8K each | |||
| RTX 3060 12 GB | 1 | 11K | 11.6 GB |
| RTX 4060 Ti 16 GB | 2 | all 16K | 15.4 GB |
| RTX 3090 24 GB | 4 | all 16K | 23.4 GB |
| RTX 4090 24 GB | 4 | all 16K | 23.4 GB |
| RTX 5090 32 GB | 6 | all 16K | 31.0 GB |
| L40S 48 GB | 9 | all 16K | 44.0 GB |
| A100 80 GB | 16 | all 16K | 78.2 GB |
| H100 80 GB | 16 | all 16K | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | 20 | all 16K | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | 23 | all 16K | 107 GB |
| H200 141 GB | 30 | all 16K | 138 GB |
| B200 180 GB | 39 | all 16K | 176 GB |
| 2× RTX 3060 12 GB split by layers (llama.cpp) | 4 | all 16K | 11.6 GB a card |
| 2× RTX 4060 Ti 16 GB split by layers (llama.cpp) | 5 | all 16K | 15.4 GB a card |
| 2× RTX 4090 24 GB split by layers (llama.cpp) | 9 | all 16K | 23.4 GB a card |
| 2× RTX 3090 24 GB split by layers (llama.cpp) | 9 | all 16K | 23.4 GB a card |
| 2× RTX 5090 32 GB split by layers (llama.cpp) | 13 | all 16K | 31.0 GB a card |
| Requests at once | 8K tokens each |
|---|---|
| 1 | 9.5 GB |
| 5 | 26.7 GB |
| 8 | 39.6 GB |
| 16 | 73.9 GB |
| 32 | 143 GB |
| 64 | 280 GB |
One card, with vLLM's small-card settings.
From the model card
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.
A capable large language model for natural language to SQL generation.
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
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.
Use the code here to get started with the model.
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]
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.
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 |
Contact us on X at @defogdata, or on email at founders@defog.ai
Quoted from the model card on Hugging Face. The full card is behind the Hugging Face link above.