Nodes/ComfyUI_Lam/多文本CLIP批量编码
ComfyUI Node

多文本CLIP批量编码

Batch-encode a list of prompts into one conditioning

By yanlang0123·Created 2 years ago·Updated 10 days ago· 77
多文本CLIP批量编码
  • clip
  • textList
  • CONDITIONING
pre_text
app_text

MultiTextEncode ("多文本CLIP批量编码", batch CLIP-encode multiple texts) takes a list of prompts and a CLIP model and returns a single conditioning tensor that encodes all of them at once. That's the batch trick core ComfyUI doesn't give you: normally one text input → one conditioning. Here, one list → one conditioning, and the sampler generates for all of them in a single pass.

This is the natural partner for LongTextToList. Split a pile of prompts into a list, hand the list here, and you've turned a fifty-line text file into fifty variations out of one queue. It's the same trick that makes batch prompt grids work in ComfyUI - you keep the encoding on the graph instead of re-running the sampler fifty times from a browser loop.

How it works

For each text in the list it runs a normal CLIP encode - tokenize, encode, pooled output - then concatenates all the conditionings and all the pooled outputs along the batch dimension. The result is one conditioning with a batch dimension equal to your list length, so the KSampler generates that many images per run.

Two optional inputs shape every prompt uniformly:

  • pre_text - a prefix prepended to every item. Great for "masterpiece, best quality," or a shared style anchor.
  • app_text - a suffix appended to every item. Good for a common negative-ish qualifier, or a fixed camera/lighting tail.

They're concatenated with spaces around the middle, so pre_text + " " + text[i] + " " + app_text. If your list is empty it throws rather than silently doing nothing.

The inputs and outputs

  • clip - the CLIP from your checkpoint loader.
  • textList - a LIST of prompts, one per image you want.
  • pre_text, app_text - optional prefixes/suffixes applied to all items.
  • Output: CONDITIONING - the batched conditioning, wired into the positive (or negative) input of a sampler.

Installing it

From the ComfyUI_Lam pack. ComfyUI Manager → search "ComfyUI_Lam", or:

cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam

Restart, and it's in the lam category. It needs a CLIP from your checkpoint - no extra model downloads and no pack-specific files. Ignore the README's heavy setup for this one; the face-fusion rars and TensorFlow pins have nothing to do with encoding text.

Common issues

Watch your VRAM: batch-encoding a long list means a big batch dimension at sampling time, which can blow up memory fast. If a run that should produce five images dies with an OOM, reduce the list size or lower resolution - the node itself is light, the sampler that follows it isn't.

Also note this is a "put it all in one conditioning" batch, not a loop. Every item gets the same seed unless you vary it downstream, so identical-looking outputs are you, not the node. If you want per-item seeds you're back to a loop or a seed-list approach.

Pack-level reality check: ComfyUI_Lam is a Chinese-origin pack with a near-zero community footprint, and its README's full install will happily try to pin numpy 1.23.4 into your environment - skip that for a node like this. And if you uninstall the pack and a leftover Chinese popup appears at launch, delete ComfyUI/web/extensions/lam to clear the pack's frontend extension.

Categorylam

Inputs (4)

NameTypeDefaultDescription
clipCLIP
textListLIST
pre_textoptSTRING
app_textoptSTRING

Outputs (1)

NameTypeDescription
CONDITIONINGCONDITIONING