Downloads · 30 days
0
Shaimaz/gemma3_4B_LoRA_Emotion_Toxicity_v1
gemma3_4B_LoRA_Emotion_Toxicity_v1 is a machine learning model from Shaimaz. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Downloads · 30 days
0
Access
Public
Updated Oct 10, 2025
Repo size
51 MB
Likes
1
Public
Click a slice to open those files.
.json34.5 MB · 66%
From the Hugging Face model README
from huggingface_hub import HfApi
readme_text = """
Author: Shaima Z. Alzubi
Base model: google/gemma-3-4b-it
Technique: LoRA (Low-Rank Adaptation)
Trained Cores: Core-1 (Emotions) + Core-2 (Toxicity)
This model adapts Gemma-3-4B-IT using a dual-core dataset:
| Core | Domain | Objective | Size |
|---|---|---|---|
| 🩵 Core-1 | Emotion understanding | Detect human emotional states from text | 49K |
| 💢 Core-2 | Toxicity moderation | Detect & rephrase toxic or disrespectful content | 65K |
The LoRA improves emotional recognition and safe conversational tone, making the base Gemma more empathetic and socially aware.
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
from peft import PeftModel
base = "google/gemma-3-4b-it"
adapter = "Shaimaz/gemma3_4B_LoRA_Emotion_Toxicity_v1"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(base)
model = PeftModel.from_pretrained(model, adapter)
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer, device=0)
prompt = "Detect the emotion or toxicity in this text and respond kindly:\\n\\nYou are so annoying!"
print(pipe(prompt, max_new_tokens=60)[0]['generated_text'])