File size: 3,222 Bytes
eca15ed
5ce4522
652c521
eca15ed
 
5ce4522
eca15ed
 
652c521
 
 
 
eca15ed
 
 
 
1b71b77
eca15ed
8b2369b
652c521
25137ce
652c521
25137ce
652c521
25137ce
 
 
 
652c521
25137ce
eca15ed
 
5ce4522
 
eca15ed
25137ce
 
 
 
 
eca15ed
5ce4522
eca15ed
25137ce
5ce4522
25137ce
5ce4522
 
eca15ed
25137ce
eca15ed
5ce4522
25137ce
5ce4522
25137ce
5ce4522
 
25137ce
 
5ce4522
 
 
25137ce
5ce4522
 
 
652c521
 
25137ce
eca15ed
652c521
25137ce
652c521
 
 
25137ce
652c521
 
 
 
 
 
25137ce
652c521
25137ce
 
 
 
 
 
652c521
 
 
25137ce
eca15ed
 
5ce4522
 
 
 
 
 
eca15ed
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
---
license: apache-2.0
base_model: Qwen/Qwen2.5-7B-Instruct
language:
- en
pipeline_tag: text-generation
tags:
- humor
- lora
- sft
- qwen2
- peft
---

# HumorGen-7B

A 7B humor generation model fine-tuned from [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) using the **Cognitive Synergy Framework** — six psychologically-grounded AI personas generate and rank joke candidates, and only the best make it into training data. The result is a compact model that outperforms Qwen-2.5-32B and GPT-OSS-120B on automated humor evaluation.

> 📄 [HumorGen: Cognitive Synergy for Humor Generation in Large Language Models via Persona-Based Distillation](https://edwardajayi.github.io/assets/papers/HumorGen_CSF.pdf)

---

## Install

```bash
pip install "unsloth[colab-new]" bitsandbytes xformers trl peft transformers
pip install -U "bitsandbytes>=0.46.1"
```

## Usage

```python
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer

model = PeftModel.from_pretrained(
    AutoModelForCausalLM.from_pretrained(
        "unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit", device_map="auto"
    ),
    "Jayi2424/HumorGen-7B",
)
tokenizer = AutoTokenizer.from_pretrained("unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit")

prompt = "Write a funny joke about: Monday meetings\n"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=150, temperature=0.8, do_sample=True)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```

### Chat format

```python
SYSTEM = (
    "You are a joke generator. Given a headline or topic, generate a funny joke. "
    "Output ONLY the joke. No reasoning, no explanation."
)
messages = [
    {"role": "system", "content": SYSTEM},
    {"role": "user", "content": "Write a funny joke based on: Denzel Washington reveals he doesn't watch movies anymore"},
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.7, top_p=0.9, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
```

---

## Benchmark (SemEval 2026 MWAHAHA, 43k pairwise comparisons)

| Model | BT Rating | Win % |
|---|---|---|
| GPT-5 | 1323.7 | 84.7% |
| Kimi-K2 | 1221.6 | 75.3% |
| Gemini-2.5-Pro | 1190.3 | 72.0% |
| **HumorGen-7B (this model)** | **1083.9** | **59.5%** |
| GPT-OSS-120B | 989.2 | 47.7% |
| Qwen-2.5-32B-Instruct | 964.3 | 44.5% |
| Base Qwen-7B | 607.1 | 10.8% |

---

## Model Info

| | |
|---|---|
| Base model | Qwen/Qwen2.5-7B-Instruct |
| Method | SFT + LoRA (r=16, α=16) |
| Framework | Unsloth + TRL |
| Training data | 12,000 examples from 1,200 MWAHAHA prompts |

---

## Citation

```bibtex
@misc{ajayi2025humorgen,
  title        = {HumorGen: Cognitive Synergy for Humor Generation in Large Language Models via Persona-Based Distillation},
  author       = {Ajayi, Edward and Mitra, Prasenjit},
  year         = {2025},
  howpublished = {\url{https://edwardajayi.github.io/assets/papers/HumorGen_CSF.pdf}},
  note         = {Preprint}
}
```