Downloads · 30 days
117
5% of all-time downloads
RichardErkhov/motherduckdb_-_DuckDB-NSQL-7B-v0.1-gguf
motherduckdb_-_DuckDB-NSQL-7B-v0.1-gguf is a machine learning model from RichardErkhov. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
117
5% of all-time downloads
All-time downloads
2.3K
Public
Repo size
76.6 GB
Likes
0
Public
Click a slice to open those files.
.gguf88.7 GB · 100%
From the Hugging Face model README
Quantization made by Richard Erkhov.
DuckDB-NSQL-7B-v0.1 - GGUF
| Name | Quant method | Size |
|---|---|---|
| DuckDB-NSQL-7B-v0.1.Q2_K.gguf | Q2_K | 2.36GB |
| DuckDB-NSQL-7B-v0.1.IQ3_XS.gguf | IQ3_XS | 2.6GB |
| DuckDB-NSQL-7B-v0.1.IQ3_S.gguf | IQ3_S | 2.75GB |
| DuckDB-NSQL-7B-v0.1.Q3_K_S.gguf | Q3_K_S | 2.75GB |
| DuckDB-NSQL-7B-v0.1.IQ3_M.gguf | IQ3_M | 2.9GB |
| DuckDB-NSQL-7B-v0.1.Q3_K.gguf | Q3_K | 3.07GB |
| DuckDB-NSQL-7B-v0.1.Q3_K_M.gguf | Q3_K_M | 3.07GB |
| DuckDB-NSQL-7B-v0.1.Q3_K_L.gguf | Q3_K_L | 3.35GB |
| DuckDB-NSQL-7B-v0.1.IQ4_XS.gguf | IQ4_XS | 3.4GB |
| DuckDB-NSQL-7B-v0.1.Q4_0.gguf | Q4_0 | 3.56GB |
| DuckDB-NSQL-7B-v0.1.IQ4_NL.gguf | IQ4_NL | 3.58GB |
| DuckDB-NSQL-7B-v0.1.Q4_K_S.gguf | Q4_K_S | 3.59GB |
| DuckDB-NSQL-7B-v0.1.Q4_K.gguf | Q4_K | 3.8GB |
| DuckDB-NSQL-7B-v0.1.Q4_K_M.gguf | Q4_K_M | 3.8GB |
| DuckDB-NSQL-7B-v0.1.Q4_1.gguf | Q4_1 | 3.95GB |
| DuckDB-NSQL-7B-v0.1.Q5_0.gguf | Q5_0 | 4.33GB |
| DuckDB-NSQL-7B-v0.1.Q5_K_S.gguf | Q5_K_S | 4.33GB |
| DuckDB-NSQL-7B-v0.1.Q5_K.gguf | Q5_K | 4.45GB |
| DuckDB-NSQL-7B-v0.1.Q5_K_M.gguf | Q5_K_M | 4.45GB |
| DuckDB-NSQL-7B-v0.1.Q5_1.gguf | Q5_1 | 4.72GB |
| DuckDB-NSQL-7B-v0.1.Q6_K.gguf | Q6_K | 5.15GB |
| DuckDB-NSQL-7B-v0.1.Q8_0.gguf | Q8_0 | 6.67GB |
license: llama2 inference: parameters: do_sample: false max_length: 200 base_model: meta-llama/Llama-2-7b widget:
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.
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.
We evaluate our models on a DuckDB-specific benchmark that contains 75 text-to-SQL pairs. The benchmark is available here.
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.
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.
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.
### 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.