UMAP Representation of a Semantle Game

March 24th, 2022 - Nils Trost

Semantle, created by David Turner, is an interesting spin on the recent trend of word guessing games. Instead of finding similarities in the spelling, semantle compares the semantic similarity between the words. Here I threw together a bit of code to visually explore a game of semantle using a UMAP representation of the underlying word2vec word embedding. You can follow along with my bumbling semantle guesses, or, probably more fun, visualize your own guesses.

You can install all of the used packages using pip, and all except for Babyplots also using conda.

First we load the full word2vec model (not included in the repository, but you can find it here.

Semantle has a list of allowed and banned words. We need to filter the model by these, so that our UMAP is representative (Filtering code adapted from the original semantle source code). These lists are also not included in this repository, but you can find them in the semantle repository.

Now we create a subset of the word2vec model with just the allowed vectors (this takes quite long, because I add the vectors one by one instead of batch-wise which would be better).

Save it, so we don't have to do it again.

Now we load the model with only the allowed words.

This example is based on semantle #53, where the secret word was "shot". So we first get the 1000 closest words to "shot".

Now we load my guesses. You can also do this for your semantle attempts, by replacing the words in guesses.txt (and the secret word).

Next, we get the closest 1000 words around the guesses, but keeping only unique words.

Put the secret word at the end of the guesses.

Here, we get the vectors for the selected words...

... and run the UMAP dimensionality reduction.

Finally, we create a dataframe to organize the data for visualization...

... get the coordinates of the guessed words ...

... and create the babyplots visualization of the UMAP and the guessed path. Drag the mouse over the plot to rotate and shift+scroll to zoom in and out.