Model reference · open weights

sqlcoder-2

LLMs defog Text gen 1 build Open weights 10k dl/mo

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.

  • sqlcoder-2 is a 6.7B parameter text-generation model developed by defog for converting natural language questions into SQL queries.
  • It is fine-tuned from CodeLlama-7B and supports a context length of 16,384 tokens.
  • The model is licensed under cc-by-sa-4.0 and is intended for read-only database analytics.

Summary of the defog/sqlcoder-7b-2 model card, 2026-10-01

What it is

Released bydefog
Released2024-02-05
Parameters6.7B
VRAM4.8 GB for the weights

What it runs on

Memory and cards for sqlcoder-7b-2 (FP16)

4.8 GBweights, file size
524 MBcache per 1K tokens
444 MBruntime overhead, at least
16,384 tokenscontext max
CardRequests at onceContext maxMemory
8K each
RTX 3060 12 GB111K11.6 GB
RTX 4060 Ti 16 GB2all 16K15.4 GB
RTX 3090 24 GB4all 16K23.4 GB
RTX 4090 24 GB4all 16K23.4 GB
RTX 5090 32 GB6all 16K31.0 GB
L40S 48 GB9all 16K44.0 GB
A100 80 GB16all 16K78.2 GB
H100 80 GB16all 16K78.1 GB
RTX PRO 6000 Blackwell 96 GB20all 16K93.8 GB
DGX Spark (GB10) 128 GB unified23all 16K107 GB
H200 141 GB30all 16K138 GB
B200 180 GB39all 16K176 GB
2× RTX 3060 12 GB
split by layers (llama.cpp)
4all 16K11.6 GB a card
2× RTX 4060 Ti 16 GB
split by layers (llama.cpp)
5all 16K15.4 GB a card
2× RTX 4090 24 GB
split by layers (llama.cpp)
9all 16K23.4 GB a card
2× RTX 3090 24 GB
split by layers (llama.cpp)
9all 16K23.4 GB a card
2× RTX 5090 32 GB
split by layers (llama.cpp)
13all 16K31.0 GB a card
Memory needed at each load
Requests at once8K tokens each
19.5 GB
526.7 GB
839.6 GB
1673.9 GB
32143 GB
64280 GB

One card, with vLLM's small-card settings.

From the model card

What defog says about sqlcoder-2

Read 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.

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.

dategroup_byorder_byratiojoinwhere
sqlcoder-70b9691.497.185.797.191.4
sqlcoder-7b-29691.494.391.494.377.1
sqlcoder-34b8094.385.777.185.780
gpt-47294.397.18091.480
gpt-4-turbo7691.491.462.888.677.1
natural-sql-7b5688.685.76088.680
sqlcoder-7b6482.974.354.374.374.3
gpt-3.57277.182.834.365.771.4
claude-25271.474.357.165.762.9

Model Card Contact

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.

© 2026 AxForge · EU-hosted AI infrastructure Pricing Docs Trust Privacy Terms