HF Transformers run pipeline
Prompt enhancement's missing middle
- pipeline
- input
- raw_result
- conversation
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_PIPELINEto run. - input (optional) - typed as
*, meaning anything. For text generation pipelines you feed it anHFT_CONVERSATION(fromHFTCreateConversationor 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 carryinggenerated_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
conversationinto a text input and hit a dead end. You needHFTUnpackConversationto 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.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| pipeline | HFT_PIPELINE | — | |
| seed | INT | 10–18446744073709550000 | — |
| kwargs | STRING | — | |
| inputopt | * | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| raw_result | HFT_RESULT | — |
| conversation | HFT_CONVERSATION | — |