DEV Community

Akage
Akage

Posted on

I built a 3D playground to see how AI understands words - WordCanvas3D

To a language model, the word "cat" is just a long list of numbers. So is "dog". So is "democracy".

What surprised me is that those numbers aren't random. Words with similar meanings end up close to each other, and some relationships even turn into directions you can do math with. I wanted to actually see that, not just read about it. So I built WordCanvas3D.

πŸ”— Try it: https://wordcanvas3d.vercel.app/
πŸ’» Code: https://github.com/Akage1234/WordCanvas3D

It's free, open source, and runs in your browser. No signup.

Here's what you can explore.

Fly through a map of meaning

A 3D cloud of glowing word points on a dark background, with nearby words grouped into clusters

Every point is a word. Grab the scene, spin it around, zoom in, and you start noticing neighborhoods: animals near animals, countries near countries, emotions near emotions.

Search for a word and the camera flies straight to it, so you can see who its neighbors are.

You can also switch between two ways of squashing hundreds of dimensions into three:

  • PCA keeps the big picture, the overall spread of the data.
  • UMAP keeps local neighborhoods tight, so clusters pop out more clearly.

Switching between them on the same words is one of the most interesting things to try. The same data tells a slightly different story each way.

See how a model actually reads your sentence

The tokenizer comparison screen, with one sentence split into colored token chunks by two different tokenizers

Models don't read words, they read tokens: chunks that can be whole words, parts of words, or single characters.

Type a sentence and watch GPT and LLaMA split it differently, side by side. Some fun things to try:

  • A long or rare word
  • Numbers and dates
  • A sentence in another language

It explains a lot about why "token limits" and "token pricing" work the way they do.

Do math with meaning

The vector playground showing word arrows in 3D space, with the result of a word equation highlighted

This is the part that hooked me in the first place:

paris βˆ’ france + italy β†’ rome
Enter fullscreen mode Exit fullscreen mode

Take "paris", remove the "france" part, add "italy", and you land near "rome". The model was never taught capitals. That relationship just emerged from reading lots of text.

Try your own equations and see where they land. Not all of them work, and the failures are just as interesting.

Learn the ideas behind it

An explainer article page with a short heading, a few lines of text and an illustration about embeddings

While building this I had to learn a lot myself, so I wrote short visual guides on embeddings, tokenizers and vectors. They're meant to be read in a few minutes alongside the tool.

Small things that make it nicer

Full screen mode hides the panels so it's just you and the words:

The embedding explorer in full screen mode, with the 3D word cloud filling the whole window and a small control bar at the bottom

It works on phones and tablets, with touch controls for rotating, panning and pinch-zooming:

WordCanvas3D on a phone screen, showing the 3D word view with a dock of controls at the bottom

And it speaks four languages: English, δΈ­ζ–‡, ζ—₯本θͺž and EspaΓ±ol.

The WordCanvas3D interface shown in a non-English language, with translated menus and labels

How it's built

  • Next.js for the app
  • Three.js for the 3D view
  • Tailwind CSS for styling
  • next-intl for translations
  • Python to prepare the data ahead of time

The heavy lifting (loading embeddings and reducing them to 3D) happens beforehand in Python. The browser only loads the finished coordinates, which keeps things smooth even on a phone.

One honest caveat: squeezing hundreds of dimensions into three always loses some information. Nearby words are usually related, but distances are approximate. Think of it as a map, not a measurement.

Go explore

πŸ‘‰ https://wordcanvas3d.vercel.app/

If you find a weird cluster or an equation that surprisingly works, I'd love to see it in the comments.

And if you want to help: the code is open source, and translating the Learn articles is a great first contribution.

⭐ https://github.com/Akage1234/WordCanvas3D

Top comments (0)