Views
No views yet
hate vs not hate.LLaMA-Factory/data/dynahate_*.jsonl in the training workspace).You are a helpful Assistant. Your task is to classify the social media post as hate or not hate. Post:Strictly respond only with the label: 'hate' or 'not hate'.hate, not hate. Outputs are normalized case-insensitively during evaluation.| Component | Value |
|---|---|
| Base model | meta-llama/Meta-Llama-3.1-8B-Instruct |
| Finetuning method | QLoRA (bnb 4-bit, lora_rank=8, lora_alpha=16, lora_dropout=0.05) |
| Sequence length | 1 024 |
| Batch size | 3 per device × grad acc 8 (effective 24) |
| Optimizer | paged_adamw_32bit, LR 2e-5, cosine schedule, warmup 10 % |
| Epochs | 3 |
| Framework versions | transformers==4.57.1, peft==0.17.1, bitsandbytes==0.43.1, PyTorch 2.1+ |
trainer_log.jsonl, trainer_state.json, all_results.json).scripts/eval_dynahate_metrics.py (greedy decoding, max 4 new tokens, cutoff 1 024).eval_metrics.txt.| Split | Accuracy | Macro-F1 | Precision (hate / not hate) | Recall (hate / not hate) |
|---|---|---|---|---|
| Dynahate dev | 0.9259 | 0.9255 | 0.9228 / 0.9294 | 0.9382 / 0.9121 |
| Dynahate test | 0.9153 | 0.9142 | 0.9123 / 0.9191 | 0.9361 / 0.8898 |
sklearn classification reports (see eval_metrics.txt).1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4base_model = "meta-llama/Meta-Llama-3.1-8B-Instruct"
5adapter_id = "muditbaid/llama31-dynahate-qlora"
6
7tokenizer = AutoTokenizer.from_pretrained(adapter_id, use_fast=True, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(
9 base_model,
10 device_map="auto",
11 trust_remote_code=True,
12)
13model = PeftModel.from_pretrained(model, adapter_id)
14
15instruction = "You are a helpful Assistant. Your task is to classify the social media post as hate or not hate. Post:"
16system_prompt = "Strictly respond only with the label: 'hate' or 'not hate'."
17post = "i can't stand those people coming into our neighborhood"
18
19messages = [
20 {"role": "system", "content": system_prompt},
21 {"role": "user", "content": f"{instruction} {post}"},
22]
23prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
24inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
25output = model.generate(**inputs, max_new_tokens=4, do_sample=False)
26print(tokenizer.decode(output[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True).strip())adapter_model.safetensors / adapter_config.json: LoRA weights and configuration.tokenizer.*, chat_template.jinja, special_tokens_map.json: tokenizer assets aligned with the base model.dynahate_instruction_prompt.txt, dynahate_system_prompt.txt: prompt text used for data generation.eval_metrics.txt, eval_results.json, all_results.json, train_results.json: evaluation + training summaries.checkpoint-1000) are omitted from the upload to keep the repo lightweight.@inproceedings{vidgen2020dynahate,
title={Learning from the Worst: Dynamically Generated Datasets to Improve Online Hate Detection},
author={Vidgen, Bertie and others},
booktitle={ACL},
year={2020}
}@misc{AI@Meta2024Llama3,
author = {AI@Meta},
title = {The Llama 3 Herd of Models},
year = {2024}
}