Nodes/ComfyUI-HF-Diffusers/HF Transformers run pipeline
ComfyUI Node

HF Transformers run pipeline

Prompt enhancement's missing middle

By Yahweasel·Created 8 months ago·Updated 7 months ago· 2
HF Transformers run pipeline
  • pipeline
  • input
  • raw_result
  • conversation
seed1
kwargs

The execution node for the pack's Transformers side. You hand it the HFT_PIPELINE from HFTLoadPipeline, optionally an input, and it calls the pipeline - running the LLM or VLM and returning what it produced. In the prompt-enhancer workflow this is the node in the middle: conversation goes in, enriched text comes out, your text-to-image model gets a better prompt than you could write.

Inputs are almost comically minimal:

  • pipeline - the HFT_PIPELINE to run.
  • input (optional) - typed as *, meaning anything. For text generation pipelines you feed it an HFT_CONVERSATION (from HFTCreateConversation or chained). For other task types you can feed whatever the task expects - the * type is the author's way of not boxing you in.
  • seed - for reproducible generation.
  • kwargs - JSON, the usual escape hatch (sampling temperature, max tokens, and so on go here).

Two outputs, and this is where the design shows:

  • raw_result (HFT_RESULT) - whatever the pipeline returned, untouched.
  • conversation (HFT_CONVERSATION) - the generated conversation, extracted automatically if the result is a chat-style output carrying generated_text.

Why the two outputs matter

The pack's flow is: create a conversation → run it through this node → the generated conversation comes back on the second output → feed that into HFTUnpackConversation to pull the assistant's reply out as plain text. If you've ever written a Transformers chat script, you know the result of a text-generation pipeline is a nested structure of message dicts; this node's job is to hand you the conversation-shaped part without you having to dig. The raw_result is there for the cases where you want the full untouched output instead.

Note the extraction is conditional - if the pipeline returns something that isn't a chat-style list with generated_text, the conversation output stays None and you're on your own with raw_result. That's the honest behavior of a generic node that can't know every task's output shape.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/Yahweasel/ComfyUI-HF-Diffusers

or install ComfyUI-HF-Diffusers via ComfyUI Manager, then restart. requirements.txt pins diffusers~=0.36.0.

Gotchas

  • The conversation output isn't text. Beginners wire conversation into a text input and hit a dead end. You need HFTUnpackConversation to extract the string - that's not an extra step, it's the intended pipeline.
  • Seed on an LLM is softer than on a sampler. It seeds torch's generator, so runs are reproducible given identical hardware and versions, but upgrade transformers and the same seed can drift.
  • First run downloads the model. The 7B-ish defaults pull several gigabytes into the HF cache. Plan for it; the node isn't broken, it's downloading.
Categoryhuggingface-transformers

Inputs (4)

NameTypeDefaultDescription
pipelineHFT_PIPELINE
seedINT10–18446744073709550000
kwargsSTRING
inputopt*

Outputs (2)

NameTypeDescription
raw_resultHFT_RESULT
conversationHFT_CONVERSATION