Granite Code

Granite-20B-Code-Base-SQL-Gen

by IBM watsonx · Available; deploy-on-demand model in IBM watsonx.ai

IBM Granite-20B-Code-Base-SQL-Gen is a 20-billion-parameter text-to-SQL model for generating queries from natural-language questions and database schemas. It supports text input and output, has an 8,192-token context window, and is available as a deploy-on-demand model in watsonx.ai. Its SQL output requires validation, and IBM does not list a standalone token price in the supplied documentation.

Text Reasoning Coding
Granite-20B-Code-Base-SQL-Gen is an IBM Research model designed to turn questions written in ordinary language into SQL. It is intended for workflows where a system first identifies the relevant database tables, columns, and values, then asks the model to produce a query for the target database.
Outputs

What Granite-20B-Code-Base-SQL-Gen can produce

Text
Inputs

What it can understand

Text
Capabilities

Supported features

Fine-tuning
Model profile

Performance characteristics

5/10 Reasoning
7/10 Coding
4/10 Speed
5/10 Cost efficiency
Specifications

Technical details

Model family Granite Code
Model type Coding
Context window 8K tokens
Maximum output 8K tokens
Release date 2024-07-01
Status Available; deploy-on-demand model in IBM watsonx.ai
Knowledge cutoff notes

IBM's model card and current foundation-model documentation do not provide a verified knowledge-cutoff date for this exact model.

Model notes

IBM Research developed this 20-billion-parameter decoder-only model by fine-tuning Granite-20B-Code-Base on IBM's SQLInstruct dataset, Spider 1.0, and BIRD training data. It is intended as the final SQL-generation stage after relevant schema and content-linking information have been identified. IBM documentation states that the model is primarily fine-tuned using question/SQL pairs from SQLite databases, so performance may be limited for other SQL dialects unless dialect-specific post-processing or tuning is applied. IBM's current watsonx.ai model documentation lists the model as available and gives an 8,192-token context window. IBM system requirements indicate full fine-tuning is supported with compatible NVIDIA A100, H100, or H200 configurations. The model should be used with validation and safety testing because generated SQL can be incorrect or unsafe.

Cost

Model pricing

Input Not publicly listed as a standalone token price; IBM lists the model as deploy-on-demand.
Output Not publicly listed as a standalone token price; IBM lists the model as deploy-on-demand.
Model guide

Granite-20B-Code-Base-SQL-Gen: IBM’s Model for Natural-Language SQL

IBM Granite-20B-Code-Base-SQL-Gen is a 20-billion-parameter decoder-only language model fine-tuned specifically for text-to-SQL generation. It converts natural-language questions, database schemas, and schema-linking information into SQL queries, making it suitable for analytics assistants and SQL-generation pipelines rather than general-purpose chat.

What is Granite-20B-Code-Base-SQL-Gen?

Granite-20B-Code-Base-SQL-Gen is a specialized IBM Granite Code model for natural-language-to-SQL generation. A user might ask, “Which products had the highest sales last quarter?” The model uses that question together with information about the database schema and, where available, schema-linking details to generate a SQL query.

The model has 20 billion parameters and uses a decoder-only architecture. In practical terms, it generates text sequentially, with the generated text normally being SQL rather than a conversational answer. IBM describes it as a final SQL-generation stage: another part of the application should identify relevant schema elements and provide them in the prompt before this model is called.

It is currently listed in IBM watsonx.ai’s foundation-model catalog as an available deploy-on-demand model. The model is also documented through IBM’s Granite and watsonx materials. Its release date is listed as July 1, 2024.

Primary purpose and recommended workflow

The model is built for text-to-SQL tasks over databases that may not have appeared in its training data. IBM’s documented training sources include the SQLInstruct dataset, Spider 1.0, and BIRD data. The model was fine-tuned from Granite-20B-Code-Base and is intended to use question-and-SQL examples and database context to produce a query.

