Nodes/ComfyUI-Apt_Preset/sum_TextEncode
ComfyUI Node

sum_TextEncode

Sum_TextEncode

By cardenluo·Created 2 years ago·Updated 22 days ago· 309
sum_TextEncode
  • context
  • context
  • positive
  • negative
pos
neg
modenormal
main_prompt_ratio0.50

Here's a problem nobody warns you about when you move from SDXL to the modern DiT family: prompt weighting is dead. (keyword:1.3), [keyword:0.6], all of it - on Flux 2, Z-Image, and the other LLM-encoded models, those brackets aren't parsed, they're fed to the encoder as literal punctuation. The KB's own verdict: "not weakened, discarded." That's where sum_TextEncode comes in. It's the pack's conditioning encoder that knows which model family it's talking to, and for the modern ones it re-implements weighting the way those models actually understand it.

The pack's syntax is [语义@权重] - semantic weight brackets. [女孩打伞,瀑布@0.2] weakens that concept to 20%; [3d风格@0.2] as the opening token strengthens the 3D style and everything after it keeps its default weight. No parenthetical soup, no CLIP-attention hack that modern encoders ignore.

What it actually does

Takes the context's clip and your pos/neg text, then branches on mode:

  • normal - plain CLIPTextEncode, no special handling.
  • flux2.klein - runs the prompt through the pack's pre_Unit_PromptWeight processor, which parses the [语义@权重] syntax and turns it into conditioning the Flux 2 Klein encoder understands, with main_prompt_ratio deciding how much the overall prompt dominates.
  • z-image / qwen-image / ernie-image-turbo - the same weight-processing idea against each model family's own encoder quirks.

Because these models don't use a real negative prompt at the classic CFG level, sum_TextEncode sets a zeroed negative when none is given - a reminder that "negative prompt" is largely a myth on this architecture class unless the model was trained for it.

The inputs that matter

  • context - required; it supplies the clip and prior conditioning.
  • pos / neg - the prompts. pos is multiline, neg is not.
  • mode - the model family selector: normal, flux2.klein, z-image, qwen-image, ernie-image-turbo. Getting this wrong silently picks the wrong processor, so match it to whatever sum_load_simple loaded.
  • main_prompt_ratio - 0 to 1, default 0.5. The higher it is, the more the semantics skew toward the overall prompt rather than the bracketed items. Lower it to let weighted features shine through.

The outputs that matter

context, positive, negative - plus, because this is an output node, it prints prompt_info (what it encoded, which mode, the first ~20 chars) to the UI so you can sanity-check your weighting actually applied.

Wiring it in

sum_load_simplesum_TextEncode → stack → sum_Ksampler. It replaces the prompt stage; the stacks can also take a raw prompt field, but this is the node that gives you per-model weighting.

Installing it

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset.git
cd ComfyUI-Apt_Preset
pip install -r requirements.txt   # Windows: double-click install.bat

Or ComfyUI Manager → ComfyUI-Apt_Preset.

Common issues

People port old prompts verbatim and expect the bracket syntax to be optional sugar - it isn't. (girl:1.3) stays literal garbage on Klein; you have to convert to [[email protected]] or just write it in words. And the main_prompt_ratio default of 0.5 is a real choice, not a safety value: if you're stacking lots of [feature@strength] items and the image keeps ignoring your main subject, crank the ratio up; if your main prompt is bulldozing your weighted accents, drop it. Finally, neg is single-line here - a paste-heavy workflow that drops a multi-line negative in will just truncate.

CategoryApt_Preset/chx_tool

Inputs (5)

NameTypeDefaultDescription
contextRUN_CONTEXT
posoptSTRING
negoptSTRING
modeoptCOMBOnormal5 options: normal, flux2.klein, z-image, qwen-image, ernie-image-turbo
main_prompt_ratiooptFLOAT0.500–1

Outputs (3)

NameTypeDescription
contextRUN_CONTEXT
positiveCONDITIONING
negativeCONDITIONING