Downloads · 30 days
0
thefounder03/qlora-nl2sql-qwen2.5-7b
qlora-nl2sql-qwen2.5-7b is a machine learning model from thefounder03. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
[](https://github.com/dhruvkachhela/finetunningQLORA)
Downloads · 30 days
0
Access
Public
Updated Jul 17, 2026
Repo size
10.1 MB
Likes
0
Public
Click a slice to open those files.
.pt10.1 MB · 100%
From the Hugging Face model README
This repository contains LoRA adapter weights fine-tuned on the Spider text-to-SQL dataset.
The base model was quantized to 4-bit NormalFloat (NF4) using a custom, from-scratch PyTorch implementation of block-wise quantization and 8-bit double quantization of scale factors, then injected with trainable LoRA adapters on attention projection layers.
Qwen/Qwen2.5-7B-Instructq_proj, v_projrichardr1126/spider-schema.0.2434 at step 350 / 1000Since these weights were trained using a custom from-scratch PyTorch quantization class, loading the model requires replacing the linear layers with QuantizedLinear before copying the adapter weights:
import torch
from transformers import AutoModelForCausalLM
# 1. Load base model
base_model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-7B-Instruct",
torch_dtype=torch.float16,
device_map="auto"
)
# 2. Re-create the NF4 codebook
cb = make_nf4_codebook()
# 3. Swap linear layers to custom QuantizedLinear in-place
for layer in base_model.model.layers:
layer.self_attn.q_proj = QuantizedLinear.from_linear(layer.self_attn.q_proj, cb)
layer.self_attn.v_proj = QuantizedLinear.from_linear(layer.self_attn.v_proj, cb)
# 4. Inject LoRA adapters
inject_lora(base_model, r=8, alpha=16)
# 5. Load adapter weights from checkpoint
checkpoint = torch.load("best_qlora_checkpoint.pt")
lora_state = checkpoint["lora_state_dict"]
for name, param in base_model.named_parameters():
if name in lora_state:
param.data.copy_(lora_state[name].to(param.device))
print("Model successfully loaded with custom quantized weights!")