Nodes/ComfyDL/RNN LM Predict
ComfyUI Node

RNN LM Predict

The payoff node of the LM demo

By Cynthia-lxx·Created 2 months ago·Updated about 16 hours ago· 6
RNN LM Predict
  • model
  • vocab
  • prediction
prefixthe
num_preds10

This is the most fun node in the whole ComfyDL pack, because it's the one that makes the "before/after" visible: feed it a little language model and a starting prefix, and it prints the next few characters the model believes should follow. In the README's signature demo it's the payoff - the step where a few hundred lines of wiring turn into actual text on your screen instead of another tensor you have to squint at.

It's part of ComfyDL's NLP Models category and it sits at the end of the RNN language-model chain: RNN (from scratch) or GRU builds the recurrence, RNN Language Model (from scratch) wraps it with an output layer, and this node runs it forward and hands you a prediction string.

What it actually does under the hood

Generation is greedy, one token at a time. The model is given your prefix, runs its recurrence over it to warm up the hidden state (the d2l "warm-up period"), then at each step picks the single most likely next token via argmax over the vocab, feeds it back in, and repeats. There's no sampling, no temperature, no beam search - just the most probable continuation, every time.

Two consequences worth knowing before you're disappointed:

  • It's really built for character-level models. The prefix is treated as a sequence of characters, looked up one at a time in the vocab. The demo's default prefix of "the " and its ''.join-style output are the classic d2l "time machine" character LM setup. Feed it a word-level vocab and most of your prefix will map to <unk>, and you'll get junk out.
  • Greedy argmax degenerates. Even a well-trained RNN, forced to always pick its top guess, tends to repeat itself after a while ("the traveller said said said…"). That's the model honestly telling you it has no idea; it's not a bug.

The inputs you'll actually set

  • model - must be an RNN language model wrapper (RNN Language Model from scratch or high-level), not a bare RNN. The node checks for a predict method and raises a clear error if you feed it a raw recurrence. Wrap first, then predict.
  • vocab - the cdlVocab out of Vocab Build, so the model can map hidden states back to characters and decode its answer.
  • prefix - where to start. Defaults to "the ".
  • num_preds - how many tokens to generate after the prefix (1–1000). Keep it small-ish; a character LM on the default tiny config goes off the rails fast past a few hundred.

The trap nobody warns you about

The pack's shipped demo wires this node straight onto an untrained model just to show the wiring. Predictions will be gibberish - a handful of random characters - because the weights are still at their init values. In the d2l textbook this node appears after training loops; in a ComfyUI graph there's no automatic training for this model, so "it output garbage" is usually not a broken workflow, it's an untrained one. If you want sensible text you'll need to train the model first (the pack's TorchOps gives you SGD Step and Gradient Clip to roll your own loop) or just accept the demo's purpose: proving the pipeline runs end to end.

Installing ComfyDL

Same install for every node in the pack:

cd ComfyUI/custom_nodes
git clone https://github.com/Cynthia-lxx/ComfyDL ./ComfyDL
pip install -r ./ComfyDL/requirements.txt

Restart ComfyUI and the nodes appear under ComfyDL/NLP Models. Keep the folder named exactly ComfyDL, and note ComfyUI Manager may not list the pack yet (its registry PublisherId is unfilled), so cloning is the reliable route. Dependencies are just matplotlib, IPython and matplotlib-inline - torch/torchvision come from ComfyUI itself.

The pack is too new and too niche for any community troubleshooting to exist yet, so when output looks wrong, go to the repo's FUNCTIONS.md and the d2l RNN chapter it mirrors. This is a teaching node, and the "aha" it's teaching is that prediction is the easy half - training is where the work happens.

CategoryComfyDL/NLP Models

Inputs (4)

NameTypeDefaultDescription
modelcdlModel
vocabcdlVocab
prefixSTRINGthe
num_predsINT101–1000

Outputs (1)

NameTypeDescription
predictionSTRING