Gemma 2B Instruction LoRA Adapter (CPU Trained)

Model Description

This repository contains a LoRA (Low-Rank Adaptation) adapter fine-tuned on top of Google’s Gemma 2B Instruct model (google/gemma-2-2b-it).

The adapter was trained entirely on CPU using PEFT and TRL’s SFTTrainer for instruction-following tasks.

⚠️ This repository contains only LoRA adapter weights, not the full base model.


Model Details

  • Developed by: Aditi Rao
  • Shared by: Aditi Rao
  • Model type: Causal Language Model (LoRA Adapter)
  • Language(s): English
  • License: Gemma License
  • Finetuned from: google/gemma-2-2b-it

Training Details

Training Method

  • Fine-tuning approach: LoRA (PEFT)
  • Trainer: trl.SFTTrainer
  • Precision: float32
  • Hardware: CPU only

LoRA Configuration

  • Rank (r): 16
  • Alpha: 32
  • Dropout: 0.05
  • Target modules:
    • q_proj
    • k_proj
    • v_proj
    • o_proj
    • gate_proj
    • up_proj
    • down_proj

Training Hyperparameters

  • Epochs: 1
  • Batch size: 1
  • Gradient accumulation: 8
  • Learning rate: 1e-4
  • Max sequence length: 256
  • Optimizer: AdamW

Training Data

  • Custom instruction-style dataset in JSONL format
  • Chat-formatted using Gemma chat template
  • System messages normalized into user messages to comply with Gemma formatting rules

How to Get Started with the Model

Load the Adapter with the Base Model

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

base_model_id = "google/gemma-2-2b-it"
adapter_id = "aditi-rao-123/hf_model_gemma"

tokenizer = AutoTokenizer.from_pretrained(adapter_id)

base_model = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.float32,
    device_map="cpu"
)

model = PeftModel.from_pretrained(base_model, adapter_id)

prompt = "Explain what a cryptocurrency wallet is."
inputs = tokenizer(prompt, return_tensors="pt")

outputs = model.generate(**inputs, max_new_tokens=128)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Downloads last month
3
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for aditi-rao-123/hf_model_gemma

Adapter
(428)
this model