Skip to content
← Models
Open weightsDefog/10 trustMetrics-checked
SQLCoder logo

SQLCoder

Defog's open text-to-SQL model family that claims to beat GPT-4 at turning plain English into SQL.

Visit official page →

About

SQLCoder is a family of models from Defog.ai built for one job: converting natural language questions into SQL queries. The line runs from early 15B StarCoder and CodeLlama variants up to the current sqlcoder-7b-2, trained on 20,000+ human-curated questions across ten schemas that were kept out of the evaluation set. The flagship 7B-2 runs on a CodeLlama-7B base with a 16K context window and supports beam search for harder queries.

Defog's claim is that SQLCoder outperforms GPT-4 and GPT-4-turbo on their sql-eval framework of 200 questions on novel schemas, and it materially beats every other popular open-source model they tested. The weights carry a CC BY-SA 4.0 license with extra responsible-use restrictions, which means commercial use is allowed but fine-tuned derivatives must be shared under the same terms. It ships with a small pip package, an Apple Silicon build, and a demo that wires it straight to your database.

Specs

Context window

16,384 tokens (sqlcoder-7b-2)

Pricing

Free / open weights (CC BY-SA 4.0)

Free quota

Free / open weights — self-host at no license cost; modified weights must be shared under CC BY-SA 4.0

API access

Self-hosted via Hugging Face (defog/sqlcoder-7b-2) and the sqlcoder pip package; interactive demo on defog.ai

Weights

Open weights

Released

Not disclosed

Benchmarks

  • Defog sql-eval (200 questions on novel schemas): claimed to outperform GPT-4 and GPT-4-turbo (provider-reported)
  • Spider: ~83% execution accuracy claimed by third-party tables (unverified; not Defog's official metric)

Provider-reported unless a source says otherwise. Benchmarks are marketing-adjacent by nature — treat them as directional.

Use cases

text-to-sqldata-analyticsbi-copilotsdatabase-interfaces

Trust score — 7/10

/10 trustMetrics-checked

Scored 7/10 (metrics tier, metrics-v1). Evidence: official Defog repo and HF cards document training (20k human-curated questions, held-out eval schemas) and the CC BY-SA 4.0 license; the sql-eval framework is public. Strengths: focused, well-maintained text-to-SQL line with pip packaging and multi-platform builds. Docked for: (1) the headline GPT-4 comparison is vendor-run on their own 200-question benchmark with no independent replication; (2) share-alike license plus responsible-use restrictions complicate commercial reuse; (3) line has not had a major release since early 2024.

How the trust score is built

Full methodology →
Adoption · stars/downloads, log-scaled vs peers
7.0/10
Maintenance · recency, releases, issue load
6.0/10
Openness · license + docs
7.0/10
Manual review · sanity read + red-flag check
7.0/10
  • · Public sql-eval framework; training on 20k held-out-schema questions
  • · GPT-4 comparison is vendor-run on own 200-question benchmark; no major release since early 2024

Sources