Run this model with HF Jobs
Run rushilarun/Mochi-Llama-1B-Classifier on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/rushilarun/Mochi-Llama-1B-Classifier. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/rushilarun/Mochi-Llama-1B-Classifier on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use rushilarun/Mochi-Llama-1B-Classifier with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use rushilarun/Mochi-Llama-1B-Classifier with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B-Instruct") model = PeftModel.from_pretrained(base_model, "rushilarun/Mochi-Llama-1B-Classifier") - Notebooks
- Google Colab
- Kaggle
Mochi-Llama-1B-Classifier
LoRA adapter from Mochi (Malicious Output Curation for High-quality Injection-defense) for meta-llama/Llama-3.2-1B-Instruct.
Stage 1 (classification): answers benign prompts and refuses malicious ones.
Test split (1,074 prompts): accuracy 0.935, precision 0.973, recall 0.943, F1 0.958. Responses were labeled by Claude Haiku 4.5. See the repository for the full evaluation.
Usage
This is a LoRA adapter, so you also need access to the base model (meta-llama/Llama-3.2-1B-Instruct).
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
tok = AutoTokenizer.from_pretrained("rushilarun/Mochi-Llama-1B-Classifier")
base = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-3.2-1B-Instruct", torch_dtype=torch.float16, device_map="auto")
model = PeftModel.from_pretrained(base, "rushilarun/Mochi-Llama-1B-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.
- Downloads last month
- 25
Model tree for rushilarun/Mochi-Llama-1B-Classifier
Base model
meta-llama/Llama-3.2-1B-Instruct