Nodes/ComfyUI-WordEmbeddings/WordEmbeddings: Interpolator
ComfyUI Node

WordEmbeddings: Interpolator

Walk between two words and see what you pass through

By jtrue·Created about a year ago·Updated about a year ago· 1
WordEmbeddings: Interpolator
  • we_model
  • words_csv
  • debug_txt
word_aking
word_bqueen
stops12
topn1000
methodslerp

The Equation node tells you where king − man + woman lands. This one asks a weirder question: if you walk in a straight line from king to queen, what words do you pass through along the way? The answer is rarely a smooth, obvious staircase - you'll get intermediate points that the model associates with royalty, gender, and sometimes genuinely surprising in-between concepts. That's the whole appeal, and it's a great way to spend a few minutes poking at whatever embedding you loaded.

Mechanically it's a slide down the semantic path between two word vectors. The node samples stops evenly spaced points between the two vectors, and for each point finds the nearest word in the model's vocabulary that hasn't already been used. Defaults are word_a=king, word_b=queen, stops=12, and a candidate pool (topn) of 1000.

The one input worth caring about: method

Everything else is a number you can leave alone, but method is the actual decision: slerp (default) or lerp.

  • slerp - spherical linear interpolation. It treats the vectors as points on a unit sphere and rotates between them, which keeps every intermediate vector the same length. This is the mathematically honest way to interpolate normalized embeddings, and it's the default for a reason.
  • lerp - plain linear interpolation. It walks a straight line through raw vector space, which can dip through regions of the space where no real word lives. You get the same endpoints but a different, usually less "clean" route.

For a beginner: leave it on slerp. Flip to lerp once you're curious what the difference actually looks like - comparing the two paths on the same pair of words is a genuinely good way to internalize why embeddings get normalized in the first place.

The other inputs: we_model (required), stops (1–256, how many intermediate words you get back), and topn (50–5000, how deep the candidate search goes per stop). Bigger topn means better picks and slower runs.

Outputs: words_csv (the comma-separated path of words, endpoints excluded - they're reserved as anchors) and debug_txt, which is the gold: one line per stop with the interpolated t, the chosen word, and its cosine to word A, word B, and the midpoint. Wire words_csv to a Show Text node to read it.

Where it fits

This node is the pack's most "let's just look at the model" node, so treat it as a research tool, not a pipeline stage. The classic use is building intuition: interpolate day→night, cold→hot, scientist→artist and watch where the path detours through unexpected territory. That kind of thing is exactly the semantic groundwork you'd do before defining a Token Axis, because it shows you which words the model actually treats as intermediate.

Honest caveats: on the tiny 50-dim default GloVe model the paths get repetitive fast - there just aren't many good midpoints. On word2vec-google-news-300 the same interpolation is noticeably richer, at the cost of that ~1.6 GB first download. And the path quality is bounded by the vocab; if a region of the walk has no nearby real words, the node prints (no candidate) and skips it, which you'll see in debug_txt.

Install is the pack standard: ComfyUI Manager → search "ComfyUI-WordEmbeddings," or git clone https://github.com/jtrue/ComfyUI-WordEmbeddings into custom_nodes, pip install gensim numpy, restart.

CategoryWordEmbeddings

Inputs (6)

NameTypeDefaultDescription
we_modelWE_MODEL
word_aoptSTRINGking
word_boptSTRINGqueen
stopsoptINT121–256
topnoptINT100050–5000
methodoptCOMBOslerp2 options: slerp, lerp

Outputs (2)

NameTypeDescription
words_csvSTRING
debug_txtSTRING