Marketplace · Text & chat
duckdb-nsql:7b
Call duckdb-nsql:7b through one OpenAI-compatible API. It's served by 1 host on the Inpherio grid, each at a price it sets — your request goes to the cheapest healthy one, and fails over to the next if it's down.
At a glance.
code sql
from openai import OpenAI
client = OpenAI(base_url="https://inpherio.co.uk/v1",
api_key=INPHERIO_API_KEY)
reply = client.chat.completions.create(
model="duckdb-nsql:7b",
messages=[{"role": "user", "content": "Hello"}],
)duckdb-nsql:7b in detail.
7B parameter text-to-SQL model made by MotherDuck and Numbers Station.
- Published by
- motherduckdb
- Parameters
- 6.7B
- Download size
- 3.8 GB (as packaged for Ollama)
- Quantisation
- Q4_0
- Format
- gguf
- Architecture
- llama
- Licence
- Llama 2 licence
- Based on
- meta-llama/Llama-2-7b
- Task
- text generation
- Library
- transformers
- First published
- 24 Jan 2024
- Last updated
- 26 Jan 2024
- Downloads (30 days)
- 62 on Hugging Face
- Likes
- 106
llama text-generation
The model card
Published by the model's authors on Hugging Face — shown as they wrote it, unedited by Inpherio.
DuckDB-NSQL-7B
Model Description
NSQL is a family of autoregressive open-source large foundation models (FMs) designed specifically for SQL generation tasks.
In this repository we are introducing a new member of NSQL, DuckDB-NSQL. It's based on Meta's original Llama-2 7B model and further pre-trained on a dataset of general SQL queries and then fine-tuned on a dataset composed of DuckDB text-to-SQL pairs.
Training Data
200k DuckDB text-to-SQL pairs, synthetically generated using Mixtral-8x7B-Instruct-v0.1, guided by the DuckDB v0.9.2 documentation. And text-to-SQL pairs from NSText2SQL that were transpiled to DuckDB SQL using sqlglot.
Evaluation Data
We evaluate our models on a DuckDB-specific benchmark that contains 75 text-to-SQL pairs. The benchmark is available here.
Training Procedure
DuckDB-NSQL was trained using cross-entropy loss to maximize the likelihood of sequential inputs. For finetuning on text-to-SQL pairs, we only compute the loss over the SQL portion of the pair. The model is trained using 80GB A100s, leveraging data and model parallelism. We fine-tuned for 10 epochs.
Intended Use and Limitations
The model was designed for text-to-SQL generation tasks from given table schema and natural language prompts. The model works best with the prompt format defined below and outputs. In contrast to existing text-to-SQL models, the SQL generation is not contrained to SELECT statements, but can generate any valid DuckDB SQL statement, including statements for official DuckDB extensions.
How to Use
Example 1:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1")
model = AutoModelForCausalLM.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1", torch_dtype=torch.bfloat16)
text = """### Instruction:
Your task is to generate valid duckdb SQL to answer the following question.
### Input:
### Question:
create a new table called tmp from test.csv
### Response (use duckdb shorthand if possible):
"""
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=500)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
Example 2:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1")
model = AutoModelForCausalLM.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1", torch_dtype=torch.bfloat16)
text = """### Instruction:
Your task is to generate valid duckdb SQL to answer the following question, given a duckdb database schema.
### Input:
Here is the database schema that the SQL query will run on:
CREATE TABLE taxi (
VendorID bigint,
tpep_pickup_datetime timestamp,
tpep_dropoff_datetime timestamp,
passenger_count double,
trip_distance double,
fare_amount double,
extra double,
tip_amount double,
tolls_amount double,
improvement_surcharge double,
total_amount double,
);
### Question:
get all columns ending with _amount from taxi table
### Response (use duckdb shorthand if possible):"""
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=500)
print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
Example 3:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1")
model = AutoModelForCausalLM.from_pretrained("motherduckdb/DuckDB-NSQL-7B-v0.1", torch_dtype=torch.bfloat16)
text = """### Instruction:
Your task is to generate valid duckdb SQL to answer the following question, given a duckdb database schema.
Read the rest of the model card
Input:
Here is the database schema that the SQL query will run on: CREATE TABLE rideshare ( hvfhs_license_num varchar, dispatching_base_num varchar, originating_base_num varchar, request_datetime timestamp, on_scene_datetime timestamp, pickup_datetime timestamp, dropoff_datetime timestamp, trip_miles double, trip_time bigint,
);
Question:
get longest trip in december 2022
Response (use duckdb shorthand if possible):
"""
input_ids = tokenizer(text, return_tensors="pt").input_ids
generated_ids = model.generate(input_ids, max_length=500) print(tokenizer.decode(generated_ids[0], skip_special_tokens=True))
For more information (e.g., run with your local database), please find examples in [this repository](https://github.com/NumbersStationAI/DuckDB-NSQL).Sources: motherduckdb/DuckDB-NSQL-7B-v0.1 on Hugging Face · duckdb-nsql:7b on Ollama. Collected from public sources on 8 Nov 2026; the host serving it may run a different build or quantisation — the marketplace shows each host's own measurements.
Who's serving it.
Every host benchmarked this model on its own hardware before serving it. Prices are set by each host; health is scored by the platform from what it observes.
| Host | Tier | Price | Measured speed | Health | State | Rent |
|---|---|---|---|---|---|---|
| GTX 1080 Ti (11G) | L1 | £0.043 in · £0.086 out | 5 tok/s · 152 ms first token | 78 | loads on request | £0.60/h |
Live data, refreshed on every visit. How billing works.
Room on the grid for your machine.
Right now one machine serves duckdb-nsql:7b. If it drops, so does every request for it — a second host is what turns it into failover, and the grid needs that more than another copy. The router weighs price, measured speed, health and whether the model is already loaded — so a host with a sharper price or quicker hardware wins the next call.
Set your own price — you keep 85% of what it earns, and new hosts start with 12 months fee-free (up to £250 of earnings). A payout fee of £2 + 1% per payout to a UK bank account, £2 + 2% to any other country applies when you're paid. Install the connector, load duckdb-nsql:7b, and the platform benchmarks it on your hardware before your first request.