Downloads · 30 days
14
8% of all-time downloads
Nuxera/duckdb-nsql-7b-mlx-4bit
duckdb-nsql-7b-mlx-4bit 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 4-bit quantized variant of motherduckdb/DuckDB-NSQL-7B-v0.1, intended for maximum efficiency (lowest memory, fastest decoding) on Apple Silicon (M1/M2/M3/M4).
Downloads · 30 days
14
8% of all-time downloads
All-time downloads
173
Public
Parameters
6.7B
17.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors3.8 GB · 100%
How the weights are stored.
U326.7B · 100%
From the Hugging Face model README
This repository contains an MLX-optimized 4-bit quantized variant of motherduckdb/DuckDB-NSQL-7B-v0.1, intended for maximum efficiency (lowest memory, fastest decoding) 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 4-bit MLX conversion targets minimal memory usage and high throughput, with a larger quality trade-off compared to FP16/8-bit—especially for long schemas and complex queries.
pip install mlx-lm
from mlx_lm import load, generate
model, tokenizer = load("Nuxera/duckdb-nsql-7b-mlx-4bit")
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-4bit --port 8080
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):
4-bit can degrade more than 8-bit/FP16 when prompts include:
If you need maximum reliability, prefer FP16 or 8-bit.
This model inherits the Llama 2 license from the base model.
@misc{nuxera_duckdb_nsql_mlx_4bit,
title={DuckDB-NSQL-7B MLX 4-bit Quantized Conversion},
author={Nuxera AI},
year={2025},
publisher={Hugging Face},
howpublished={\url{https://huggingface.co/Nuxera/duckdb-nsql-7b-mlx-4bit}}
}
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}}
}