Downloads · 30 days
32
44% of all-time downloads
ProfRutPatel/indian-history-qlora
indian-history-qlora is a machine learning model from ProfRutPatel. 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.
This model is a fine-tuned version of Qwen/Qwen2.5-0.5B-Instruct trained on NCERT Class XII Indian History textbook (128 pages) using QLoRA (4-bit quantization + LoRA adapters).
Downloads · 30 days
32
44% of all-time downloads
All-time downloads
72
Public
Repo size
46.7 MB
Likes
0
Public
Click a slice to open those files.
.safetensors35.2 MB · 76%
From the Hugging Face model README
This model is a fine-tuned version of Qwen/Qwen2.5-0.5B-Instruct trained on NCERT Class XII Indian History textbook (128 pages) using QLoRA (4-bit quantization + LoRA adapters).
| Property | Value |
|---|---|
| Base Model | Qwen/Qwen2.5-0.5B-Instruct |
| Fine-tuning Method | QLoRA (4-bit NF4 + LoRA rank 16) |
| Training Data | NCERT Themes in Indian History Part II (128 pages) |
| Training Samples | ~165 text continuation samples |
| Epochs | 5 |
| GPU | NVIDIA RTX 3050 4GB |
| Training Time | ~3.4 minutes |
| Final Train Loss | 2.674 |
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load adapter on top of base model
tokenizer = AutoTokenizer.from_pretrained("Rut-ai/indian-history-qlora")
model = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen2.5-0.5B-Instruct",
dtype=torch.bfloat16,
device_map="auto"
)
model = PeftModel.from_pretrained(model, "Rut-ai/indian-history-qlora")
model.eval()
# Generate
def ask(instruction, context=""):
if context:
prompt = f"### Instruction:\n{instruction}\n\n### Input:\n{context}\n\n### Response:\n"
else:
prompt = f"### Instruction:\n{instruction}\n\n### Response:\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(**inputs, max_new_tokens=200, temperature=0.7,
do_sample=True, repetition_penalty=1.1)
return tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
# Example
print(ask(
"Continue the following passage about Indian history:",
"The Mughal Empire was one of the largest empires in Indian history."
))
The model was trained on text continuation in Alpaca format:
### Instruction:
Continue the following passage about Indian history:
### Input:
[First 150 words of a historical text chunk]
### Response:
[Continuation of the passage]
Apache 2.0 — based on Qwen2.5-0.5B-Instruct