Jayi2424 commited on
Commit
652c521
Β·
verified Β·
1 Parent(s): 5ce4522

Update model card: add paper link, benchmark results, methodology, and Quick Start code

Browse files
Files changed (1) hide show
  1. README.md +110 -28
README.md CHANGED
@@ -1,6 +1,6 @@
1
  ---
2
  license: apache-2.0
3
- base_model: unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit
4
  language:
5
  - en
6
  pipeline_tag: text-generation
@@ -8,14 +8,32 @@ tags:
8
  - humor
9
  - jokes
10
  - comedy
 
 
 
 
 
11
  - causal-lm
12
  ---
13
 
14
  # HumorGen-7B
15
 
16
- **HumorGen-7B** is a humor generation model based on [Qwen2.5-7B-Instruct](https://huggingface.co/unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit), fine-tuned to generate funny jokes from headlines or topics.
 
 
 
 
17
 
18
- ## Quick Start
 
 
 
 
 
 
 
 
 
19
 
20
  ```python
21
  # Install required packages
@@ -37,29 +55,45 @@ model = PeftModel.from_pretrained(base_model, "Jayi2424/HumorGen-7B")
37
  # Load tokenizer
38
  tokenizer = AutoTokenizer.from_pretrained("unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit")
39
 
40
- # Create a prompt for joke generation
41
  prompt = "Generate a joke using the words 'Nigeria' and 'Capstone':\n"
42
-
43
- # Tokenize and generate
44
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
45
  outputs = model.generate(**inputs, max_new_tokens=100, use_cache=True)
46
-
47
- # Print the generated joke
48
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
49
  ```
50
 
51
- ## Usage Examples
 
 
52
 
53
- ### Basic Generation
54
 
55
  ```python
56
- prompt = "Write a funny joke about: coffee"
57
- inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
58
- outputs = model.generate(**inputs, max_new_tokens=150, temperature=0.8)
59
- print(tokenizer.decode(outputs[0], skip_special_tokens=True))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  ```
61
 
62
- ### With System Prompt (Chat Format)
63
 
64
  ```python
65
  SYSTEM_PROMPT = (
@@ -83,27 +117,75 @@ outputs = model.generate(
83
  do_sample=True,
84
  pad_token_id=tokenizer.eos_token_id,
85
  )
86
-
87
  print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
88
  ```
89
 
90
- ## Model Details
 
 
 
 
91
 
92
- - **Base Model:** [Qwen2.5-7B-Instruct](https://huggingface.co/unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit)
93
- - **Architecture:** LoRA (Low-Rank Adaptation) adapter
94
- - **License:** Apache-2.0
95
- - **Language:** English
 
 
 
 
 
 
 
 
 
 
96
 
97
- ## Generation Parameters
98
 
99
- | Parameter | Default | Description |
100
- |-----------|---------|-------------|
101
- | `max_new_tokens` | 100-512 | Maximum length of generated joke |
102
- | `temperature` | 0.7-0.8 | Controls creativity (higher = more random) |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  | `top_p` | 0.9 | Nucleus sampling threshold |
104
- | `do_sample` | True | Enable sampling for diverse outputs |
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
- ## Citation
107
 
108
  If you use this model in your research, please cite:
109
 
 
1
  ---
2
  license: apache-2.0
3
+ base_model: Qwen/Qwen2.5-7B-Instruct
4
  language:
5
  - en
6
  pipeline_tag: text-generation
 
8
  - humor
9
  - jokes
10
  - comedy
11
+ - lora
12
+ - sft
13
+ - qwen2
14
+ - unsloth
15
+ - peft
16
  - causal-lm
17
  ---
18
 
19
  # HumorGen-7B
20
 
21
+ <p align="center">
22
+ <a href="https://edwardajayi.github.io/assets/papers/HumorGen_CSF.pdf">πŸ“„ Paper</a> β€’
23
+ <a href="https://huggingface.co/Jayi2424/HumorGen-7B">πŸ€— Model</a> β€’
24
+ <a href="https://github.com/edwardajayi">πŸ’» GitHub</a>
25
+ </p>
26
 
27
+ **HumorGen-7B** is a 7B-parameter humor generation model fine-tuned from [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) using the **Cognitive Synergy Framework** introduced in our paper. It is a LoRA adapter trained with Supervised Fine-Tuning (SFT) on high-quality humor data curated via a Mixture-of-Thought (MoT) approach with six cognitive personas grounded in psychological humor theory.
28
+
29
+ This model achieves a Bradley-Terry rating of **1083.9** on automated pairwise evaluation, **outperforming Qwen-2.5-32B and GPT-OSS-120B on humor generation** despite being 4–17Γ— smaller.
30
+
31
+ > **Paper:** [HumorGen: Cognitive Synergy for Humor Generation in Large Language Models via Persona-Based Distillation](https://edwardajayi.github.io/assets/papers/HumorGen_CSF.pdf)
32
+ > **Authors:** Edward Ajayi, Prasenjit Mitra β€” *Carnegie Mellon University Africa*
33
+
34
+ ---
35
+
36
+ ## πŸš€ Quick Start (Colab / Jupyter)
37
 
38
  ```python
39
  # Install required packages
 
55
  # Load tokenizer
56
  tokenizer = AutoTokenizer.from_pretrained("unsloth/qwen2.5-7b-instruct-unsloth-bnb-4bit")
57
 
58
+ # Generate a joke
59
  prompt = "Generate a joke using the words 'Nigeria' and 'Capstone':\n"
 
 
60
  inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
61
  outputs = model.generate(**inputs, max_new_tokens=100, use_cache=True)
 
 
62
  print(tokenizer.decode(outputs[0], skip_special_tokens=True))
63
  ```
64
 
65
+ ---
66
+
67
+ ## πŸ“– Usage
68
 
69
+ ### Standard Usage (Full Precision)
70
 
71
  ```python
72
+ from transformers import AutoModelForCausalLM, AutoTokenizer
73
+ from peft import PeftModel
74
+
75
+ base_model_id = "Qwen/Qwen2.5-7B-Instruct"
76
+ adapter_model_id = "Jayi2424/HumorGen-7B"
77
+
78
+ tokenizer = AutoTokenizer.from_pretrained(base_model_id)
79
+ model = AutoModelForCausalLM.from_pretrained(
80
+ base_model_id,
81
+ torch_dtype="auto",
82
+ device_map="auto"
83
+ )
84
+ model = PeftModel.from_pretrained(model, adapter_model_id)
85
+ model = model.merge_and_unload() # optional: merge for faster inference
86
+
87
+ headline = "Denzel Washington reveals he doesn't watch movies anymore"
88
+ messages = [{"role": "user", "content": f"Write a funny joke based on this news headline: {headline}"}]
89
+
90
+ text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
91
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
92
+ outputs = model.generate(**inputs, max_new_tokens=256, temperature=0.8, do_sample=True)
93
+ print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))
94
  ```
95
 
96
+ ### With System Prompt
97
 
98
  ```python
99
  SYSTEM_PROMPT = (
 
117
  do_sample=True,
118
  pad_token_id=tokenizer.eos_token_id,
119
  )
 
120
  print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
121
  ```
122
 
123
+ ---
124
+
125
+ ## πŸ† Benchmark Results
126
+
127
+ Evaluated on the **SemEval 2026 MWAHAHA** held-out test set (50 prompts, 43,048 pairwise comparisons judged by Llama-3.3-70B-Instruct):
128
 
129
+ | Model | BT Rating | Win % |
130
+ |-------|-----------|-------|
131
+ | GPT-5 | 1323.7 | 84.7% |
132
+ | Kimi-K2 | 1221.6 | 75.3% |
133
+ | Gemini-2.5-Pro | 1190.3 | 72.0% |
134
+ | **HumorGen-SFT-7B (this model)** | **1083.9** | **59.5%** |
135
+ | HumorGen-DPO-7B | 1079.9 | 59.0% |
136
+ | GPT-OSS-120B | 989.2 | 47.7% |
137
+ | Qwen-2.5-32B-Instruct | 964.3 | 44.5% |
138
+ | Base Qwen-7B | 607.1 | 10.8% |
139
+
140
+ > HumorGen-SFT-7B outperforms Qwen-2.5-32B and GPT-OSS-120B while being **4–17Γ— smaller**.
141
+
142
+ ---
143
 
144
+ ## 🧠 Model Details
145
 
146
+ | Property | Value |
147
+ |----------|-------|
148
+ | Base Model | [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) |
149
+ | Fine-tuning Method | SFT (Supervised Fine-Tuning) |
150
+ | Adapter Type | LoRA (r=16, alpha=16) |
151
+ | Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
152
+ | Training Framework | Unsloth + TRL |
153
+ | Training Data | SemEval 2026 MWAHAHA (1,200 news headline prompts) |
154
+ | BT Rating | 1083.9 (Win rate: 59.5%) |
155
+ | License | Apache-2.0 |
156
+
157
+ ---
158
+
159
+ ## βš™οΈ Generation Parameters
160
+
161
+ | Parameter | Recommended | Description |
162
+ |-----------|-------------|-------------|
163
+ | `max_new_tokens` | 100–512 | Maximum length of generated joke |
164
+ | `temperature` | 0.7–0.8 | Controls creativity (higher = more varied) |
165
  | `top_p` | 0.9 | Nucleus sampling threshold |
166
+ | `do_sample` | `True` | Enable sampling for diverse outputs |
167
+
168
+ ---
169
+
170
+ ## πŸ”¬ Training Methodology
171
+
172
+ Data was synthesized using the **Cognitive Synergy Framework**:
173
+
174
+ 1. **Mixture-of-Thought (MoT):** Six distinct cognitive personas β€” *The Absurdist, The Cynic, The Neurotic, The Observer, The Wordsmith, The Optimist* β€” each generate 4 joke candidates per prompt from a teacher ensemble of Kimi-K2 and Qwen-2.5-32B-Instruct, yielding ~28,800 candidates across 1,200 prompts.
175
+ 2. **Elo Ranking:** All candidates are ranked via pairwise LLM evaluation using Llama-3.3-70B-Instruct as judge, producing per-prompt Elo ratings.
176
+ 3. **SFT Training:** The top-10 Elo-ranked candidates per prompt (12,000 total) are used to fine-tune the student model, promoting diversity across humor styles (wordplay, absurdity, sarcasm).
177
+
178
+ ---
179
+
180
+ ## πŸ’‘ Key Findings
181
+
182
+ - **SFT is the strongest variant:** DPO and GRPO do not improve over the SFT baseline β€” cognitive data quality is the primary driver of humor generation performance.
183
+ - **The Explainer Trap:** Training on reasoning traces hurts performance; the model learns to explain jokes rather than deliver them.
184
+ - **Data > Scale:** A well-curated 7B student outperforms a 32B teacher and a 120B open-weight model.
185
+
186
+ ---
187
 
188
+ ## πŸ“š Citation
189
 
190
  If you use this model in your research, please cite:
191