Semantle Solver

Using word embeddings to beat Semantle

July 10, 2023 | ~700 words | 4 min read


Wordle spinoffs are all the rage these days. I learned about a fun one last weekend: Semantle. Here’s the description from the website:

Semantle is a unique word-guessing game that focuses on the meanings of words. Players aim to find a secret word by making guesses that are semantically related. Feedback on each guess helps guide them closer to the target word, offering a challenging and fun experience for those who enjoy exploring language.

— semantle.com

The game involves guessing based on semantic similarity, which measures whether two words have similar meaning. Semantic similarity is probably best illustrated by example:

It’s fun! I played a few rounds, then started wondering if I could build a solver to beat the game more easily. Turns out it was pretty easy.

Gameplay

The game has a very simple interface. You simply enter a word into a text box, then it’ll tell you how “close” your guess was to the secret word.

The basic game interface.

It’s hard! Here are my results from a recent game, where it took me 11 guesses to get the right answer (“person”):

An example game that I played. 11 guesses is a pretty good result. I was lucky to find a word with high similarity ("thing") on an early guess.

That’s one of my faster solves—it often takes me more than 20 or 30 guesses if I don’t find a word with high similarity early.

Creating a solver

After a few games I started thinking about creating a solver. I thought surely the game must be built on word embeddings, which are built for the purpose of capturing semantic meaning. So I downloaded some pre-trained word Word2Vec embeddings and implemented the following algorithm:

  1. The solver chooses a random word from the corpus. The user enters it in Semantle.
  2. The user enters the similarity score from Semantle and enters it into the solver.
  3. If similarity == 100, we’re done. Success!
  4. Otherwise, filter the pool of possible guesses (the Word2Vec corpus) to only the words with a cosine similarity near the entered score.
  5. The solver chooses the next word to guess: the word with the closest cosine similarity to the last entered score.
  6. Repeat steps 2-5 until success.

It works! Actually, it works surprisingly well. Here’s the solver playing the same game as above:

The solver's guesses in the same game that took me 11 tries (screenshot from Semantle).
% python main.py
--------- remaining solutions: 157,244 ---------
current guess: trackable
Similarity = 21.7
--------- remaining solutions: 129 ---------
Next guess: microbeads
Similarity = 7.28
--------- remaining solutions: 2 ---------
Next guess: person
Similarity = 100

Succeeded after 3 guesses!
The command line inputs/outputs from the game.

As you can see, the solver uses an… interesting strategy. I expected it would play like a human, but better—each subsequent guess would have a higher similarity score, quickly zeroing in on the secret word. But actually, it behaves very differently. With just couple data points, it’s able to drastically reduce the number of possible solutions, even if the previous guesses weren’t very close. It’s basically triangulating to the correct solution, and it’s doing so much more efficiently than I expected.

How I expected the solver to reach the solution (left) vs. how it actually did (right), demonstrated in a 2D vector space where the red point represents the solution and arrows point to each subsequent guess. It's more efficient than I expected, but it plays the game very differently than a human.

The result is an extremely good solver. It almost always finds the solution in 3 guesses, sometimes 2, sometimes 41. That said, it does suck the fun out of the game a little bit!

The source code for the solver is here.


  1. Roughly 4% success rate in 2 guesses, 88% in 3 guesses, and 8% in 4 guesses in my testing. ↩︎


Tags: projects NLP