A practical application usually separates the task into stages:

  1. Understand the question: identify the requested measure, filters, grouping, sorting, and time range.
  2. Link the question to the schema: find the relevant tables, columns, relationships, and possibly representative values.
  3. Generate SQL: provide the question and selected schema information to Granite-20B-Code-Base-SQL-Gen.
  4. Validate before execution: check the syntax, referenced objects, permissions, expected result shape, and query safety.

This division matters because the model is not a database engine. It does not directly execute queries or independently verify that a generated query returns the intended result.

Verified specifications

SpecificationDetails
ProviderIBM
Model familyGranite Code
Parameters20 billion
ArchitectureDecoder-only language model
Primary taskNatural-language-to-SQL generation
Context window8,192 tokens
Maximum new tokens8,192 tokens
InputText
OutputText, normally SQL
Fine-tuningSupported; IBM system requirements document compatible NVIDIA A100, H100, or H200 configurations for full fine-tuning
AvailabilityAvailable as a deploy-on-demand model in IBM watsonx.ai

The 8,192-token context limit covers the prompt and supplied context, including the natural-language question, schema descriptions, linking information, examples, and other instructions. Large schemas may therefore need to be reduced or retrieved selectively before they are sent to the model. IBM’s catalog also lists 8,192 maximum new tokens, although normal SQL queries will generally be much shorter than that ceiling.

Main strengths and limitations

Strengths

  • Task specialization: the model is fine-tuned for SQL generation instead of being used as an unrestricted general-purpose chatbot.
  • Schema-independent design: it is intended to work with previously unseen databases when the relevant schema and linking information are supplied.
  • Enterprise deployment context: its availability through watsonx.ai makes it relevant to organizations building governed analytics or data-assistance workflows.
  • Fine-tuning path: IBM documents full fine-tuning support on compatible NVIDIA hardware, which may help organizations adapt the model to a particular SQL dialect or internal conventions.

Limitations

  • SQL is not guaranteed to be correct: a generated query can use the wrong table, column, join, filter, or aggregation even when it looks syntactically valid.
  • Database execution is outside the model: an application must execute and validate the query separately, with appropriate access controls and safeguards.
  • Dialect considerations: IBM notes that the model was primarily fine-tuned using question-and-SQL pairs from SQLite databases. Other dialects may require post-processing, prompting, validation, or additional tuning.
  • Limited context: the 8,192-token window can become restrictive when a database has many tables or when the prompt includes extensive documentation and examples.
  • Narrower scope than general chat models: it is not intended for broad conversational assistance, multimodal work, or unrelated content-generation tasks.

Capabilities, modalities, and tools

Granite-20B-Code-Base-SQL-Gen accepts text and produces text. It does not have verified image, audio, or video input or output. Its output is not direct database action: the model generates a textual SQL statement that another system may later inspect and execute.

The supplied model information does not verify built-in function calling, tool use, web search, streaming, batch processing, caching, or a dedicated JSON mode for this model. Applications can still wrap the model in a larger workflow, but that should not be confused with a model-level tool-calling capability.

Its coding capability is specialized rather than broad. SQL generation is a form of code generation, and the model is a reasonable fit when the desired artifact is a query. It should not automatically be treated as a general software-programming model for tasks such as application architecture, debugging across many programming languages, or repository-level code changes.

Reasoning, speed, and cost trade-offs

The model performs the reasoning needed to map a question and schema to a likely SQL sequence, but the supplied documentation does not identify a separate chain-of-thought or configurable reasoning mode. It should therefore be evaluated as a specialized generation model, not as a verified reasoning-focused system.

As an editorial assessment, the available data rates its reasoning at 5 out of 10, coding at 7 out of 10, speed at 4 out of 10, and cost at 5 out of 10. These are comparative editorial scores, not IBM-published benchmark results. The coding score reflects the model’s SQL specialization; the lower speed assessment is consistent with evaluating a 20-billion-parameter model against smaller text-to-SQL or general-purpose alternatives, but actual latency depends on deployment hardware, configuration, prompt size, and service load.

