Downloads · 30 days
9
26% of all-time downloads
shoron07/mistral-7b-dolly-qlora
mistral-7b-dolly-qlora is a text generation model from shoron07. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This repository contains a QLoRA adapter trained on top of mistralai/Mistral-7B-v0.3 using the databricks/databricks-dolly-15k instruction dataset.
Downloads · 30 days
9
26% of all-time downloads
All-time downloads
35
Public
Repo size
168 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 97%
From the Hugging Face model README
This repository contains a QLoRA adapter trained on top of
mistralai/Mistral-7B-v0.3 using the databricks/databricks-dolly-15k instruction dataset.
The base model was loaded using 4-bit NF4 quantization and remained frozen. Only the LoRA adapter parameters were optimized.
| Setting | Value |
|---|---|
| Base model | mistralai/Mistral-7B-v0.3 |
| Training examples | 11,850 |
| Validation examples | 1,447 |
| Test examples | 1,446 |
| Epochs | 1 |
| Maximum sequence length | 1,024 |
| Quantization | 4-bit NF4 |
| Double quantization | Enabled |
| LoRA rank | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.05 |
| Learning rate | 2e-4 |
| Optimizer | Paged AdamW 8-bit |
| Completion-only loss | Enabled |
| Trainable parameters | 41,943,040 |
| Trainable percentage | 0.5754% |
The adapter targeted the q_proj, k_proj, v_proj, o_proj,
gate_proj, up_proj, and down_proj linear layers.
Eight exact duplicates were removed. Repeated complete inputs were assigned only to training, producing zero instruction-plus-context overlap among the training, validation, and test splits.
Examples longer than 1,024 tokens were filtered instead of silently truncated.
These results use all 1,446 untouched test examples.
| Metric | Base Mistral | QLoRA adapted |
|---|---|---|
| Test loss | 3.0392 | 2.5306 |
| Perplexity | 20.8891 | 12.5609 |
| Mean token accuracy | 0.6565 | 0.6912 |
Generation was evaluated on a reproducible balanced sample of 80 held-out examples, containing 10 examples from every Dolly category.
| Metric | Base Mistral | QLoRA adapted |
|---|---|---|
| ROUGE-1 F1 | 0.1806 | 0.4392 |
| ROUGE-2 F1 | 0.0690 | 0.2628 |
| ROUGE-L F1 | 0.1380 | 0.3713 |
| BERTScore F1 | 0.8188 | 0.8884 |
QLoRA achieved a higher BERTScore on 70/80 examples.
import torch
from peft import PeftModel
from transformers import (
AutoModelForCausalLM,
AutoTokenizer,
BitsAndBytesConfig
)
base_model_id = "mistralai/Mistral-7B-v0.3"
adapter_id = "shoron07/mistral-7b-dolly-qlora"
quantization_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True,
bnb_4bit_compute_dtype=torch.float16
)
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
revision="caa1feb0e54d415e2df31207e5f4e273e33509b1",
quantization_config=quantization_config,
device_map="auto"
)
model = PeftModel.from_pretrained(
base_model,
adapter_id
)
prompt = (
"### Instruction:\n"
"Explain why the sky appears blue.\n\n"
"### Response:\n"
)
inputs = tokenizer(
prompt,
return_tensors="pt"
).to(model.device)
with torch.inference_mode():
output = model.generate(
**inputs,
max_new_tokens=200,
do_sample=False
)
print(
tokenizer.decode(
output[0],
skip_special_tokens=True
)
)