ComfyUI Node

Run Phi

The node that turns ComfyUI into a local chatbot

By alexisrolland·Created 2 years ago·Updated 11 months ago· 9
Run Phi
  • phi_model
  • phi_tokenizer
  • STRING
system_messageYou are an AI assistant that's helpful and efficient.
instructionWhat is the answer to life the universe and everything. Give me just the answer. No bla bla...
return_full_textfalse
do_samplefalse
temperature0.50
max_new_tokens500

Run Phi is where the ComfyUI-Phi pack actually does its work. Load Phi puts the 3.8B Phi-3.5-mini-instruct model in memory; this node takes a prompt and produces text. The genuinely useful part: it runs a chat-style generation with a system message, which is exactly what you want for prompt engineering. Feed it "You are an expert prompt writer for SDXL. Turn this idea into a detailed prompt:" and your rough thought goes in one side, a full prompt comes out the other. No API key, no network call - the whole thing is a HuggingFace pipeline running on your GPU.

People reach for it for the same reason anyone runs an LLM inside ComfyUI: to stop copy-pasting between a browser tab and the prompt box. Prompt rewriting, captioning, "what would this LoRA add to this prompt," mild automation - it all fits in a graph once you have a text node this easy.

How it works

The source is refreshingly small. The node builds a messages list with a system role and a user role, then runs transformers.pipeline("text-generation") with the loaded model and tokenizer. Generation args are exactly what you set in the UI. The response is pulled from output[0]["generated_text"] and handed out as a plain STRING - which means you can wire it into anything that takes text, like a CLIP text encoder's positive prompt.

The inputs that matter

Seven required inputs, and only a few you'll actually touch:

  • phi_model / phi_tokenizer - plug in the two outputs from Load Phi. No other pack produces these.
  • system_message - the personality/role. This is the most powerful input here; a good system message does 80% of the work for prompt rewriting.
  • instruction - what you actually want. Multiline, so paste a whole paragraph.
  • temperature - defaults to 0.5, ranged 0.01+. For prompt-generation work people tend to push this up toward 0.8–1.0 for variety; for deterministic output leave sampling off.
  • max_new_tokens - cap on generated tokens, default 500. Fine for prompts; raise it for longer prose.
  • do_sample - off by default, which is the right call for repeatable prompt edits.
  • return_full_text - returns the whole conversation instead of just the new text. On by default it's false, and you'll want to keep it that way; flipping it makes the node stringify the message dict, which is ugly to pipe anywhere.

Output

One output: STRING, labeled "text" in the code. That's it. It goes straight into any downstream text input - or into a Preview Text node if you want to eyeball it.

Install and gotchas

Install is the pack-level routine (ComfyUI Manager → "Phi", or git clone https://github.com/alexisrolland/ComfyUI-Phi into custom_nodes and pip-install its requirements.txt). Run Phi itself needs nothing beyond what Load Phi pulled in.

Where people get burned:

  • Load Phi first, with the model actually downloaded. Run Phi just fails at generation if the model object it receives isn't valid. The model folder must exist under ComfyUI/models/microsoft/ because Load Phi uses local_files_only=True - no silent download.
  • First generation is slow. The model loads into memory on the load node; the first run after that still has warm-up cost. It's normal, not a hang.
  • It shares ComfyUI's Python environment. This pack deliberately stopped pinning transformers (v4.0.3), so it inherits whatever version ComfyUI has. If another pack updates transformers and Phi starts erroring, that's the classic custom-node dependency collision, not your fault - check versions before rebuilding anything.
  • VRAM pressure. Phi-3.5-mini is ~7–8GB in fp16. On a 12GB card running it alongside a full diffusion pipeline is tight; on 8GB it's a non-starter with a checkpoint loaded. If that's your card, an GGUF-based text node is the usual workaround - this pack doesn't do quantization.
Categoryphi

Inputs (8)

NameTypeDefaultDescription
phi_modelphi_model
phi_tokenizerphi_tokenizer
system_messageSTRINGYou are an AI assistant that's helpful and efficient.
instructionSTRINGWhat is the answer to life the universe and everything. Give me just the answer. No bla bla...
return_full_textBOOLEANfalse
do_sampleBOOLEANfalse
temperatureFLOAT0.50
max_new_tokensINT500

Outputs (1)

NameTypeDescription
STRINGSTRING