---
title: 'HumorPlanSearch: Context-Aware Joke Generation'
url: https://www.emergentmind.com/topics/humorplansearch
type: topic
---

# HumorPlanSearch: Context-Aware Joke Generation

HumorPlanSearch is a modular pipeline for automated humor generation with large language models that treats joke writing as a structured problem of planning, contextual reasoning, retrieval, filtering, and revision rather than a single “prompt and sample” step. It is designed to generate jokes that are context-aware, culturally tuned, and non-repetitive by explicitly modeling topic, audience style, historical strategy reuse, and iterative evaluation. In the reported formulation, the pipeline combines Plan-Search for strategy generation, Humor Chain-of-Thought (HuCoT) templates, a knowledge graph of historical strategies, semantic novelty filtering, and a judge-driven revision loop, with quality assessed through the Humor Generation Score (HGS) [2508.11429].

## 1. Problem setting and conceptual basis

HumorPlanSearch is motivated by the observation that standard LLM humor generation often produces jokes that feel generic, repetitive, or tone-deaf because humor is deeply situated and depends on the listener’s cultural background, mindset, and immediate context. The system therefore reframes humor generation as a structured planning and search problem in which multiple candidate strategies are explored, compared, and revised before final jokes are selected [2508.11429].

In this formulation, “context” is multi-dimensional. It includes topic, cultural style, audience persona, emotional tone, and local discourse setting. A single prompt such as “Write a funny joke about startups for Indian Gen Z” does not force a model to reason systematically about audience, cultural references, style, and novelty. HumorPlanSearch addresses that limitation by separating strategy formation from wording, and by introducing explicit intermediate structures for cultural and stylistic reasoning [2508.11429].

A closely related comprehension-side perspective appears in HumorBench, which defines “getting the joke” as requiring hypothesis formation and testing, backtracking, and multi-step reasoning over associations, constraints, and background knowledge. That work treats humor understanding as a planning/search process over interpretations rather than as a purely intuitive reaction. This suggests that HumorPlanSearch extends a broader research trend in which humor is modeled as structured reasoning rather than as unstructured text generation [2507.21476].

## 2. Pipeline architecture

HumorPlanSearch begins with a topic prompt and ends with a set of jokes plus their reasoning traces, ranked by HGS. The reported pipeline contains five stages: Plan-Search, HuCoT generation, novelty filtering, hybrid scoring, and judge-guided plan revision [2508.11429].

| Component | Function | Reported detail |
|---|---|---|
| Plan-Search | Generate and combine humor strategies | `gemma2-9b-it`; \(N = 12\) first-order strategies |
| Hybridization | Build second-order strategies | up to \(k \times 3\) hybrids, with \(k = 3\) |
| Knowledge Graph | Retrieve historical strategies | persistent NetworkX graph |
| Novelty filtering | Remove near-duplicate jokes | `all-MiniLM-L6-v2`, cosine threshold \(0.75\) |
| Revision loop | Improve weak strategies | `llama3-70b-8192`, up to 2 iterations |

A humor strategy is a semi-structured description of how to approach a topic comedically. It specifies style, humor mechanism, narrative elements, cultural references, and tone. The Strategy LLM produces \(N = 12\) distinct first-order strategies for each topic, then combines them in pairs to form second-order hybrids, up to a maximum of \(k \times 3\) hybrids with \(k = 3\). High-performing historical strategies are also retrieved from a persistent NetworkX knowledge graph and adapted to the current topic, then added to the active pool [2508.11429].

The knowledge graph is represented conceptually as \(G = (V, E)\), where nodes represent strategies or contexts and edges represent relations such as strategy–topic, strategy–style, and strategy–performance. Retrieved strategies are adapted by preserving their underlying humor structure while replacing topic-specific surface content. This provides a form of persistent memory rather than generating each joke from scratch [2508.11429].

Novelty filtering is applied after joke generation. Each joke is embedded with `all-MiniLM-L6-v2`, and cosine similarity is used to detect semantic overlap. If the maximum similarity between a new joke and already retained jokes is at least \(0.75\), the joke is discarded as insufficiently novel. With this threshold, about 18% of generated jokes are removed as being too similar [2508.11429].

