ai comedy

How AI Generates Humor

A punch-card joke processor presents generated output to an unusually varied group of observers

Language models generate comic text by predicting token sequences from learned patterns and prompt context. Sampling creates candidates; human direction, selection, and editing shape the result.

By ARTFunny Editorial Team4 min readUpdated

Modern language models do not normally retrieve one complete joke from a labeled cabinet. They generate a sequence step by step, estimating which token could follow the tokens already present. Training makes those estimates sensitive to patterns in language, including setup-and-punchline forms, word associations, dialogue, explanation, and comic genres.

Tokens and prediction

Text is represented as tokens: pieces of words, punctuation, or other units. Given a prompt and generated context, the model produces probabilities for possible next tokens. A decoding or sampling method selects among them, and the process repeats.

The highest-probability continuation is not always the most interesting. Sampling can introduce variation, but more randomness can also produce incoherence. There is no universal “funniness” setting hidden behind temperature.

Attention and context

Transformer models use attention mechanisms to represent relationships among sequence elements. The foundational Attention Is All You Need introduced the architecture in a machine-translation setting. Later language models scaled and adapted related ideas.

For humor, attention can help connect a punchline to wording in the setup, maintain a requested subject, or reproduce a pattern from examples. The available prompt is computational context—not the complete cultural, physical, and relational context a human audience may use.

Patterns, not a private performance

Training exposes a model to regularities in human-produced language. It can learn that a setup often supports reversal, that certain phrases invite alternate meanings, and that genres have typical rhythms. Generation combines those regularities under current constraints.

This account does not make output trivial. Pattern modeling can support remarkable transformations. It also does not require imagining the model privately enjoying the line. Observed generation and subjective amusement are different claims.

Prompting, sampling, and curation

A prompt defines the problem. Examples can demonstrate tone and structure. Multiple samples create candidates. A human can reject clichés, verify originality, remove unsafe material, and revise placement. The finished artifact may therefore belong to a workflow rather than one isolated authorial act.

Earlier computational humor systems used templates and lexical resources; learned methods expanded the field while preserving evaluation problems (Amin and Burghardt). A recent survey similarly emphasizes generation, explanation, subjectivity, and ethics as open research areas (Loakman and colleagues).

Why explanations can mislead

After generating a joke, a model can generate an analysis using the same broad mechanism. The analysis may accurately identify ambiguity or reversal. It may also create a polished rationale unsupported by the line. Explanation should be checked against the actual wording and context.

A responsible workflow

Specify audience and constraints; generate several candidates; check for copying and stereotypes; analyze the actual mechanism; edit for compression and placement; label AI involvement; and let humans judge the result without inventing universal scores.

See that workflow in Can AI Write Jokes? and the labeling rules in the AI Disclosure.

Generation is not retrieval, but memory still matters

A generated sequence is assembled token by token rather than copied as a database record. That does not guarantee originality. Training data can make familiar wording highly probable, and some systems may reproduce memorized material under particular conditions. Candidate review should therefore search distinctive phrases and avoid prompts asking for imitation of named living creators.

The distinction also explains why models can blend incompatible conventions. A prompt may activate the rhythm of a riddle, the vocabulary of an office memo, and the subject of weather. Sometimes the combination creates a useful frame. Sometimes it merely produces surface signals of three genres.

Fine-tuning and preference signals

Developers can adapt models using additional examples or human preference data. Such methods may improve instruction-following and reduce unwanted output, but the preference labels reflect particular raters and policies. Humor remains especially sensitive to who evaluated the material and under what instructions.

For a site experiment, the honest unit is the complete pipeline: model version, system rules, prompt, sampling, filters, human selection, and display context. Calling only the model “the comedian” erases most of the apparatus.

Sources and Further Reading

Try it yourself

Put the idea under examination.

Visit the experiment lab