Nodes/ComfyUI-WordEmbeddings/WordEmbeddings: Token Axis
ComfyUI Node

WordEmbeddings: Token Axis

Project any word onto a semantic meter — is 'king' more male or more royal?

By jtrue·Created about a year ago·Updated about a year ago· 1
WordEmbeddings: Token Axis
  • we_model
  • x
  • summary
  • cos_left
  • cos_right
tokenking
axisman,boy,he,him,his,king,father,brother,husband,actor|woman,girl,she,her,hers,queen,mother,sister,wife,actress
token_can_be_phrasetrue
lowercasetrue
neutral_eps0.08
equal_eps0.020

This is the node the whole pack is really about. Give it a word and a semantic axis, and it tells you where that word sits on the axis - a single number in [-1, 1] plus a plain-English sentence explaining what it found. king on a male/female axis comes back positive and "more male than female, with strong confidence." It's a transparent, reproducible semantic meter, and it's the closest thing this pack has to a headline feature.

The axis format is the one thing to learn, and it's easy: write it as left pole | right pole, with comma-separated synonyms on each side. Each side is averaged into a single pole vector, so a few good synonyms beat one lucky word. The README's default is the gender axis:

man,boy,he,him,his,king,father,brother,husband,actor | woman,girl,she,her,hers,queen,mother,sister,wife,actress

More poles to steal: temperature (hot,warm,heat,boiling | cold,cool,freezing,ice), royalty (royal,king,queen,prince,noble | common,commoner,peasant,ordinary), formality (formal,proper,polite | casual,slang,informal). Three to ten synonyms a side is the sweet spot.

How it works

Under the hood: each pole becomes the unit-normalized mean of its words' vectors, the axis direction is left_mean − right_mean, and x is the token's projection onto that direction. Positive x means the token leans left; negative means right. It also computes cos_left and cos_right - how strongly the token resonates with each pole independently, which is how it knows confidence. That's all gensim vectors and NumPy; no neural net runs at inference.

The inputs that matter

  • we_model (required) - from a Loader.
  • token - the word (or phrase, if token_can_be_phrase is on) you're placing on the axis. Default king.
  • axis - the left|right pole definition above.
  • token_can_be_phrase (default true) - if your token is "ice cream", the node averages the unit vectors of both words. Cheap and effective.
  • lowercase (default true) - fold everything to lowercase before lookup. Leave it on unless you're testing case sensitivity.
  • neutral_eps (default 0.08) - if |x| is below this, the summary calls the word "similar" to both poles instead of picking a side.
  • equal_eps (default 0.02) - below this, the summary says "equal." You can tune both, but the defaults are sane.

Outputs: x (FLOAT, the projection), summary (STRING, the human sentence), cos_left and cos_right (FLOATs). Wire x into anything that eats a float - a weight, a schedule, a comparison - and wire summary into a Show Text node to read it.

Where people get burned

Vocabulary, always. If a pole has no in-vocab words, that side is silently unavailable and the axis falls back to single-sided or reports "axis unavailable." Check your spellings, and remember lowercase is on by default.

Bias is not a bug, it's the dataset. Static embeddings absorb the biases of their training text, and this node is a microscope for exactly that. Run "she is more home than career" style axes and the model will happily confirm your corpus's 2014-era biases with high confidence. The README flags this explicitly, and it's the reason to be thoughtful about the axes you publish. Don't shoot the messenger - but don't trust the meter as ground truth, either.

Also: the projection is into word embedding space, not your text encoder's. Great for prompt research and for driving numbers in a workflow; it is not conditioning your sampler directly.

Installation

Pack standard: ComfyUI Manager → search "ComfyUI-WordEmbeddings," or

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

then restart ComfyUI. The node itself has zero extra downloads - the model comes from the Loader upstream.

CategoryWordEmbeddings

Inputs (7)

NameTypeDefaultDescription
we_modelWE_MODEL
tokenoptSTRINGking
axisoptSTRINGman,boy,he,him,his,king,father,brother,husband,actor|woman,girl,she,her,hers,queen,mother,sister,wife,actress
token_can_be_phraseoptBOOLEANtrue
lowercaseoptBOOLEANtrue
neutral_epsoptFLOAT0.080–0.5
equal_epsoptFLOAT0.0200–0.2

Outputs (4)

NameTypeDescription
xFLOAT
summarySTRING
cos_leftFLOAT
cos_rightFLOAT