Downloads · 30 days
13
24% of all-time downloads
tdelard/Qwen3-4B-DBT-Instruct-LoRA
Qwen3-4B-DBT-Instruct-LoRA is a machine learning model from tdelard. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for peft. The card lists the license as apache-2.0.
QLoRA adapter fine-tuned on top of unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit (the pre-quantized 4-bit Unsloth variant of Qwen3-4B-Instruct) to convert natural language business questions into complete, multi-fil…
Downloads · 30 days
13
24% of all-time downloads
All-time downloads
54
Public
Repo size
276 MB
Likes
0
Public
Click a slice to open those files.
.safetensors264 MB · 94%
From the Hugging Face model README
QLoRA adapter fine-tuned on top of unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit (the pre-quantized 4-bit Unsloth variant of Qwen3-4B-Instruct) to convert natural language business questions into complete, multi-file dbt DAGs.
Looking for the ready-to-run GGUF (LM Studio / Ollama)? → tdelard/Qwen3-4b-DBT-Instruct-GGUF
Given a business question and a SQL schema, the model generates a full dbt project structure:
stg_*.sql files that clean and rename raw source data_sources.yml / _stg_*.yml schema files with column definitionsint_*.sql files that join and enrich staging datafct_*.sql or dim_*.sql final business modelsThis repo contains only the LoRA adapter weights (264 MB). You need to load the base model alongside the adapter.
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer
base_model_id = "unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit"
adapter_id = "tdelard/Qwen3-4B-DBT-Instruct-LoRA"
tokenizer = AutoTokenizer.from_pretrained(base_model_id)
model = AutoModelForCausalLM.from_pretrained(base_model_id, torch_dtype="auto", device_map="auto", load_in_4bit=True)
model = PeftModel.from_pretrained(model, adapter_id)
messages = [
{
"role": "system",
"content": (
"You are a dbt expert. Given a business question and a SQL schema, "
"generate a complete, production-ready dbt DAG including staging SQL files, "
"YAML schema files, intermediate models, and mart models. "
"Use proper dbt conventions: ref(), source(), naming prefixes (stg_, int_, fct_, dim_)."
),
},
{
"role": "user",
"content": (
"Business question: Show the total revenue per product category.\n"
"SQL context: CREATE TABLE orders (order_id INT, product_id INT, amount DECIMAL); "
"CREATE TABLE products (product_id INT, category VARCHAR, name VARCHAR);"
),
},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
output = model.generate(**inputs, max_new_tokens=1024, temperature=0.7, top_p=0.8, top_k=20)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
| Parameter | Value |
|---|---|
| Base model | unsloth/Qwen3-4B-Instruct-2507-unsloth-bnb-4bit |
| Training framework | Unsloth + TRL SFTTrainer |
| Method | QLoRA |
| LoRA rank | 32 |
| LoRA alpha | 32 |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Learning rate | 2e-4 |
| Max sequence length | 2048 tokens |
| Training loss masking | Responses only (train_on_responses_only) |
| Hardware | Google Colab T4 GPU (15 GB VRAM) |
| Training dataset | tdelard/text_to_dbt — 900 train / 100 eval |
Full training pipeline: thomasdlr/qwen3-dbt-instruct
Apache 2.0 — same as the base Qwen3-4B / Unsloth model.
Fine-tuned 2x faster using Unsloth.