ComfyUI Node

LLM_Eval

The node that actually feeds tokens into the model's brain

By HairlessPrimate·Created 3 years ago·Updated 2 years ago· 71
LLM_Eval
  • LLM
    tokens0

    Every LLM has a hidden state called the context - the running record of everything it has "read" so far, which it consults every time it produces a new token. LLM_Eval is the node that writes tokens into that context. Feed it a list of token IDs and it runs them through the model, updating the KV cache so the next sampled token knows what came before. And here's the notable part: it has no outputs. It's a side-effect node, the first one in this pack.

    That makes it simultaneously the most invisible and most fundamental node here. The Call LLM nodes do evaluation for you internally - you never touch LLM_Eval for normal generation. You use it when you're assembling the inference loop by hand: LLM_Tokenize your prompt into IDs, push them into the model with LLM_Eval, then LLM_Sample to pull the next token out, detokenize to read it, and repeat. That's the exact loop llama.cpp runs, exposed as graph nodes.

    Inputs

    • LLM - the loaded model whose context you're writing to.
    • tokens - the INT list of token IDs to evaluate. Comes from LLM_Tokenize (for your prompt) or, in the loop pattern, from a previous LLM_Sample appended to the sequence.

    No outputs. That's not an oversight in the schema - the node's whole job is the side effect of updating the model's context.

    How you'd actually use it

    The manual loop is the thing this node exists for, and it's genuinely educational to build once:

    1. LLM_Tokenize a prompt → token IDs.
    2. Feed the IDs into LLM_Eval → context is now primed with your prompt.
    3. LLM_Sample → one token ID out (the model's guess at the next token, chosen with your sampling settings).
    4. LLM_Detokenize that ID → the character or word it produced.
    5. Feed the sampled token back into LLM_Eval to extend context, sample again, repeat.

    That's autoregressive generation, stripped to its parts. Do it a few times and you'll understand exactly why LLMs generate one token at a time and why the whole pipeline feels slow.

    The catch, and it's the pack's documented limitation: there's no known way to loop back output within ComfyUI itself. The README notes that repeating this loop - feeding a sampled token back into LLM_Eval - has no built-in mechanism, and the author points at ComfyUI-Custom-Scripts' WIP Repeater node as a possible (unfinished) solution. In practice, expect to run LLM_Eval a handful of times by hand with static tokens, not to build an infinite dialogue loop with it.

    Install

    Standard pack setup: ComfyUI Manager search "ComfyUI-Llama", or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/daniel-lewis-ab/ComfyUI-Llama
    

    plus pip install llama-cpp-python on manual installs. GGUF models into ComfyUI/custom_nodes/ComfyUI-Llama/models, restart, Ctrl+F5, nodes under the LLM menu.

    Bottom line: LLM_Eval is the pack's clearest look under the hood - an outputless node that does the real work of making the model aware of context. It's not for everyday prompting, but it's the difference between using an LLM and understanding one.

    CategoryLLM

    Inputs (2)

    NameTypeDefaultDescription
    LLMLLM
    tokensINT0

    Outputs (0)

    No outputs