Nodes/ComfyCollectorNodes/Token Remap (CCN)
ComfyUI Node

Token Remap (CCN)

Nudge 'ship' toward 'starship' in embedding space

By valkymaera·Created 4 months ago·Updated 10 days ago· 1
Token Remap (CCN)
  • clip
  • conditioning
  • text_out
text
remappings# source -> target # ship -> starship # craft -> spacecraft
blend1.00

Sometimes the problem isn't that a word is missing from your prompt - it's that the word you have is ambiguous, and the model keeps drawing the wrong flavor of it. "Ship" could be a boat, a spaceship, or a shipping container, and plain text can't tell CLIP which one you mean. Token Remap (CCN) is the pack's answer to that: it swaps the embedding of one word toward another, so "ship" gets blended partway toward "starship" without you rewriting the whole prompt. This is the pack's own signature move, the tinker-y bit the author is most proud of.

The appeal is subtle and worth sitting with. A string replace changes the text, which changes everything downstream. Token Remap leaves your prompt text untouched and instead remaps at the token level - you land between "ship" and "starship" rather than committing to either. The node description says it plainly: "Remap words like 'ship' to 'starship' at the embedding level with controllable blending."

How it works

You write remapping pairs in the remappings field, one per line:

# source -> target
# ship -> starship
# craft -> spacecraft

Lines starting with # are comments. The format accepts ->, =>, :, or a comma as the separator - the author's forgiving about syntax because the string's already cramped. The prompt is encoded twice: once as written, once with the word replacements applied. Then the two conditionings are blended, and here's the clever bit - the blend only happens at the positions that changed, when the token counts line up. If the remapped prompt has a different token count, it falls back to blending the whole conditioning tensors (a global lerp). Either way you don't re-encode every position, which is why this stays fast enough to use in a real workflow.

blend controls the strength: 1.0 is fully remapped, 0.0 is the original prompt, and values beyond 0–1 extrapolate - the tooltip notes you can push past the endpoints "in embedding space." A blend of 0.5 gives you half-ship, half-starship, which is occasionally exactly the weird middle you didn't know you wanted.

The inputs and outputs that matter

  • clip - the CLIP model, same one you'd feed a CLIP Text Encode.
  • text - your prompt.
  • remappings - the source→target pairs, one per line.
  • blend - float, default 1.0. 0 = original, 1 = fully remapped.

Outputs: conditioning - wire this into your sampler where you'd normally put the CLIP Text Encode output - and text_out (the remapped text), if you want to see or reuse the literal replacement.

How to install it

Part of ComfyCollectorNodes: ComfyUI Manager → search ComfyCollectorNodes → Install, or:

cd ComfyUI/custom_nodes
git clone https://github.com/valkymaera/ComfyCollectorNodes.git

Restart ComfyUI. No extra dependencies.

Common issues

This is a CLIP-space tool, and the author is upfront that it's model-dependent. It matches whole words only, and "some models or CLIP formats may be resilient to it" - the README's own caveat. On modern LLM-encoded models, where the encoder is a chat-style instruction reader rather than a token bag, embedding-space remapping has much less to grab onto (that's the CLIP-versus-LLM divide from prompt-engineering.md). If you're on Flux or a newer LLM-encoder model and this does nothing, it's not broken - it's the wrong tool for that encoder.

Also, if a source word doesn't appear in your prompt at all, or the token counts shift after remapping, you get the global-lerp fallback rather than precise per-position blending. Works, just less surgical. If you need something like this that also remaps concepts that aren't in the prompt, the same pack's Concept Remap is the bigger sibling - this one is the focused, per-word version.

CategoryCCN/conditioning

Inputs (4)

NameTypeDefaultDescription
clipCLIP
textSTRING
remappingsSTRING# source -> target # ship -> starship # craft -> spacecraft
blendFLOAT1.00-100–1000.0 = original prompt, 1.0 = fully remapped. Values beyond 0-1 extrapolate in embedding space.

Outputs (2)

NameTypeDescription
conditioningCONDITIONING
text_outSTRING