Nodes/Model Utility Toolkit/Merge Embeddings (3 Models)
ComfyUI Node

Merge Embeddings (3 Models)

Merge Embeddings (3 Models) — blend three textual inversions into one

By silveroxides·Created 2 years ago·Updated 3 days ago· 17
Merge Embeddings (3 Models)
  • layer_parameters
  • output_filename
  • documentation
◄execution_mode▾►
◄model_a▾►
◄model_b▾►
◄model_c▾►
◄calc_mode▾►
◄mismatch_modeskip►
◄alignment_modepad/crop►
◄alpha0.50►
◄beta0.50►
◄gamma0.50►
◄delta2.00►
◄epsilon0.01►
◄zeta0.00►
◄seed0►
◄output_filenamemerged_3_embedding►
◄save_dtype▾►
◄process_device▾►
◄exclude_patterns►
◄discard_patterns►
◄glob_patternsfalse►
◄lazy_loadtrue►
◄force_clear_cachefalse►
◄override_dtypefalse►
◄include_modefalse►

This is one of the more niche nodes in the whole pack, and it's worth saying that up front rather than pretending otherwise. Embeddings are already a shrinking part of the ecosystem - locked to whichever text encoder they were trained against, mostly abandoned by every architecture since SD 2.0's CLIP swap, with the surviving new uploads almost entirely SDXL/Illustrious pose and character files rather than anything general-purpose. Merging three of them together is a genuinely specialist move on top of an already-niche technique: think averaging a few seed variants of the same trained concept, or blending three related style embeddings into one you can load with a single trigger word instead of three.

That said, if you're the kind of person who trains or collects a lot of embeddings for one base architecture, this is a real tool doing real work, not filler. It's part of ComfyUI-ModelUtils' Merging category, and it's the same SVD/blend machinery the pack uses elsewhere (LoRA extraction, checkpoint merging) applied to the smallest file type in the ecosystem.

Inputs that matter. model_a, model_b, and model_c are the three embeddings you're merging - dropdowns of your local embeddings folder. alpha, beta, and gamma (each default 0.5, range −10 to 10) read as the per-model blend weights for A, B, and C respectively, one Greek letter per input. execution_mode and calc_mode are mode selectors the schema doesn't document further - treat them as "pick a value, see what changes" rather than something with an obvious right answer from the field name alone. mismatch_mode (default "skip") governs what happens when the three embeddings don't line up cleanly - different shapes or missing keys between them - and alignment_mode (default "pad/crop") decides how it reconciles vectors of different lengths, by padding the shorter one or cropping the longer one.

There are three more numeric knobs - delta (default 2), epsilon (default 0.01), zeta (default 0) - that feed whatever formula calc_mode is running. The README doesn't spell out the math behind them, so the honest advice is to leave them at default until you have a reason not to, then sweep them by eye rather than by intuition.

The rest is plumbing shared with the pack's other merge and extraction nodes: seed for anything with a stochastic component, save_dtype and process_device for output precision and where the work runs, exclude_patterns/discard_patterns (regex by default, or glob syntax if you flip glob_patterns to true) for keeping specific tensor keys out of the merge, lazy_load (on by default) to stream tensors from disk instead of loading everything into memory at once, force_clear_cache (on by default) to free CUDA memory after each layer, and override_dtype (off by default) to force the whole output to save_dtype instead of preserving whatever higher precision the inputs carried.

Outputs. output_filename (STRING) tells you where the merged embedding landed; output_filename for the node input sets what it's called, defaulting to merged_3_embedding. documentation (STRING) is a second output that appears to return a human-readable summary of what the merge actually did - worth piping into a text-preview node, since with this many undocumented knobs, a plain-language readout of what ran is more useful here than on almost any other node in the pack.

Installing it. ComfyUI Manager, search "Model Utility Toolkit," or:

cd ComfyUI/custom_nodes
git clone https://github.com/silveroxides/ComfyUI-ModelUtils

Restart ComfyUI afterward.

Troubleshooting. Given how many parameters here are genuinely undocumented, the most useful troubleshooting step is also the simplest: read the documentation output before you assume anything went wrong. Beyond that, remember embeddings are text-encoder-locked - merging three SDXL-era embeddings gives you a usable SDXL-era embedding, but it won't magically produce something that works on a model with an entirely different text encoder, no matter how the merge math shakes out.

CategoryModelUtils/Merging

Inputs (25)

NameTypeDefaultDescription
execution_modeCOMBOMERGE writes the selected result; DOCUMENTATION ONLY returns the operation reference without loading model files.
model_aCOMBOPrimary embedding; anchors metadata, tensor shapes, and values preserved by exclusions or skip handling.
model_bCOMBOSecond embedding contributing to the selected calculation mode.
model_cCOMBOThird embedding contributing to the selected three-model calculation mode.
calc_modeCOMBOThree-model operation to apply per comparable tensor; DOCUMENTATION ONLY shows its formula and coefficient meanings.
mismatch_modeCOMBOskipHandle missing or incompatible tensors: preserve Model A, substitute zeros where supported, or abort with an error.
alignment_modeCOMBOpad/cropResolve compatible shape differences by zero-padding/cropping or by interpolating Model B and Model C to Model A shape.
alphaFLOAT0.50-10–10Mode-specific coefficient; use DOCUMENTATION ONLY for its exact role in the selected calculation mode.
betaFLOAT0.50-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
gammaFLOAT0.50-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
deltaFLOAT2.00-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
epsilonFLOAT0.01-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
zetaFLOAT0.00-10–10Mode-specific coefficient; some calculation modes ignore it. See DOCUMENTATION ONLY for the selected formula.
seedINT00–18446744073709550000Random seed used only by calculation modes with stochastic behavior.
output_filenameSTRINGmerged_3_embeddingOutput filename without extension, written under the matching ComfyUI model directory.
save_dtypeCOMBOOutput tensor dtype; when Override Dtype is disabled, source tensors with higher precision remain at that precision.
process_deviceCOMBODevice used for per-tensor merge arithmetic; CUDA out-of-memory retries the affected tensor on CPU.
exclude_patternsSTRINGNewline-separated regex or glob patterns for tensors excluded from merging and preserved from Model A.
discard_patternsSTRINGNewline-separated regex or glob patterns for tensors omitted entirely from the output.
glob_patternsBOOLEANfalseWhen True, exclude/discard patterns use glob syntax (* = any sequence, dots are literal). When False (default), patterns are Python regex matched as substrings.
lazy_loadBOOLEANtrueLow memory mode: load tensors from disk on demand
force_clear_cacheBOOLEANfalseClear CUDA cache after each layer
override_dtypeBOOLEANfalseForce the entire model to be saved as the selected save_dtype. If False (default), higher precision dtypes are preserved.
include_modeBOOLEANfalseUse Exclude Patterns as a whitelist instead. Only matching tensors are merged; nonmatching tensors are preserved from Model A.
layer_parametersoptMODELUTILS_LAYER_PARAMETERSOptional Layer Parameter Configuration. a=alpha; b=beta; c/g=gamma; d=delta; e=epsilon; f/z=zeta. Only coefficients used by Calc Mode are accepted. Full names are also accepted. Unassigned values use this node's settings; existing filters still apply.

Outputs (2)

NameTypeDescription
output_filename*—
documentationSTRING—