Nodes/ComfyUI-N-Nodes/GPT Text Sampler
ComfyUI Node Runs on cloud

GPT Text Sampler

Run a local GGUF LLM inside your ComfyUI graph

By Nuked88·Created 3 years ago·Updated 2 years ago· 237
GPT Text Sampler
  • model
  • STRING
prompt
model_path
max_tokens2048
temperature0.70
top_p0.50
logprobs0
echodisable
stop_tokenSTOPTOKEN
frequency_penalty0.00
presence_penalty0.00
repeat_penalty1.18
top_k40
tfs_z1.00
print_outputdisable
cachedNO
prefix### Instruction:
suffix### Response:

This is the other half of GPT-Loader-Simple - the loader gets a GGUF language model into your graph, this node actually runs it. Feed it a prompt and a loaded model, and it generates text through llama-cpp-python, the same way you'd get output from any local llama.cpp setup, just wired into ComfyUI's node graph instead of a terminal or a separate chat UI.

How it works

Under the hood this is calling straight into llama.cpp's completion API, and the parameter list reflects that pretty directly if you've used any local LLM tooling before. prompt is your input text. model is the Llama instance from GPT-Loader-Simple, and this bare version of the sampler also wants model_path fed alongside it - the resolved checkpoint path the loader's second output provides. max_tokens (default 128) caps how much it generates. temperature, top_p, top_k, and tfs_z are the standard sampling knobs that trade determinism for variety; frequency_penalty, presence_penalty, and repeat_penalty all push against the model repeating itself. stop_token tells it when to quit generating early. prefix and suffix default to ### Instruction: and ### Response: - that's Alpaca-style instruction formatting, and it matters more than it looks: if you're running a model trained on a different chat template (ChatML, ordinary chat-turn formatting, whatever), leaving these defaults on can produce noticeably worse output. Match the prefix/suffix to whatever format your specific GGUF model actually expects.

The inputs and outputs that matter

Beyond prompt and model: cached (default NO) skips regenerating if the input hasn't changed, useful when you're iterating on something downstream and don't want to re-run the LLM every single queue. echo controls whether the prompt itself gets included alongside the generated text. print_output just dumps the result to your console, handy for debugging without wiring up a text-preview node.

Output is a single STRING - the generated text, ready to feed into a CLIP Text Encode if you're using this to auto-write or expand prompts, or anywhere else that takes text.

Installing the pack

  • ComfyUI Manager - search "ComfyUI-N-Nodes," install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/Nuked88/ComfyUI-N-Nodes.git, then restart ComfyUI.

llama-cpp-python installs itself with prebuilt CUDA wheels now, per the README - no manual compile step needed for GPU support the way older guides describe.

Common issues & troubleshooting

Output reads like garbage or ignores your prompt. Check prefix/suffix against what your model actually expects. The Alpaca-style default (### Instruction: / ### Response: ) is right for Alpaca-format models and wrong for a lot of newer chat-tuned GGUFs - a template mismatch is one of the most common causes of nonsense output from any local LLM setup, this one included.

Generation is slower than you'd like. That's a loader-side setting, not this node - go back to GPT-Loader-Simple and check gpu_layers. If it's low, most of the compute is landing on CPU regardless of what this sampler's settings say.

Repeats itself in longer generations. Push repeat_penalty up from its default (1.17647) and check frequency_penalty/presence_penalty - all three exist specifically to fight this, and the default values are a reasonable starting point rather than the last word.

You're missing model_path and hitting an error. That input only exists on this older bare version of the sampler - if you're using GPT-Loader-Simple [n-suite]'s single model output, pair it with GPT Text Sampler [n-suite] instead, which drops the model_path requirement.

CategoryN-Suite/Sampling

Inputs (18)

NameTypeDefaultDescription
promptSTRING
modelCUSTOM
model_pathSTRING
max_tokensINT2048
temperatureFLOAT0.700.2–1
top_pFLOAT0.500.1–1
logprobsINT0
echoCOMBOdisable2 options: enable, disable
stop_tokenSTRINGSTOPTOKEN
frequency_penaltyFLOAT0.00
presence_penaltyFLOAT0.00
repeat_penaltyFLOAT1.18
top_kINT40
tfs_zFLOAT1.00
print_outputCOMBOdisable2 options: enable, disable
cachedCOMBONO2 options: YES, NO
prefixSTRING### Instruction:
suffixSTRING### Response:

Outputs (1)

NameTypeDescription
STRINGSTRING