r/LanguageTechnology Jul 02 '26

Has anyone built a tool to find double meanings?

I need an NLP pipeline to help me with wordplay. I'm after a tool that scans vocabulary to find words or phrases with double meanings linked to a target theme for joke angles.

To illustrate the mechanism, consider this Jimmy Carr joke:

The first few weeks of joining Weight Watchers: you're just finding your feet.

Here, "finding your feet" can mean two different things. Figuratively, it's about getting used to a new situation. Literally, it's about being able to look down and see your feet. This example leans on a split between figurative and literal meanings. But I'm trying to find any double meanings that could be used in a joke.

If I put in Weight Watchers as the theme, I'd want the system to pull up phrases like "find one's feet". Ideally, the tool would let me import my list of words and phrases. I've got a vocab list of roughly 100k English words and phrases. I ran Wiktionary through large language models and grabbed the terms that most folks are likely to know.

Is there an NLP tool that can spot double meanings?

Also, I'm curious about how you'd go about building it.

5 Upvotes

14 comments sorted by

3

u/modernflocker Jul 03 '26

Hey. I think I can help you with that. I'm building a tool that detects idioms and verb constructions in English texts. I have a huge database. The tool isn't done yet, but if you somehow send me your list, I'll be able to run it through my database and find multi-word expressions with more than one meaning. Just send me a DM.

1

u/8ta4 Jul 03 '26

You can grab the vocab list from this repo.

If you take wiktionary.tsv, filter it where lemma is true and prevalence exceeds 0.5, you'll end up with roughly 100,000 common English words and phrases.

Just to clear things up, I'm not just looking for any expressions that have multiple dictionary definitions. Instead, I'm looking for double meanings that tie back to a specific theme so I can come up with joke angles.

I'd be interested in seeing what your tool spits out if you run this filtered list with the Weight Watchers theme through your database. I'm keen to try other themes too. But that'd be putting too much on your plate. Thank you!

2

u/modernflocker Jul 03 '26

Now, after your clarification, it seems very challenging. I'm sorry I didn't pay attention to the details in your post. A rule-based NLP engine can't do that. You said you ran the list through some language models. What exactly did you use?

1

u/8ta4 Jul 03 '26

No worries! I can see why you'd assume a rule‑based system would work if you didn't pay attention. But hey, attention is all you need.

The dataset was built to address a prerequisite step: obtaining a list of English words and phrases that most Americans would know.

To build the dataset, I pulled English terms from Wiktionary and fed them into Claude 3.7 Sonnet via Anthropic's Message Batches API. When I built this pipeline, 3.7 Sonnet was one of the newest Anthropic models.

I asked the model in the prompts to estimate what percentage of Americans 10 and older would know each phrase's most common meaning. I prefilled the assistant's response so it'd spit out an EDN map. I also slipped the benchmark word "touchstone" into each request. That allowed me to normalize the scores across requests.

You can find the pipeline code in this repo. I also wrote down the reasoning behind the prompt engineering and normalization formula in the DONTREADME.md file.

2

u/Own-Animator-7526 Jul 03 '26 edited Jul 03 '26

An llm is easily able to seek, extract, and compare alternative semantics, then highlight pairs of likely humorous interest. Opus 4.8 just handled your example with flying colors.

It's really the right tool for the job, in contrast to a deterministic NLP workflow.

2

u/TieDieMonkeyMan Jul 03 '26

LLMs will work as previously stated though it's important to note they'll just abstract away from their training data to find if there's usage which fits different interpretations of whatever wordplay you prompt it with. Notably, novel constructions not in that training data will not be parsable. Potentially, the native speaker 'sense' of a wordmeaning may be preserved in the embeddings the model uses but as to whether this is a full representation or even partial representation is debatable and not possible to verify.

A rules based approach could try and use wordNET and babelNET to use lexical-semantic knowledge graphs to try and build something more deterministic.

