Views
No views yet
meta-llama/Meta-Llama-3.1-8B-Instructhatespeech, offensive, normal)1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3import torch
4
5base = "meta-llama/Meta-Llama-3.1-8B-Instruct"
6adapter = "<your-username>/<your-adapter-repo>" # or local path to this checkpoint
7
8tokenizer = AutoTokenizer.from_pretrained(base)
9model = AutoModelForCausalLM.from_pretrained(base, torch_dtype=torch.bfloat16, device_map="auto")
10model = PeftModel.from_pretrained(model, adapter)
11
12# Build a llama3-style prompt and generate the label ("hatespeech"/"offensive"/"normal")llama3, cutoff length: 2048saves/llama31-8b/hatexplain/loradatasets), majority-vote label from annotatorsinstruction + input → label as assistant response precision recall f1-score support
hatespeech 0.7252 0.8634 0.7883 593
offensive 0.6152 0.4726 0.5346 548
normal 0.7698 0.7836 0.7766 781
accuracy 0.7196 1922
macro avg 0.7034 0.7065 0.6998 1922
weighted avg 0.7120 0.7196 0.7112 1922pad_token = eos_token for batched evaluation.