Downloads · 30 days
5
19% of all-time downloads
annamanaseryan/cozmo-emotion-grpo
cozmo-emotion-grpo is a text classification model from annamanaseryan. Use it when you need a label for a piece of text. It is set up for peft.
PEFT LoRA adapter trained with GRPO (group-relative policy optimization) from human yes/no feedback on robot emotion displays. This adapter sits on top of the SFT classifier:
Downloads · 30 days
5
19% of all-time downloads
All-time downloads
26
Public
Repo size
1.8 MB
Likes
0
Public
Click a slice to open those files.
.safetensors1.8 MB · 99%
From the Hugging Face model README
PEFT LoRA adapter trained with GRPO (group-relative policy optimization) from human yes/no feedback on robot emotion displays. This adapter sits on top of the SFT classifier:
annamanaseryan/cozmo-emotion-sft
| This repo | Not included here |
|---|---|
LoRA weights (adapter_model.safetensors) | Full DeBERTa weights |
adapter_config.json | SFT best_model.bin (required separately) |
You need all three:
microsoft/deberta-v3-base (encoder backbone, from Hugging Face)annamanaseryan/cozmo-emotion-sft (best_model.bin + tokenizer + EmotionClassifier)HUMAN: {human_text}
ROBOT: {robot_text}
| Id | Description |
|---|---|
| 0 | anger_frustration |
| 1 | interest_desire |
| 2 | confusion_sorrow_boredom |
| 3 | joy_hope |
| 4 | understanding_gratitude_relief |
| 5 | disgust_surprise_alarm_fear |
See emotion_labels.yaml.
r=8, lora_alpha=16, lora_dropout=0.05query_proj, key_proj, value_projpip install torch transformers peft pyyaml huggingface_hub
import sys
import torch
import yaml
from huggingface_hub import snapshot_download
from transformers import AutoTokenizer
from peft import PeftModel
SFT_REPO = "annamanaseryan/cozmo-emotion-sft"
GRPO_REPO = "annamanaseryan/cozmo-emotion-grpo"
device = "cuda" if torch.cuda.is_available() else "cpu"
sft_dir = snapshot_download(SFT_REPO)
grpo_dir = snapshot_download(GRPO_REPO)
sys.path.insert(0, sft_dir)
from modeling_emotion import EmotionClassifier
with open(f"{sft_dir}/emotion_labels.yaml") as f:
cfg = yaml.safe_load(f)
id2desc = {int(i): d["description"] for i, d in cfg["emotions"].items()}
tokenizer = AutoTokenizer.from_pretrained(sft_dir)
base = EmotionClassifier(n_classes=6, model_name="microsoft/deberta-v3-base")
base.load_state_dict(torch.load(f"{sft_dir}/best_model.bin", map_location="cpu"))
model = PeftModel.from_pretrained(base, grpo_dir)
model.to(device).eval()
def predict(human: str, robot: str, max_length: int = 256):
text = f"HUMAN: {human}\nROBOT: {robot}"
inputs = tokenizer(
text,
return_tensors="pt",
max_length=max_length,
padding="max_length",
truncation=True,
).to(device)
with torch.no_grad():
logits = model(**inputs)
probs = torch.softmax(logits, dim=-1).cpu().squeeze()
out = {id2desc[i]: float(probs[i]) for i in range(len(probs))}
pred = max(out, key=out.get)
return pred, out
label, dist = predict("Do you have empathy?", "i try to understand.")
print(label)
print(dist)
A copy of this script is in inference_example.py.