Nodes/ComfyUI_EmbeddingToolkit/Slice Existing Embedding File
ComfyUI Node

Slice Existing Embedding File

Strip the BOS/EOS padding off an embedding file you already have

By silveroxides·Created about a year ago·Updated 4 months ago· 11
Slice Existing Embedding File
      embedding_file
      output_filename_prefixsliced_embedding

      Somewhere in your embeddings folder there's a file with a few extra tokens glued to the front and back of the vectors that actually matter. This node strips them off and saves a clean copy. That's the whole job, and it's a surprisingly handy one.

      Here's the situation it solves. Text embeddings - whether you made them with this pack's Save Token Embeddings node, downloaded them from CivitAI, or pulled a .pt out of an old A1111 folder - frequently have the text encoder's BOS (beginning-of-sequence) and EOS (end-of-sequence) markers baked into the stored vector sequence. When such a file is used as embedding:name in a prompt, those baked-in markers can fight the prompt: the embedding doesn't blend, it pushes attention around, or it just feels "stuck" at the start of the prompt. Slicing them off gives you a leaner sequence that slots into a prompt more like an ordinary token.

      How it works

      Pick a file from the dropdown (it scans your ComfyUI/models/embeddings folder for .safetensors and .pt files). The node loads it and applies a per-key rule:

      • clip_l / clip_g tensors → drop the first and last vectors (BOS and EOS)
      • t5* / umt5* / pile* tensors → drop the last vector (EOS only)
      • anything else → left untouched

      It writes the sliced result to a new file in the embeddings folder, keeping the original extension and auto-incrementing the name so you never clobber the source. Multi-part files (a clip_l + clip_g SDXL embedding, say) get each component sliced per its own rule. If no tensor matches a slicing rule, it refuses to write rather than silently producing a copy - you'll see "No changes made" in the log, which is the correct behavior.

      The inputs

      Two, and the first is the whole point:

      • embedding_file - a dropdown of everything in your embeddings folder. It's populated when the node loads, so if a file isn't listed, refresh the workflow.
      • output_filename_prefix (default sliced_embedding) - output saves as sliced_embedding_00001.safetensors (or .pt if the source was .pt), auto-incremented.

      There are no output ports; like the save nodes in this pack, it's a dead-end that does its work and reports the path in the UI log.

      When you'd actually reach for it

      Three cases, in order of how often I've seen them:

      1. You saved with this pack's save nodes and left slice_bos_eos off, and now the embedding won't blend into prompts. Slice the file.
      2. You downloaded an A1111-era embedding that carries BOS/EOS and behaves differently than a clean ComfyUI embedding.
      3. You want to strip padding before sharing the file, so whoever uses it gets the same behavior you do.

      Honestly, if your embedding works fine as-is, don't bother. This is a fix-it-when-it-fights-you tool, not a step in every workflow.

      Installing the pack

      Part of silveroxides/ComfyUI_EmbeddingToolkit - a small personal pack with no dependencies and no model downloads. Install via ComfyUI Manager (search "ComfyUI_EmbeddingToolkit") or:

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

      Then restart ComfyUI.

      One gotcha

      Remember the encoder lock that applies to all embeddings: slicing changes the shape of the vectors, not their meaning. A sliced SDXL-CLIP file still won't work on a Qwen3 or Mistral model, and ComfyUI won't warn you when it silently ignores it. Slice to make a compatible file cleaner - don't slice hoping to make an incompatible one work.

      CategoryEmbeddingToolkit/Utils

      Inputs (2)

      NameTypeDefaultDescription
      embedding_fileCOMBO1 options: None
      output_filename_prefixSTRINGsliced_embedding

      Outputs (0)

      No outputs