Downloads · 30 days
10
25% of all-time downloads
nandbins/tinyllama-unsloth-merged
tinyllama-unsloth-merged is a text generation model from nandbins. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as apache-2.0.
This is a fully merged model of TinyLlama (1.1B parameters) fine-tuned using Unsloth optimizations with LoRA adapters, then merged into a single complete model. Unlike adapter-only versions, this model is standalone a…
Downloads · 30 days
10
25% of all-time downloads
All-time downloads
40
Public
Parameters
1.1B
2.2 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors2.2 GB · 100%
From the Hugging Face model README
This is a fully merged model of TinyLlama (1.1B parameters) fine-tuned using Unsloth optimizations with LoRA adapters, then merged into a single complete model. Unlike adapter-only versions, this model is standalone and can be loaded without PEFT library.
# ── Load Merged Model with Transformers ───────────────────────────────────
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
import torch
# Model identifier
MODEL_ID = "arif-butt/tinyllama-unsloth-merged"
print("Loading model and tokenizer...")
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForCausalLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.float16,
device_map="auto",
trust_remote_code=True,
)
model.eval()
print("✅ Model loaded successfully!")
# Test prompt
prompt = "Q: Name all the courses Arif butt teach?\nA:"
# Tokenize
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=100,
temperature=0.2,
do_sample=True,
pad_token_id=tokenizer.eos_token_id,
)
# Decode
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Prompt: {prompt}")
print(f"Response: {response}")
Option 2: Using Pipeline
# ── Text Generation Pipeline ─────────────────────────────────────────────
from transformers import pipeline
import torch
MODEL_ID = "arif-butt/tinyllama-unsloth-merged"
pipe = pipeline(
"text-generation",
model=MODEL_ID,
torch_dtype=torch.float16,
device_map="auto",
)
prompt = "Q: What is machine learning?\nA:"
output = pipe(prompt, max_new_tokens=100, temperature=0.2)
print(output[0]["generated_text"])
Option 3: Using Unsloth (Faster Inference)
# ── Load with Unsloth for Maximum Performance ────────────────────────────
from unsloth import FastLanguageModel
import torch
MODEL_ID = "arif-butt/tinyllama-unsloth-merged"
print("Loading model with Unsloth...")
model, tokenizer = FastLanguageModel.from_pretrained(
model_name=MODEL_ID,
max_seq_length=2048,
dtype=torch.float16,
device_map="auto",
)
print("✅ Model loaded with Unsloth optimizations!")
# Test prompt
prompt = "Q: Explain neural networks\nA:"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
**inputs,
max_new_tokens=150,
temperature=0.3,
do_sample=True,
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Response: {response}")
Fine-tuning Configuration
LORA_R = 16 # Rank of LoRA matrices
LORA_ALPHA = 32 # Scaling factor (alpha/r = 2.0)
LORA_DROPOUT = 0.05 # Dropout for regularization
TARGET_MODULES = [ # Layers where LoRA is applied
"q_proj", # Query projection
"k_proj", # Key projection
"v_proj", # Value projection
"o_proj", # Output projection
"gate_proj", # Gate projection (MLP)
"up_proj", # Up projection (MLP)
"down_proj" # Down projection (MLP)
]