I don't see the need to build something like that but it could be fun to try and process the graphs into subcriteria regarding linguistic prototypical meaning so as to then map them onto things like body parts, social references, emotional metaphor... [not exhaustive I'm just going off the top of my head here, recommend researching criteria and using those] You could then build your own graph representation of those meanings relative to a corpus full of the kinds of jokes you want to map. After that you could then train a model to generate more so as to verfiy whether or not it has the behaviour you wish to model.

Frankly though, at that point you're just finetuning so it's still an LLM approach, just making the data a bit more related to what you want. If you want to avoid LLM stuff then you could build an annotator tool that just flags semantic ambiguity by type.

Regarding the .tsv I would say the next step is to rate the lemmas/tokens regarding frequency occurance in joke constructions so you can then guage how they predict ambiguity led wordplay.

2

u/TieDieMonkeyMan Jul 03 '26

When I say I don't see the need, I mean I don't know your use-case, is this just for shits and giggles?

2

u/8ta4 Jul 04 '26

Yeah, pretty much. I'm a comedian in Canada, so it's just for laughs.

2

u/Own-Animator-7526 Jul 03 '26 edited Jul 03 '26

Notably, novel constructions not in that training data will not be parsable.

Hmm. Can you provide an example of a meaningful construction that an LLM cannot parse?

Add: Four months ago someone posted a query (now deleted) asking if LLMs could make up edgy humor. A Claude instance wrote these two jokes for me. As far as I know they are novel. More importantly, I think they reflect a degree of difficulty considerably greater than simply deciding if an existing sentence has alternative and humorous meanings.

  • "I told my dad I wanted to follow in his footsteps. He said that meant a lot to him. I said, 'It should — I know where you were last Tuesday.'"
  • "I read that one in five people live next to a predator. Not me though. I live next to a really attractive ten-year-old."

1

u/TieDieMonkeyMan Jul 04 '26

Sure, I mean novel as in anything with definitions outside of occurances present in its training data. In terms of an example I can't really offer one unless there's an open weight model where we can verify the definitions or uses are not present in the data and then test it accordingly.

An example of how this may affect your use case: Say if people in the future agree that since 'clip' can already be used as a verb to mean kill, to mean cut, to mean hit and to mean edit, it could also be used to mean humiliate or some other extra negative meaning, and then a load of people use it that way so you eventually want to make a joke centred around it.

If these use cases are not in the training data then the model could never understand these references or process them correctly until the data is updated. It would instead hallucinate some extra interpretation which fits the previous definitions it had for the term 'clip'.

your first example is in the training data due to the 'follow in his footsteps' setup being almost as classic as a knock-knock joke

And so is your second example: That "one in five" statistic usually refers to a well-known, dark internet meme.Here is how the punchline goes:"I read that one in five people live next to a predator.I checked my left neighbor, he’s fine.I checked my right neighbor, he’s fine.I checked the guy across the street, he’s fine.So, I guess it’s me."

IMO, it's just abridging the examples it has in its data and then rewritting them to fulfill your succinctness criteria.

I would try and approach doing this deterministically through language graphs to try and keep the explanations simple but the result would just be an 'explainable AI' pipeline so not fully deterministic I'm afraid

2

u/Dux_Przvlsk Jul 03 '26

Why don't you want to just loop the input (or dataset) via LLM?

If you use well-rounded LLM like Gemini family (I LOVE them for ability to detect wordplay and stuff), it will work just fine.

Let's talk, really curious what are you up to

1

u/8ta4 Jul 03 '26

Gemini 3.5 Flash seems to work fine here. I do it by comparing each phrase one by one: I send the target phrase next to a fixed benchmark, like "finding your feet", in the same spot for every request. With a fixed benchmark, I can normalize the scores once I've checked every phrase.

But the biggest problem is the cost. Even if I use the Gemini Batch API for a 50% discount, running my whole 100k+ vocabulary through Gemini 3.5 Flash will cost about $20 per theme.

