ComfyUI Extension: kinamix-embeddings-comfyui

Authored by latentwill

Created

Updated

0 stars

Run ComfyUI workflows without the setup

No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.

ComfyUI nodes for Kinamix concept embeddings

README

Kinamix Embeddings — ComfyUI

ComfyUI custom nodes for applying Kinamix concept embeddings — small, text-encoder-side concept tokens trained with the kinamix-embeddings-qwen training repo. Designed for Qwen-Image / MMDiT-style models, where the text encoder produces a long token stream and the diffusion transformer attends over it directly.

A concept embedding is a small block of learned tokens (e.g. 8 × 3584) that, when appended to the text conditioning, steers the model toward a visual concept without retraining the model itself. These nodes give you several ways to apply that block — single, multi, biased, or via DFG.

Installation

cd ComfyUI/custom_nodes
git clone https://github.com/latentwill/kinamix-embeddings-comfyui.git

Place trained .safetensors embeddings in ComfyUI/models/embeddings/. Restart ComfyUI.

Training your own embeddings

Embeddings consumed by these nodes are produced by latentwill/kinamix-embeddings-qwen. That repo handles dataset prep, the training loop, and exports the .safetensors files this plugin loads. The embedding tensor shape must match the text encoder dim of the model you're sampling with (e.g. 3584 for Qwen-Image's Qwen2.5-VL encoder).

Nodes

All nodes live under the Kinamix/Embeddings category.

Load Kinamix Embedding (KinamixLoadEmbedding)

Loads a .safetensors / .pt file from models/embeddings/ into a KINAMIX_EMBEDDING object holding the concept tokens plus encoder metadata. Has an optional embedding_file_override string input for driving selection from upstream nodes.

Outputs: embedding

Apply Embedding Qwen (KinamixApplyEmbeddingQwen)

The default single-embedding application path. Appends the concept tokens to the conditioning stream and uses noise corruption for smooth strength control: as strength decreases, the concept tokens are progressively replaced with magnitude-matched random noise, so the model sees a clean fade rather than a sharp cliff. Recommended starting point.

Inputs: conditioning, embedding, strength (0–1, default 0.75), seed, curve (optional, default 1.25 — controls how aggressively strength rolls off; higher = sharper falloff).

Outputs: conditioning

Strength guide: 0 = no concept · 0.5 = sweet spot · 0.75 = strong · 1.0 = full.

Differential Feature Guidance — DFG (KinamixDFG)

Decomposes concept influence from text guidance. Computes the concept direction in conditioning space and applies it at an independent scale:

output = text_only + strength * (text + concept − text_only)

This gives you two independent knobs: strength controls only concept influence, while KSampler's cfg continues to control text guidance as normal. Useful when CFG sweeps are blowing out the concept or vice versa.

Inputs: conditioning, embedding, strength (0.0–5.0, default 0.03), optional negative_conditioning.

Outputs: positive, negative — wire both into KSampler.

Strength guide: 0 = no concept · 0.01 = subtle · 0.05 = moderate · 1.0 = full · >1.0 = extrapolated/amplified.

Concept Bias (KinamixConceptBias)

Proximity-based directional bias. For each text token in the prompt, finds its nearest concept token (cosine similarity) and rotates the text token direction toward that concept. Magnitudes are preserved — no token is amplified, only re-aimed. Distant tokens are left alone.

Helpful as a pre-processor before Apply Embedding to improve concept adherence on long prompts where the concept tokens otherwise get drowned out by hundreds of text tokens.

Accepts up to 4 embeddings; concept tokens are pooled across all of them and each text token picks its single nearest neighbor (no compounding from multiple embeddings).

Inputs: conditioning, embedding, bias_strength (0–1, default 0.3), optional embedding_2..4.

Outputs: conditioning

Multi Embedding Qwen (KinamixMultiEmbeddingQwen)

Loads and blends up to 4 embeddings in a single node. Implements true token-space blending: each embedding's concept tokens are multiplied by its strength, summed into a single concept block, and then noise corruption is applied once to the combined block. This matters because softmax attention is direction-dominated — naively concatenating per-embedding scaled chunks barely blends; weighted summation gives the relative strengths actual semantic weight, and a single noise pass lets the noise floor cleanly suppress weak contributors instead of letting every embedding leak through.

All embeddings must share the same concept token count.

Inputs: conditioning, embedding_1 + strength_1 (required), embedding_2..4 + strength_2..4 (optional), seed, curve, optional negative_conditioning.

Outputs: positive, negative — wire both into KSampler. The negative path zero-pads the concept slots so KSampler's cfg directly amplifies the concept direction.

Workflows

Examples are in workflows/:

| File | What it shows | | --- | --- | | apply_embedding_qwen.json | Minimal single-embedding path: Load → Apply Embedding Qwen → KSampler. The recommended starting point. | | concept_tinting.json | Concept Bias as a pre-processor in front of Apply Embedding, for long prompts that need stronger concept adherence. | | multi_embedding.json | Multi Embedding Qwen blending several concepts at once with independent strengths. |

Drag any of these JSON files onto the ComfyUI canvas to load.

Choosing a node

  • One concept, normal usageApply Embedding Qwen.
  • Long/complex prompt fighting the conceptConcept BiasApply Embedding Qwen.
  • CFG and concept strength are coupled in unhelpful waysDFG.
  • Multiple concepts at onceMulti Embedding Qwen.

Compatibility

  • Built for Qwen-Image and other MMDiT-style models that consume the full text encoder token stream.
  • The embedding's hidden dim must match the model's text encoder dim (the nodes will raise a clear error otherwise).

Related

Run ComfyUI workflows without the setup

No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.

Learn more