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

WordEmbeddings: Token Centrality

Is this word 'generic' or a weird outlier? The model has an opinion.

By jtrue·Created about a year ago·Updated about a year ago· 1
WordEmbeddings: Token Centrality
  • we_model
  • centrality
  • norm
  • summary
tokenking
token_can_be_phrasetrue
lowercasetrue
strong_thr0.65
moderate_thr0.35
include_orientationfalse
orientation_eps0.050

Every other node in this pack compares a word to other words. This one compares a word to the whole corpus: it computes the cosine similarity between the token and the model-wide average direction of all its words. The result is a single number in [-1, 1] that tells you how "typical" or "central" the word is in this particular embedding's space. High magnitude means the word sits near the semantic center - the generic, frequently-ish direction most words point along. Low magnitude means it's off to the side - a distinctive outlier.

It's the least flashy node in the pack and the easiest to be skeptical of, but it earns its keep in two spots. First, it's a sanity check on your model: load a model, run a handful of common words (the, and, time, water), and they should cluster at high centrality, while rare or domain-specific terms drift lower. If that pattern holds, your embedding loaded sensibly. Second, it's a cheap filter - "how generic is this token?" is exactly the kind of signal you'd use to pick between candidate prompt terms when one is a common word and the other is a niche spelling.

How it works

The node normalizes the token's vector, computes the corpus-wide mean direction of all word vectors (cached per model in memory so you only pay for it once), and takes the dot product. That's cosine similarity. The norm output is the raw vector length of the token before normalization - and the README's caution is worth repeating: some embeddings store frequency-ish information in vector norms, but it isn't universal, so treat norm as comparative within one model, not as an absolute anything.

The summary tiers the result for you: above strong_thr (default 0.65) is "highly central (very typical)", above moderate_thr (0.35) is "moderately central", below that is "weakly central (distinctive/outlier)". With include_orientation turned on, the summary also mentions whether the token points along the average orientation, opposite to it, or near-orthogonal - interesting, but default-off for a reason: the sign of centrality isn't consistently meaningful across models.

The inputs that matter

  • we_model (required), token (default king), token_can_be_phrase, lowercase - the standard family controls.
  • strong_thr / moderate_thr - where the "typical / middling / outlier" boundaries sit. Lower them if your model's values run small.
  • include_orientation / orientation_eps - the optional orientation sentence and its threshold.

Outputs: centrality (FLOAT), norm (FLOAT), summary (STRING). Wire centrality anywhere you'd feed a score.

Where it fits and where it doesn't

This is a research and scoring node, not a pipeline staple. If you came here hoping it explains why one prompt term overweights an image, it won't - again, this measures a word's position in a static embedding space, which is a cousin of your text encoder's space, not a direct line into the sampler. And the "generic = central" intuition is a heuristic, not a law: some perfectly normal words live at the edges because their vector directions are unusual. Take the outlier verdict as a prompt to investigate, not a verdict on the word.

Also worth knowing: the first run computes the mean over the whole vocabulary, which for word2vec-google-news-300 is a few million words and a real pause before the node answers. It's cached after that, so it hurts once per loaded model. Install is the pack standard - Manager search "ComfyUI-WordEmbeddings," or git clone https://github.com/jtrue/ComfyUI-WordEmbeddings into custom_nodes, pip install gensim numpy, restart.

CategoryWordEmbeddings

Inputs (8)

NameTypeDefaultDescription
we_modelWE_MODEL
tokenoptSTRINGking
token_can_be_phraseoptBOOLEANtrue
lowercaseoptBOOLEANtrue
strong_throptFLOAT0.650–1
moderate_throptFLOAT0.350–1
include_orientationoptBOOLEANfalse
orientation_epsoptFLOAT0.0500–0.2

Outputs (3)

NameTypeDescription
centralityFLOAT
normFLOAT
summarySTRING