--- 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} } ```