The revision stage operates at the strategy level. For each iteration, jokes are generated from the current strategy set, filtered for novelty, scored with HGS, aggregated back to per-strategy performance, and then revised if needed. Strategies are partitioned into
\[
S_{\text{low}} = \{ s \mid P_s < 6.0 \}
\]
and
\[
S_{\text{high}} = \{ s \mid P_s \ge 7.0 \},
\]
where \(P_s\) is the average HGS of jokes generated from strategy \(s\). Low-performing strategies are revised using judge suggestions, and revisions are applied only if projected improvement is at least \(0.2\). The default maximum number of iterations is 2 [2508.11429].

## 3. Humor Chain-of-Thought and scoring

HuCoT, or Humor Chain-of-Thought, is the pipeline’s explicit reasoning format for joke construction. It is analogous to chain-of-thought prompting, but its steps are tailored to humor: audience modeling, cultural micro-context, narrative setup, humor device selection, and punchline construction. HuCoT is therefore not a generic logical scaffold; it is a domain-specific reasoning template for contextual comedy [2508.11429].

Three HuCoT templates are defined. The Generic template has 8 steps and emphasizes universal comedic structures, timing, and punchline design. The Indian template has 6 steps and emphasizes cultural micro-context, shared experiences, and delivery. The Gen Z-Indian template has 7 steps and emphasizes dark reality, meme culture, and cultural code-switching [2508.11429].

The evaluation metric is the Humor Generation Score, defined as
\[
\text{HGS} = \sum_{i=1}^{4} w_i \times s_i, \quad \sum_{i=1}^{4} w_i = 1.
\]
The four signals are: direct vote scoring \(s_1\), multi-persona scoring \(s_2\), pairwise win-rate \(s_3\), and topic relevance \(s_4\). The paper does not provide the exact numerical values of the weights \(w_i\), but it does specify the structure of the weighted sum [2508.11429].

Topic relevance is defined through cosine similarity between the joke embedding \(\mathbf{j}\) and the topic embedding \(\mathbf{t}\):
\[
s_4 = \frac{\mathbf{t} \cdot \mathbf{j}}{\|\mathbf{t}\| \, \|\mathbf{j}\|}.
\]
The multi-persona component uses three evaluator personas—Enthusiastic Fan, Critical Critic, and Academic Analyst—to reduce single-perspective bias. Pairwise win-rate compares jokes head-to-head, and direct vote scoring uses a 1–5 judge rating. Together these signals define a hybrid metric intended to capture funniness, comparative strength, and topical fit [2508.11429].

## 4. Experimental results and empirical behavior

The reported experiments cover 9 topics with feedback from 13 human judges of mixed cultural backgrounds, ages 20–45. Four system configurations are compared: Baseline, KG Only, Revision Only, and KG + Revision. The full configuration, combining knowledge graph retrieval and iterative revision, achieves the highest mean HGS across styles and topics [2508.11429].

The headline result is a 15.4% increase in mean HGS over a strong baseline, with \(p < 0.05\), and the results are reported with 95% confidence intervals. The configuration study functions as an ablation: KG alone helps, Revision alone helps, and combining both yields the strongest overall result [2508.11429].

The paper illustrates the contextual role of style with the topic “Startup Culture.” The Generic style produces jokes about “move fast and break things” in relationships and A/B testing dating life. The Indian style uses observational humor about office kitchen pizza battles, “ninja battle, yaar,” and developers optimizing pizza-snatching. The Gen Z-Indian style uses economic anxiety, “be a unicorn beta” versus “be a sloth, please,” and Indo-English code-switching. These examples are presented as evidence that the system changes not only wording but also underlying comedic framing across style templates [2508.11429].

