Downloads · 30 days
0
krishanwalia30/granite-4.0-h-micro_lora_model
granite-4.0-h-micro_lora_model is a text generation model from krishanwalia30. 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 model is a parameter-efficient fine-tuned version of IBM's Granite 4.0-h-micro (3.2B parameters), optimized for customer support dialog and recommendation generation tasks. The model leverages LoRA (Low-Rank Adap…
Downloads · 30 days
0
Access
Public
Updated Oct 7, 2025
Repo size
76.8 MB
Likes
0
Public
Click a slice to open those files.
.safetensors76.8 MB · 89%
From the Hugging Face model README
This model is a parameter-efficient fine-tuned version of IBM's Granite 4.0-h-micro (3.2B parameters), optimized for customer support dialog and recommendation generation tasks. The model leverages LoRA (Low-Rank Adaptation) adapters for efficient fine-tuning, enabling enterprise-grade conversational AI capabilities on consumer hardware.
| Attribute | Value |
|---|---|
| Base Model | unsloth/granite-4.0-h-micro |
| Parameters | ~3.2 Billion |
| Fine-tuning Method | LoRA (Low-Rank Adaptation) |
| Training Framework | Unsloth + Hugging Face TRL |
| Precision | 16-bit (supports 4/8-bit quantization) |
| License | Apache 2.0 |
| Language | English |
This model is not suitable for:
pip install unsloth transformers torch accelerate
from unsloth import FastLanguageModel
import torch
# Load model and tokenizer
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="krishanwalia30/granite-4.0-h-micro_lora_model",
max_seq_length=1024,
dtype=None, # Auto-detect
load_in_4bit=False, # Set True for 4-bit quantization
)
# Prepare for inference
FastLanguageModel.for_inference(model)
# Chat template
messages = [
{"role": "system", "content": "You are Granite, a helpful AI assistant."},
{"role": "user", "content": "I need help choosing a laptop for programming."}
]
inputs = tokenizer.apply_chat_template(
messages,
tokenize=True,
add_generation_prompt=True,
return_tensors="pt"
).to("cuda")
# Generate response
outputs = model.generate(
inputs,
max_new_tokens=256,
temperature=0.7,
top_p=0.9,
do_sample=True
)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
from transformers import TextIteratorStreamer
from threading import Thread
streamer = TextIteratorStreamer(tokenizer, skip_special_tokens=True)
generation_kwargs = dict(
inputs=inputs,
streamer=streamer,
max_new_tokens=256,
temperature=0.7
)
thread = Thread(target=model.generate, kwargs=generation_kwargs)
thread.start()
for text in streamer:
print(text, end="", flush=True)
| Hyperparameter | Value |
|---|---|
| Hardware | Google Colab T4 GPU (15GB VRAM) |
| Sequence Length | 1024 tokens |
| Batch Size | 2 |
| Gradient Accumulation Steps | 4 |
| Effective Batch Size | 8 |
| Max Training Steps | 60 |
| Learning Rate | 2e-4 |
| Optimizer | AdamW (8-bit) |
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0.05 |
| Target Modules | q_proj, k_proj, v_proj, o_proj |
| Weight Decay | 0.01 |
| Warmup Steps | 5 |
Thanks to Unsloth optimizations:
The model demonstrates strong performance on customer support tasks:
Note: Formal benchmark scores are pending comprehensive evaluation.
The model uses Granite 4.0's chat template:
<|start_of_role|>system<|end_of_role|>Knowledge Cutoff Date: April 2024. Today's Date: [Current Date]. You are Granite, developed by IBM. You are a helpful AI assistant.<|end_of_text|>
<|start_of_role|>user<|end_of_role|>[User message]<|end_of_text|>
<|start_of_role|>assistant<|end_of_role|>[Assistant response]<|end_of_text|>
The tokenizer's apply_chat_template() method handles formatting automatically.
| Configuration | VRAM | Use Case |
|---|---|---|
| 16-bit | 12-16GB | Development, high-quality inference |
| 8-bit | 6-8GB | Production deployment |
| 4-bit | 4-6GB | Edge devices, cost-optimized deployment |
# 4-bit quantization for reduced memory
model, tokenizer = FastLanguageModel.from_pretrained(
model_name="krishanwalia30/granite-4.0-h-micro_lora_model",
max_seq_length=1024,
load_in_4bit=True, # Enable 4-bit quantization
dtype=None,
)
If you use this model in your work, please cite:
@misc{walia2025granite4micro,
author = {Walia, Krishan},
title = {Granite 4.0-h-micro Fine-tuned with LoRA for Customer Support},
year = {2025},
month = {October},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/krishanwalia30/granite-4.0-h-micro_lora_model}},
}
This model is released under the Apache License 2.0. See LICENSE for details.
Trained with ❤️ using Unsloth and Hugging Face TRL
<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/> </div>