
Your agent can recall the nearest memory in milliseconds — but it can’t make a joke, and it can’t tell you why a joke works. Humor Embeddings argues those are the same problem run backwards. Memory retrieves what’s nearest to a query; humor looks for what sits at the right distance and can still be joined by a bridge nobody expected. Same vector index, opposite goal. So a joke can be scored, explained and tuned to its audience, and this version also says where the joke goes: one short spoken line, in a deadpan android voice, with the rest of the answer left plain. Part of our open Building Jarvis series.
Abstract
We present a formal computational framework for humor generation that operationalizes Koestler’s (1964) bisociation theory as geometry in vector embedding spaces. The central claim is that humor and memory retrieval are dual operations on the same semantic machinery: memory retrieves what lies nearest to a query; humor searches for what lies at the right distance and can still be joined by an unexpectedly valid bridge. We formalize this memory–humor correspondence and define a computable humor potential function grounded in Suls’ (1972) two-stage incongruity-resolution model.
We identify 12 humor-generating semantic patterns organized into five meta-categories, each defined as a specific embedding-space operation, and propose humor associations as a first-class relationship type in agent memory architectures. A preliminary computational pilot (n = 15 concept triplets) falsifies the initial formulation, revealing that naive coherence conflates semantic proximity with comedic validity. This negative result motivates a revised surprise-weighted formulation that decomposes bridge quality into independent validity and surprise components.
Independent measurements on the same frozen 384-dimensional sentence-embedding substrate this framework runs on—reported in a separate offline study of an agent-safety subsystem—find that structural channels over that substrate carry real discriminative signal: a clause-cosine incongruity channel, the geometric primitive at the core of this framework, reaches AUROC 0.896, while a k-NN novelty channel reaches AUROC 0.875, and a supervised head trained on the same frozen embeddings to predict a semantic property collapses to AUROC 0.286 (below chance). We use that split to bound which parts of our pipeline the substrate can be trusted to carry.
We provide reproducible experimental protocols with power analysis (N ≥ 64 raters) for validation against human ratings. The framework is designed as the affective layer of a larger agent architecture: it draws its concept neighborhoods from a semantic-memory index and is gated by a persona layer that decides when humor is appropriate — the computational counterpart of the limbic reward circuit that makes humor feel good in humans.
Finally, we close the gap between scoring a joke and delivering one: humor lives in a single channel, the agent’s short spoken line, in the deadpan voice of an android observer, while the rest of every answer stays plain.
The framework, in numbers
Claims from the paper (v4.9), stated here without the proofs. The definitions, the pilot, the validation protocol and the delivery tests are in the PDF.
How it works, in one minute
- Memory and humor run on the same index, backwards. Retrieval returns the nearest concept to a query. Humor returns a concept that is far away but still joinable. Same embeddings, same distance metric, opposite target, and no separate “joke database.”
- A joke is two distant concepts plus a bridge. The score multiplies three things: how far apart the two concepts are (the surprise), how validly a bridge concept connects to both (the resolution), and how unexpected that bridge is. All three must be non-zero; that multiplicative shape is Suls’ two-stage “incongruity then resolution.”
- There’s a distance sweet spot. Too close and the connection is obvious and boring; too far (near-orthogonal vectors) and no coherent bridge exists. The paper proposes a productive band of cosine distance and shows the unfunny pairs sit just outside it.
- The naive version failed, and the paper reports it. The first formula scored boring pairs higher than funny ones, because raw cosine coherence rewards proximity. Splitting bridge quality into independent validity and surprise terms is what fixes it.
- The substrate holds up — where it matters. An independent offline study on the identical frozen 384-dimensional MiniLM encoder found that structural channels (distance, rank, incongruity geometry) reach AUROC 0.875–0.896, while a supervised head trained on the same frozen features to predict a higher-order semantic property fell to 0.286, below chance. That supports the geometry the framework uses, says nothing yet about whether its jokes are funny, and is a warning for the sensitivity gate, which asks the same substrate to judge harm.
- It plugs into an agent, not a vacuum. A semantic-memory layer supplies the candidate concepts; a persona layer flips a
humor_enabledflag to decide whether a joke is even appropriate; this layer is the reward circuit that scores the connection. - Jokes go in one place only. Each answer has a short spoken line (thirty words at most, read aloud) and a plain body with the tables, code and steps. Humor is allowed only in the spoken line, in the voice of Data from Star Trek: The Next Generation: literal readings of idioms, field notes on human habits, absurd precision. Sarcasm never targets the person and switches off when the conversation shows frustration. About one line in three carries a joke at first, and that rate moves with how the jokes are received. Six named tests decide whether the design works.
In the ecosystem
Some nearby work doesn’t study humor at all, yet runs on the same memory machinery this paper depends on.
chopratejas/headroom — reversible context compression. Section 2.7 of the paper explains why it matters here. Humor associations live in a persistent event store, and cross-session humor calibration (Section 8.7) is lost if that store gets summarized away when context is compacted. Headroom’s lossless Compress–Cache–Retrieve approach keeps such a store recoverable. The overlap is narrow: headroom compresses to preserve recall, while the humor-association store records discrepancies to invert it. The two can sit side by side.
The Humor Embeddings framework is part of Building Jarvis, an open series on persistent agent architecture. Follow the work and contribute at github.com/globalcaos/tinkerclaw.
Read the paper

35 pages · the full humor potential function, the 12-pattern taxonomy, five bridge-discovery algorithms, the falsified pilot, the human-rating validation protocol, and the delivery design with its six tests
Was this useful?
We’re building these in the open and we want your read on them. Was it useful, 👍 or 👎? Would you wire humor onto your agent’s existing memory index this way? Tell us in the comments below.
Everything on the site, by topic or date: Browse the Tinker Zone
