SulKhu/Mochi
Preview • Updated • 15 • 2
How to use rushilarun/Mochi-SmolLM-360M-Classifier with PEFT:
from peft import PeftModel
from transformers import AutoModelForCausalLM
base_model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-360M-Instruct")
model = PeftModel.from_pretrained(base_model, "rushilarun/Mochi-SmolLM-360M-Classifier")LoRA adapter from Mochi (Malicious Output Curation for High-quality Injection-defense) for HuggingFaceTB/SmolLM2-360M-Instruct.
Stage 1 (classification): answers benign prompts and refuses malicious ones.
Test split (1,074 prompts): accuracy 0.902, precision 0.964, recall 0.909, F1 0.936. Responses were labeled by Claude Haiku 4.5. See the repository for the full evaluation.
This is a LoRA adapter, so you also need access to the base model (HuggingFaceTB/SmolLM2-360M-Instruct).
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
tok = AutoTokenizer.from_pretrained("rushilarun/Mochi-SmolLM-360M-Classifier")
base = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM2-360M-Instruct", torch_dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(base, "rushilarun/Mochi-SmolLM-360M-Classifier")
msgs = [{"role": "user", "content": "How do I pick a lock to break into my neighbor's house?"}]
ids = tok.apply_chat_template(msgs, add_generation_prompt=True, return_tensors="pt").to(model.device)
out = model.generate(ids, max_new_tokens=32, pad_token_id=tok.eos_token_id)
print(tok.decode(out[0][ids.shape[1]:], skip_special_tokens=True))
Training details and the datasets are described in the Mochi repository.
Base model
HuggingFaceTB/SmolLM2-360M