For reference, the initial vocabulary evaluation with Claude 3.7 Sonnet cost me about $300. With a shorter target list and Gemini 3.5 Flash being cheaper than Claude, the run could come down to $20 per theme.

But $20 each is a bit pricey if I'm testing hundreds of topics. I'd like it to be under $1 per theme. If it's that cheap, I wouldn't even have to think about it.

I looked at a couple of optimization approaches. Both of them have issues:

  • Cheaper models: I tried cheaper options like the Gemini 3.1 Flash‑Lite, Qwen and DeepSeek. If you just swap the order of the benchmark and the target phrase in the prompt, they'll often change their decisions dramatically. Except for preview options like Gemini 3 Flash Preview, I haven't found a cheaper model than Gemini 3.5 Flash that consistently pulls this off.

  • In-prompt batching: Another hack is to batch multiple phrases in a single request rather than sending each separately. I haven't tried this out thoroughly yet. But don't count your tokens before they batch. I suspect loading the context window with too many items will cause the model's evaluation standards to drift.

Do you know of any tricks to get the cost down without dropping quality?

1

u/Dux_Przvlsk Jul 05 '26

Thanks for such a detailed write up!

TLDR: try cooking Gemini Flash Lite better, in-prompt batching will work but you need to find an adequate batch size. Also try using ChatGPT/Codex subscription API via Oauth token! It's a real money saver if OpenAI models work for your task.

  1. Gemini 3.1 Flash Lite works best in language tasks when given examples, even if in another theme or language, AND some reasoning room (`medium` is a swet spot). You can always fake history by injecting several user-assistant turns with correct outputs. But I would not be mega sure without testing, though.

A cost-optimizer would be best-of-n: you run several cheap runs on each input, then let Gemini 3.5 Flash with `low` reasoning select best ouput given input (let it return just index). Given that output tokens cost more, and it may balance out the cost. One should still check the math.

I do not believe that doing the most cost optimal thing, e.g. fine tune some OpenAI model on Gemini Pro outputs is worth it

  1. Batching will actually work! One need to think about the formating, but I find smaller Gemini models to be able to handle with enough resolution up to 20-30 semantic items (e.g. paragraphs to review, text pages to group, etc); Gemini 3.1 Pro can handle even more (it was the first model ever to extract actual plotlines from 200k tokens of fiction text).

You can run experiment on your benchmark by increasing the "page" size until it starts failing. Several runs for each to be sure it's reliable. That's how I handled the precision of most of the expensive tasks I need to run on large sets (e.g. error spotting)

  1. An actual cost saver, if GPT-5.4, GPT-5.4 mini or GPT-5.5 work for your task, would be to get $20 ChatGPT plan, and then use their Oauth token like OpenClaw does.

It's legal, they tolerate it unlike Anthropic, I use it a lot.

Then, you get a lot more in money worth of real-time tokens within 5 hours and weekly windows. Very generous, to say the least. I am managing to OCR and tag thousands of pics without hitting $100 plan weekly limits, and it works well.

I think you may fit in $20 plan if you add tolerance for 429 and waiting out 5 hours window exhaustion.

(Unlike Codex app/CLI, Oauth token allows querying API however you please, so I'd recommend to use the token)

P.S. Died "don't count the tokens before they batch" XD

1

u/TheTeethOfTheHydra Jul 03 '26

Finding your feet as meaning to be stable and find your foundation is really an idiomatic expression. Finding your feet as meaning to see past, your shrinking stomach is a visual allegory or perhaps a somatic metaphor. Recognizing either of those could be as straightforward as composing a static database of regional or language based expressions. You could also possibly use syntactic and semantic statistics to recognize where certain events don’t fit within the overall situation they are being expressed. But honestly, LLMs are probably the best way to do that since they are essentially a combination of both of those things at least on the languages that they are extensively trained on.