Views
No views yet
meta-llama/Llama-3.2-1B-Instructq_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_projsar_to_non_context_enhanced.merge_and_unload().1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "SeeYangZhi/Llama-3.2-1B-Sarcasm-Rewriter"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForCausalLM.from_pretrained(model_id)
6
7messages = [
8 {
9 "role": "system",
10 "content": (
11 "You are a writing assistant. Rewrite sarcastic news headlines as neutral, "
12 "factual equivalents that preserve the core meaning without irony or mockery. "
13 "Respond with only the rewritten headline, no explanation."
14 ),
15 },
16 {
17 "role": "user",
18 "content": "Rewrite this sarcastic headline as a neutral, non-sarcastic news headline:\n\narea man passionate defender of what he imagines constitution to be",
19 },
20]
21
22prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
23inputs = tokenizer(prompt, return_tensors="pt")
24outputs = model.generate(**inputs, max_new_tokens=128, do_sample=False)
25print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))| Metric | Description | Direction |
|---|---|---|
| Hard Flip Rate | % of samples where sarcasm was removed (classifier-detected) | higher ↑ |
| Flip Delta | Mean change in irony score | higher ↑ |
| Semantic Similarity | all-MiniLM-L6-v2 cosine between input and output | higher ↑ |
| BLEU vs input | Lower = more genuine rewriting | lower ↓ |
| Perplexity (GPT-2) | Fluency | lower ↓ |
| Edit Distance (norm) | Proportion of words changed | higher ↑ |
| Paraphrase Score | Paraphrase detection (low = real rewriting) | lower ↓ |