Views
No views yet
data/jigsaw_threat_*.jsonl).You are a helpful Assistant. Your task is to classify the social media post as threat or not threat. Post:Strictly respond only with the label: 'threat' or 'not threat'.threat, not threat. The evaluation script lowercases predictions before scoring.| 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 | 4 per device × grad acc 8 (effective 32) |
| Optimizer | paged_adamw_32bit, LR 2e-5, cosine decay, warmup 5 % |
| Epochs | 3 |
| Frameworks | transformers==4.57.1, peft==0.17.1, bitsandbytes==0.43.1, PyTorch 2.1+ |
trainer_log.jsonl, trainer_state.json, train_results.json, all_results.json) and eval outputs live in this repository for reproducibility.scripts/eval_jigsaw_threat_metrics.py (greedy decoding, max 4 new tokens, cutoff 1 024):| Split | Accuracy | Macro-F1 | Precision (threat / not threat) | Recall (threat / not threat) |
|---|---|---|---|---|
| Validation | 0.9633 | 0.9633 | 0.9640 / 0.9626 | 0.9625 / 0.9640 |
| Test | 0.9588 | 0.9588 | 0.9622 / 0.9554 | 0.9550 / 0.9625 |
eval_metrics.txt for the full sklearn classification reports and timing.1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4base_model = "meta-llama/Meta-Llama-3.1-8B-Instruct"
5adapter_id = "muditbaid/llama31-jigsaw-threat-qlora"
6
7tokenizer = AutoTokenizer.from_pretrained(adapter_id, use_fast=True, trust_remote_code=True)
8model = AutoModelForCausalLM.from_pretrained(base_model, device_map="auto", trust_remote_code=True)
9model = PeftModel.from_pretrained(model, adapter_id)
10
11system_prompt = "Strictly respond only with the label: 'threat' or 'not threat'."
12instruction = "You are a helpful Assistant. Your task is to classify the social media post as threat or not threat. Post:"
13post = "if you show up at the rally, we will make sure you never walk again."
14
15messages = [
16 {"role": "system", "content": system_prompt},
17 {"role": "user", "content": f"{instruction} {post}"},
18]
19prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
21outputs = model.generate(**inputs, max_new_tokens=4, do_sample=False)
22prediction = tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True).strip()
23print(prediction)adapter_model.safetensors, adapter_config.json: LoRA weights + config.tokenizer.json, tokenizer_config.json, special_tokens_map.json, chat_template.jinja: tokenizer assets aligned with Llama 3.1.eval_metrics.txt, eval_results.json: detailed evaluation logs.trainer_state.json, trainer_log.jsonl, train_results.json, all_results.json: training summaries.checkpoint-330, checkpoint-471) are retained locally but excluded from the upload for size reasons.threat / not threat; the model does not explain its decisions.@misc{jigsaw2018threat,
title={Jigsaw Toxic Comment Classification Challenge},
howpublished={Kaggle},
year={2018}
}@misc{AI@Meta2024Llama3,
author = {AI@Meta},
title = {The Llama 3 Herd of Models},
year = {2024}
}