gensim>=4.3.3 numpy>=1.20
Word embedding utility nodes for ComfyUI. Load a pre-trained embedding model, explore neighbors, do analogies, and project any token/phrase onto 1D/2D/3D semantic axes with human‑readable summaries.
🔎 Built around classic static embeddings (e.g., GloVe, word2vec). Great for quick semantic experiments inside ComfyUI.
custom_nodes/ directory, for example:“`bash
ComfyUI/custom_nodes/ComfyUI-WordEmbeddings
“`
“`bash
pip install gensim numpy
“`
The pretrained loader uses
gensim.downloader. On first use it will download the selected model into your localgensim-datacache.
.kv / word2vec .bin / .txt file).we_model output into any of the analysis nodes below (Neighbors / Equation / Axis / Axis2D / Axis3D / Centrality).model_name (dropdown of gensim.downloader models; default glove-wiki-gigaword-50)WE_MODELpath (string to local embedding file)format (auto|kv|word2vec_bin|word2vec_text)label (string prefix for display)WE_MODELwe_model, word, kwords_csv, debug_csvwe_model, word_a, word_b, stops, topn, method (slerp|lerp)words_csv, debug_txtwe_model, expression (e.g., king - man + woman), k, topn_pool, normalize_terms, allow_inputswords_csv, debug_txtwe_model, word, kwords_csv, cosines_csvAxes are written
left|right. Each side may contain comma‑separated synonyms to define a pole mean. Example:
–
man,boy,he,him,his,father,brother,husband | woman,girl,she,her,hers,mother,sister,wife
Inputs also accept phrases when
token_can_be_phrase=true(we average the unit vectors of the words).
we_model, token, axis, token_can_be_phrase, lowercase, neutral_epsx *(FLOAT in [-1,1]; + means toward left pole)*cos_left *(FLOAT)*cos_right *(FLOAT)*summary *(STRING)*x is the projection of the token onto the axis direction.cos_left/right are cosine similarities to each pole mean (how much the token “resonates” with each pole independently).summary blends polarity (from x) and confidence (from cos_*) into a plain‑English sentence.we_model, token, axis1, axis2, token_can_be_phrase, lowercase, neutral_epsx, y *(FLOATs)*summary *(STRING)*x_cos_left, x_cos_right, y_cos_left, y_cos_right *(FLOATs)*we_model, token, axis1, axis2, axis3, token_can_be_phrase, lowercase, neutral_epsx, y, z *(FLOATs)*summary *(STRING)*x_cos_left, x_cos_right, y_cos_left, y_cos_right, z_cos_left, z_cos_right *(FLOATs)*The 2D/3D nodes can ignore weak axes in their summaries (thresholded by
neutral_eps) so the text focuses on strong signals.
we_model, wordcentrality *(FLOAT in [-1,1])*norm *(FLOAT)*summary *(STRING)*norm is the raw vector length (some embeddings store frequency-ish info in norms; take with caution).man,boy,he,him,his,father,brother,husband | woman,girl,she,her,hers,mother,sister,wife
hot,warm,heat,boiling | cold,cool,freezing,ice
royal,king,queen,prince,noble | common,commoner,peasant,ordinary
formal,proper,polite | casual,slang,informal
Feel free to tailor axes to your domain—adding 3–10 good synonyms per side usually stabilizes results.
cos_*): how strongly the token points toward a pole. Range [-1, 1].~0.7+ → strong affinity; ~0.3–0.6 → moderate; <0.2 → weak.x, y, z): signed position along the axis. Positive = more left, negative = more right.|x| < neutral_eps (default 0.08), we call it about equal in the summary.glove-6B-300, word2vec-google-news-300) will give different absolute values and neighbors.norm (in Centrality) isn’t universally meaningful across models; use it comparatively within the same model only.gensim + numpy).a = unit(left_mean - right_mean) (or single‑sided fallback).x = token_unit · a and per‑pole cos_left/right = token_unit · pole_mean.x) + confidence (cos_*) with thresholds.