Downloads · 30 days
0
Hemanth-5204/mistral-7b-qlora
mistral-7b-qlora is a machine learning model from Hemanth-5204. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a LoRA adapter fine-tuned from Mistral-7B using the UltraChat instruction dataset.
Downloads · 30 days
0
Access
Public
Updated Mar 11, 2026
Repo size
27.3 MB
Likes
0
Public
Click a slice to open those files.
.safetensors27.3 MB · 89%
From the Hugging Face model README
This repository contains a LoRA adapter fine-tuned from Mistral-7B using the UltraChat instruction dataset.
The model was trained using QLoRA (4-bit quantization + LoRA adapters) to enable efficient fine-tuning on limited GPU resources such as Kaggle GPUs.
This adapter can be loaded on top of the base model to generate instruction-following responses.
The model was trained using the UltraChat-200k dataset.
UltraChat contains multi-turn conversations between users and assistants designed to improve instruction-following abilities of large language models.
Dataset link:
https://huggingface.co/datasets/HuggingFaceH4/ultrachat_200k
For this experiment, a subset of the dataset was used.
QLoRA (Quantized LoRA)
| Parameter | Value |
|---|---|
| Batch size | 2 |
| Gradient accumulation | 4 |
| Learning rate | 2e-4 |
| Epochs | 1 |
| Optimizer | paged_adamw_8bit |
| Max sequence length | 512 |
Training was performed using:
Libraries used:
from transformers import AutoTokenizer, AutoModelForCausalLM, BitsAndBytesConfig
from peft import PeftModel
import torch
model_name = "mistralai/Mistral-7B-v0.1"
tokenizer = AutoTokenizer.from_pretrained(model_name)
tokenizer.pad_token = tokenizer.eos_token
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype=torch.float16,
bnb_4bit_quant_type="nf4",
bnb_4bit_use_double_quant=True
)
base_model = AutoModelForCausalLM.from_pretrained(
model_name,
quantization_config=bnb_config,
device_map="auto"
)
model = PeftModel.from_pretrained(
base_model,
"Hemanth-5204/mistral-7b-qlora"
)
prompt = "Explain self attention in transformers."
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=200
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
import torch
chat_history = ""
print("Type 'exit' to stop\n")
while True:
user_input = input("User: ")
if user_input.lower() == "exit":
break
# Add user message to history
chat_history += f"\nUser: {user_input}\nAssistant:"
inputs = tokenizer(chat_history, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=150,
temperature=0.3,
top_p=0.9,
repetition_penalty=1.2,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
# Extract only assistant reply
reply = response.split("Assistant:")[-1].strip()
print(f"\nAssistant: {reply}\n")
# Add assistant response to history
chat_history += " " + reply
This model can be used for:
As with most large language models, the model may reproduce biases present in the training data.
Users should carefully review outputs before using them in sensitive contexts.
If you use this model, please cite:
Hemanth Naravi