Nodes/ComfyUI-Llama/LLM_Token_BOS
ComfyUI Node

LLM_Token_BOS

The token ID that marks the start of everything

By HairlessPrimate·Created 3 years ago·Updated 2 years ago· 71
LLM_Token_BOS
  • LLM
  • INT

Every language model's tokenizer has a few reserved IDs that aren't words - they're markers. The BOS token (begin-of-sequence) is the one that says "a new sequence starts here." LLM_Token_BOS is a tiny node that does one thing: ask your loaded model what its BOS token ID is, and hand it back as an INT.

Why does that ID matter? Because when you build token sequences by hand - the pack's whole low-level mode of operation - the BOS marker is what tells the model a fresh prompt is beginning rather than a continuation of whatever came before. It's the difference between "here's a new thought" and "here's more of that same thought." llama.cpp and the pack's own LLM_Tokenize insert it automatically when add_bos is on; this node exists so you can insert it yourself when you're assembling sequences manually.

Input and output

  • LLM - the loaded model. It has to be, because the BOS ID is different for every tokenizer. On many models it's the same few numbers (1 and 2 are common), but you should never assume - that's the entire reason the node exists. Hardcoding 1 into a hand-built token list works until the day you swap models and the output quietly changes.

The output is INT - the model's BOS token ID.

When you'd reach for it

This is strictly a token-surgery node, useful in exactly one scenario: building token sequences by hand for the LLM_Eval / LLM_Sample pipeline, where you want to prepend the BOS marker before feeding your prompt's tokens in. In that flow it's the punctuation you put at the front of a sentence. There's no visible text involved, nothing to tune, no settings.

If you're using the pack the normal way - Load LLM Model → Call LLM - you will never touch this node, and that's fine. It's part of the exposed toolkit, the same way llama.cpp exposes llama_token_bos to C++ programmers. It's a constant you look up, not a process you run.

Install

The shared pack steps: ComfyUI Manager search "ComfyUI-Llama", or:

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

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

Honest verdict: LLM_Token_BOS is about as thin as a node gets - one query, one number. If you're hand-assembling token sequences, it's the difference between guessing a magic number and knowing it. If you're not, you can ignore it without losing a single useful feature.

CategoryLLM

Inputs (1)

NameTypeDefaultDescription
LLMLLM

Outputs (1)

NameTypeDescription
INTINT