Downloads · 30 days
18
11% of all-time downloads
Nuxera/duckdb-nsql-7b-mlx-8bit
duckdb-nsql-7b-mlx-8bit is a text generation model from Nuxera. Use it when you need the model to write or continue text. It is set up for mlx. The card lists the license as llama2.
This repository contains an MLX-optimized 8-bit quantized variant of motherduckdb/DuckDB-NSQL-7B-v0.1, intended for fast, memory-efficient inference on Apple Silicon (M1/M2/M3/M4).
Downloads · 30 days
18
11% of all-time downloads
All-time downloads
165
Public
Parameters
6.7B
20.6 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors7.2 GB · 100%
How the weights are stored.
U326.7B · 100%
From the Hugging Face model README
This repository contains an MLX-optimized 8-bit quantized variant of motherduckdb/DuckDB-NSQL-7B-v0.1, intended for fast, memory-efficient inference on Apple Silicon (M1/M2/M3/M4).
DuckDB-NSQL-7B is a 7B parameter language model fine-tuned to translate natural language questions into DuckDB SQL. The 8-bit MLX conversion reduces RAM/VRAM usage significantly versus FP16 while typically preserving near-FP16 quality for most NL→SQL workloads.
pip install mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("Nuxera/duckdb-nsql-7b-mlx-8bit")
schema = """
CREATE TABLE hospitals (
hospital_id BIGINT,
hospital_name VARCHAR,
region VARCHAR,
bed_capacity INTEGER
);
CREATE TABLE encounters (
encounter_id BIGINT,
hospital_id BIGINT,
encounter_datetime TIMESTAMP,
encounter_type VARCHAR
);
"""
question = "For each hospital region, how many encounters happened this month?"
prompt = f"""You are an assistant that writes valid DuckDB SQL queries.
### Schema:
{schema}
### Question:
{question}
### Response (DuckDB SQL only):"""
out = generate(model, tokenizer, prompt=prompt, max_tokens=256, temp=0.0)
print(out)
mlx_lm.server --model Nuxera/duckdb-nsql-7b-mlx-8bit --port 8080
curl -X POST http://localhost:8080/v1/completions -H "Content-Type: application/json" -d '{
"prompt": "### Schema:\nCREATE TABLE patients(...);\n\n### Question:\nCount patients by region\n\n### Response (DuckDB SQL only):",
"max_tokens": 200,
"temperature": 0
}'
This model works best when you provide:
Example:
You are an assistant that writes valid DuckDB SQL queries.
### Schema:
CREATE TABLE ...
### Question:
...
### Response (DuckDB SQL only):
This model inherits the Llama 2 license from the base model.
@misc{nuxera_duckdb_nsql_mlx_8bit,
title={DuckDB-NSQL-7B MLX 8-bit Quantized Conversion},
author={Nuxera AI},
year={2025},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/Nuxera/duckdb-nsql-7b-mlx-8bit}}
}
Base model:
@misc{duckdb_nsql,
title={DuckDB-NSQL-7B: Natural Language to SQL for DuckDB},
author={MotherDuck},
year={2024},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/motherduckdb/DuckDB-NSQL-7B-v0.1}}
}