The reported failures are also informative. Some outputs remain generic, especially in the Generic HuCoT style. The system can still misread subtle cultural cues, and multi-step reasoning can produce overly elaborate jokes that lose punchiness. Smaller LLMs, such as models in the Llama3-8B class, perform notably worse for nuanced, context-rich humor. These results indicate that the pipeline improves contextualization without eliminating the underlying difficulty of humor generation [2508.11429].

## 5. Relation to neighboring humor-reasoning frameworks

HumorPlanSearch belongs to a broader research program that treats humor as structured reasoning, explanation, and social interaction. HumorBench models humor comprehension as hypothesis formation, ambiguity detection, world-knowledge integration, and backtracking, using rubric-based evaluation over approximately 300 cartoon-caption pairs. Its central claim is that “getting the joke” requires planning/search over interpretations, constraints, and background knowledge. This suggests a comprehension-side analogue to HumorPlanSearch’s generation-side planning [2507.21476].

BottleHumor provides a multimodal explanation framework that is explicitly described as a planning-and-search procedure over implicit knowledge and candidate interpretations, guided by an information bottleneck objective. Its pipeline iteratively generates implications and candidate explanations, then selects non-redundant, explanation-supporting knowledge over multiple hops. This offers a different but compatible view of humor reasoning as search over knowledge snippets and explanation hypotheses [2502.18331].

A separate line of work defines the Humor Reasoning Data Object as the quintuple
\[
(C, X; Y, R; Z),
\]
where \(C\) is social dialogue or context, \(X\) is the teller’s humorous attempt, \(Y\) is the receiver’s reaction, \(R\) is the receiver’s explanation, and \(Z\) is the teller’s recovery response after humor failure. That formulation models humor as social interaction rather than as isolated joke text. This suggests that HumorPlanSearch could be extended from strategy planning for single jokes to planning over broader interactional structures, including reactions, appropriateness, and repair [2605.25171].

Large-scale caption-preference work on New Yorker contests provides a complementary empirical substrate: over 250 million human ratings on more than 2.2 million captions, together with ranking-based evaluation protocols. That literature reports that RLHF and DPO expose important limitations on creative tasks, and that even strong models such as GPT4 and Claude underperform top human contestants. This supports the view that humor generation remains a difficult ranking-and-search problem even when very large preference datasets are available [2406.10522].

## 6. Limitations, misconceptions, and future directions

HumorPlanSearch does not claim that humor can be reduced to a single scalar or a universally valid style template. Its central design assumption is narrower: that context can be foregrounded at each stage from strategy planning to evaluation, and that this improves coherence, topicality, and cultural fit relative to undifferentiated prompting [2508.11429].

A common misconception is that the system is primarily a joke-sampling pipeline with minor reranking. The reported design is more structured than that. Strategy generation, hybridization, knowledge-graph retrieval, HuCoT prompting, novelty filtering, and revision all operate as distinct modules. The system therefore treats humor generation as a staged search process rather than as one-pass decoding [2508.11429].

Its limitations are explicit. The human evaluation involves only 13 judges, which constrains generalizability. HGS is an automated metric and has not yet been correlated with live audience reactions. The experiments are computationally expensive because they require multiple large-model calls, embedding computation, and knowledge-graph operations. The paper also notes that it does not specify a formal toxicity filter, although HuCoT includes appropriateness reasoning and judge personas can be prompted to penalize culturally insensitive jokes [2508.11429].

The stated future directions include pilot deployments in open-mic or stand-up comedy clubs, a simulated comedy room based on live performance data, domain-specific humor engines for games and therapeutic chatbots, meta-learning HuCoT so that a smaller model can generate reasoning steps dynamically, reinforcement learning using judge signals as rewards, more direct human-in-the-loop revision, study of decoding effects such as temperature and sampling, and extension of PlanSearch ideas to stories and poetry [2508.11429].

Taken together, HumorPlanSearch defines a research agenda in which humor generation is organized around explicit strategy search, culturally conditioned reasoning templates, persistent memory of prior successes, semantic novelty control, and iterative judgment. In that respect it is both a concrete system architecture and a specific formulation of contextual humor generation as a planning problem [2508.11429].

Source: https://www.emergentmind.com/topics/humorplansearch