Text Generation
Transformers
Safetensors
PyTorch
English
llama
tinyllama
unsloth
merged
lora
fine-tuned
conversational
text-generation-inference
Not-For-All-Audiences
Instructions to use arif-butt/tinyllama-unsloth-merged with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use arif-butt/tinyllama-unsloth-merged with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="arif-butt/tinyllama-unsloth-merged") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("arif-butt/tinyllama-unsloth-merged") model = AutoModelForCausalLM.from_pretrained("arif-butt/tinyllama-unsloth-merged", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use arif-butt/tinyllama-unsloth-merged with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "arif-butt/tinyllama-unsloth-merged" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arif-butt/tinyllama-unsloth-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/arif-butt/tinyllama-unsloth-merged
- SGLang
How to use arif-butt/tinyllama-unsloth-merged with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "arif-butt/tinyllama-unsloth-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arif-butt/tinyllama-unsloth-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "arif-butt/tinyllama-unsloth-merged" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "arif-butt/tinyllama-unsloth-merged", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use arif-butt/tinyllama-unsloth-merged with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for arif-butt/tinyllama-unsloth-merged to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for arif-butt/tinyllama-unsloth-merged to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for arif-butt/tinyllama-unsloth-merged to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="arif-butt/tinyllama-unsloth-merged", max_seq_length=2048, ) - Docker Model Runner
How to use arif-butt/tinyllama-unsloth-merged with Docker Model Runner:
docker model run hf.co/arif-butt/tinyllama-unsloth-merged
π¦ TinyLlama Unsloth Merged - Full Fine-tuned Model
Model Description
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.
Key Features:
- Fully Merged: No separate adapter files needed
- Unsloth Optimized: 2-3x faster inference with Unsloth kernels
- Memory Efficient: 30-50% less memory usage than standard models
- Standalone: Load directly with transformers or Unsloth
- Ready to Use: Single folder with model + tokenizer
Model Details:
- Base Model: TinyLlama/TinyLlama-1.1B-Chat-v1.0
- Fine-tuning Method: LoRA with Unsloth optimizations (merged)
- Format: PyTorch safetensors
- Parameters: 1.1 Billion
- Context Length: 2048 tokens
- Precision: FP16 (float16)
π Usage
Option 1: Using Transformers (Recommended)
# ββ 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)
]
- Downloads last month
- 51
Model tree for arif-butt/tinyllama-unsloth-merged
Base model
TinyLlama/TinyLlama-1.1B-Chat-v1.0