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

CWB Merge Embeddings (3 Models)

Merge three embeddings into one vector file

By silveroxides·Created about a year ago·Updated about 24 hours ago· 14
CWB Merge Embeddings (3 Models)
  • cwb_config
  • output_filename
  • documentation
  • cwb_report
execution_mode
model_a
model_b
model_c
cwb_presetbalanced_idx_mean
mismatch_modeskip
output_filenamecwb_merged_3_embedding
save_dtype
process_device
exclude_patterns
discard_patterns
glob_patternsfalse
lazy_loadtrue
force_clear_cachetrue
override_dtypefalse

The three-input version of the CWB embedding merger - the answer to "can I combine three textual-inversion vectors into one file?" Yes, and with per-token consensus weighting rather than a blind average. It's the most niche merger in the pack, but for anyone who collects multiple embeddings of the same concept it's genuinely handy.

How it works

Model A is the anchor (metadata, preservation reference). Models B and C are equal-prior contributors. For each token vector, CWB computes a consensus - with three contributors the median becomes a robust center that a single outlier embedding can't drag - measures each embedding's similarity to it, and weights contributions by that similarity. Embeddings use the longest compatible first dimension as their alignment reference, and the default preset (balanced_idx_mean) aligns by index; if you believe the token order differs between files, the similarity-alignment presets (balanced_sim_mean, robust_sim_medn) pair tokens by cosine instead.

Output is written to models/embeddings and used like any embedding - reference embedding:filename in a prompt or wire it through an embedding-aware text encoder. mismatch_mode handles missing or incompatible tokens: skip preserves the anchor, zeros inserts zero contributions, error aborts.

Inputs that matter

  • execution_mode - MERGE writes the file; DOCUMENTATION ONLY returns the CWB reference and opens nothing.
  • model_a / model_b / model_c - your three embeddings. A anchors metadata.
  • cwb_preset (default balanced_idx_mean) - the embedding registry; _medn variants use median consensus, _sim variants use similarity alignment.
  • output_filename (default cwb_merged_3_embedding) - written to models/embeddings.
  • save_dtype / override_dtype - dtype for generated tensors.
  • exclude_patterns / discard_patterns / glob_patterns - regex (or glob) lists.
  • lazy_load, force_clear_cache, process_device - the usual UEL streaming, flushing, and device controls.

Outputs

output_filename (the written file), documentation (the CWB reference), and cwb_report (per-token merge detail).

Why you'd reach for it

Consolidating three partial embeddings of the same concept - each trained on a different slice of examples - into one vector is the realistic case. The output is small and the merge is fast, so it's low-risk to try: merge, prompt with embedding:, and judge by eye. If you want to preview token similarity first, EmbeddingModelAnalysis from the same pack has the alignment tooling.

Install

Part of Model Utility Toolkit (silveroxides/ComfyUI-ModelUtils). ComfyUI Manager → search "Model Utility Toolkit", or:

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

Restart ComfyUI. Real dependency: unifiedefficientloader (UEL). Keep ComfyUI current - newer extension API, experimental CWB nodes.

CategoryModelUtils/Merging

Inputs (16)

NameTypeDefaultDescription
execution_modeCOMBOMERGE writes a new safetensors file. DOCUMENTATION ONLY returns the CWB reference without loading or merging inputs.
model_aCOMBOPrimary contributor and preservation anchor. Supplies output metadata and anchors shared tensor names and shapes.
model_bCOMBOSecond equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity.
model_cCOMBOThird equal-prior contributor. CWB derives its effective per-vector influence from consensus similarity.
cwb_presetCOMBObalanced_idx_meanUse-case preset. Name suffixes expose alignment, consensus, norm rescaling, DSC, soft comfort bandpass, and prefix preservation. A connected CWB Config overrides it completely.
mismatch_modeCOMBOskipFor missing or incompatible anchored inputs: skip preserves the anchor, zeros inserts a zero contribution where possible, and error aborts. A lone secondary-only tensor is copied unchanged.
output_filenameSTRINGcwb_merged_3_embeddingFilename without extension. The result is atomically written to this model category under ComfyUI's models directory.
save_dtypeCOMBORequested dtype for generated floating tensors. Participating FP32 inputs keep a result FP32 unless Override Dtype is enabled.
process_deviceCOMBODevice used for per-layer FP32 CWB arithmetic. A CUDA out-of-memory error retries only the affected layer on CPU.
exclude_patternsSTRINGOne pattern per line. Matching layers are preserved from the anchor instead of merged. Uses regex unless Glob Patterns is enabled.
discard_patternsSTRINGOne pattern per line. Matching tensors or logical LoRA groups are omitted from the output. Uses regex unless Glob Patterns is enabled.
glob_patternsBOOLEANfalseInterpret exclude and discard entries as shell-style glob patterns instead of regular expressions.
lazy_loadBOOLEANtrueUse UEL low-memory loading so tensors are read and released per work unit instead of retaining the complete inputs in RAM.
force_clear_cacheBOOLEANtrueRun Python garbage collection and clear the CUDA allocator cache before each layer. Reduces retained memory but can substantially slow merging.
override_dtypeBOOLEANfalseForce generated tensors to save_dtype; guarded tensors and enabled 1D direct diffs are exempt.
cwb_configoptCWB_CONFIGOptional settings from CWB Custom Configuration. When connected, it completely overrides the selected preset.

Outputs (3)

NameTypeDescription
output_filename*
documentationSTRING
cwb_reportSTRING