Nodes/ComfyUI-WordEmbeddings/WordEmbeddings: Explorer
ComfyUI Node

WordEmbeddings: Explorer

The quickest way to see what a word 'means' to a model

By jtrue·Created about a year ago·Updated about a year ago· 1
WordEmbeddings: Explorer
  • we_model
  • words_csv
  • debug_csv
wordking
k10

One input word, one output list: the top-k nearest neighbors of that word in the embedding space. This is the simplest node in the whole pack, and honestly the one you'll reach for first, because it's the fastest way to develop intuition for whatever model you loaded. Type king, and instead of a definition you get a ranked list of the words the model considers closest to king - usually royalty, family, and power terms, in roughly that order.

That ranking is the model's actual theory of the word, exposed without a layer of prompt engineering on top. If you're trying to understand why an embedding treats two terms as near-synonyms, or whether a domain-specific corpus put spanner next to wrench or next to cricket, this is the node that answers it in one click.

How it works

Under the hood it calls gensim's most_similar(word, topn=k) and flattens the result. The model looks up the word's vector and returns the vectors closest to it by cosine similarity - same metric the whole pack uses. It's case-insensitive with a fallback (it tries your exact string first, then the lowercase version), so King still finds king in a lowercase vocab.

The inputs are a two-field affair: we_model (required, from a Loader) and word (default king, any string). k ranges from 1 to 50, default 10.

Outputs are two strings: words_csv, a plain comma-separated list of neighbor words, and debug_csv, the same list with each word's similarity score appended (queen:0.769). If your word isn't in the vocabulary, words_csv comes back empty and debug_csv carries a Not in vocab: <word> message.

Where it fits, and where it doesn't

For a beginner this node is the training wheels for the whole pack: it needs nothing except a loaded model, so it's the perfect smoke test that your Loader actually worked. It's also a great sanity check before you build a semantic axis - if actor and actress show up as close neighbors of each other, a gender axis built on those poles is going to behave.

Just don't expect it to do anything clever. It's neighbors only - no analogies, no axes, no summary sentence. Those live in the Equation and Token Axis nodes. And the neighbors are only as interesting as your model: on the tiny 50-dim GloVe default the results can feel coarse, while word2vec-google-news-300 produces famously good nearest-neighbor lists at the cost of a hefty first download.

Installation

The standard pack install, identical for every node in it:

cd ComfyUI/custom_nodes
git clone https://github.com/jtrue/ComfyUI-WordEmbeddings
pip install gensim numpy

then restart ComfyUI - or use ComfyUI Manager and search "ComfyUI-WordEmbeddings." Nothing extra for this node specifically; the model download is upstream in the Loader. One heads-up: the pack is small and essentially unknown in the community, so if you load a workflow containing these nodes, that's its only install step.

CategoryWordEmbeddings

Inputs (3)

NameTypeDefaultDescription
we_modelWE_MODEL
wordoptSTRINGking
koptINT101–50

Outputs (2)

NameTypeDescription
words_csvSTRING
debug_csvSTRING