IBM does not publish a standalone per-token input or output price for this model in the supplied research. Instead, it is listed as deploy-on-demand in watsonx.ai. Buyers should therefore confirm the applicable deployment, compute, and account pricing with IBM rather than assuming a token rate from another watsonx model.

When to choose this model

Choose Granite-20B-Code-Base-SQL-Gen when the central requirement is generating SQL from natural-language questions and you can provide a carefully selected schema context. It is especially suitable for:

  • analytics assistants that draft queries for human review;
  • natural-language interfaces over structured enterprise databases;
  • the SQL-generation stage of a retrieval and schema-linking pipeline;
  • teams that want an IBM Granite model in a watsonx.ai deployment;
  • organizations that need the option to fine-tune or post-process output for internal SQL conventions.

It is less suitable when the application needs a general conversational model, direct database execution, multimodal input, built-in external tools, or dependable support for a specialized SQL dialect without additional engineering. A smaller model may be preferable when low latency and lower deployment cost matter more than using a 20-billion-parameter specialist. A general-purpose coding or reasoning model may be a better choice when SQL is only one small part of a broader programming task.

Validation and safe deployment

Generated SQL should be treated as an untrusted draft. Before execution, applications should validate that referenced tables and columns exist, restrict the permitted operations, apply authorization for the requesting user, and consider read-only database credentials for exploratory analytics. Query timeouts, row limits, cost controls, and logging can reduce the impact of inefficient or unintended statements.

Evaluation should include questions involving joins, ambiguous terms, missing values, date boundaries, aggregation, nested queries, and dialect-specific syntax. Testing only whether SQL parses is not enough: a syntactically valid query can still answer the wrong business question. Human review or an independent database-validation step remains important for high-impact reporting.

Bottom line

Granite-20B-Code-Base-SQL-Gen is a focused IBM model for converting natural-language data questions into SQL. Its strongest case is a structured text-to-SQL pipeline that supplies schema context, validates the result, and handles execution outside the model. Its specialization and watsonx.ai availability are useful for enterprise analytics workflows, while the 8,192-token context, SQLite-oriented fine-tuning background, lack of verified built-in tools, and unlisted standalone token pricing are important constraints to consider before deployment.


Answers to Frequently Asked Questions

What are the limitations of Granite-20B-Code-Base-SQL-Gen?
The model can generate incorrect tables, joins, filters, aggregations, or SQL syntax, even when the output appears valid. Its context window may be restrictive for large schemas, and its fine-tuning was primarily based on SQLite-oriented question-and-SQL data, so other SQL dialects may require additional prompting, post-processing, validation, or fine-tuning. Standalone per-token pricing and built-in tool-calling capabilities are not verified in the supplied information.
What are the main specifications of Granite-20B-Code-Base-SQL-Gen?
The model has 20 billion parameters, uses a decoder-only architecture, supports text input and text output, and has an 8,192-token context window and an 8,192-token maximum-new-token limit. It is available as a deploy-on-demand model in IBM watsonx.ai and supports fine-tuning on compatible NVIDIA A100, H100, or H200 configurations.
What is Granite-20B-Code-Base-SQL-Gen used for?
Granite-20B-Code-Base-SQL-Gen is an IBM Granite Code model designed to convert natural-language questions into SQL queries. It is intended for text-to-SQL workflows where an application provides the user’s question together with relevant database schema and schema-linking information.
Does Granite-20B-Code-Base-SQL-Gen execute or validate SQL queries?
No. The model generates SQL as text but does not execute queries or independently verify that they are correct. Applications must validate syntax, referenced tables and columns, permissions, query safety, and whether the query answers the intended business question before execution.


Sources 5
Provider

About IBM watsonx