XB-llama - 🚀 模型加载Pro
XB_ToolBox's GGUF loader doesn't load anything — and that's the feature
- llama_model
- parameters
XB-llama - 🚀 Model Loader Pro is the front door of XB_ToolBox's LLM branch: one node where you pick a local GGUF, cap how much VRAM it may touch, and set every sampling knob the pack's inference nodes will use. If you've been keeping Ollama running just so a ComfyUI node can rewrite your prompt, this is the in-graph alternative.
What it is not is a model loader. Get that straight first.
Why it's called a loader and loads nothing
Read the source: loadmodel() returns two Python dicts. The first (llama_model, type LLAMACPPMODEL) is just a config - model path, mmproj, chat handler, context length, VRAM limit, image-token caps, backend, GPU index. The second (parameters, type LLAMACPPPARAMS) holds the sampling settings. Weights load later, when a downstream inference node fires and calls LLAMA_CPP_STORAGE.load_model().
Two consequences in practice: a workflow containing this node allocates no VRAM just by being queued, and if you swap in an online API node the local weights never load at all. Also, there's no "[XB-llama] loading model" line in the console until the downstream node runs - if you're watching the log wondering why nothing's happening, that's the design, not a hang.
Models come from ComfyUI/models/LLM/ - the pack registers that folder and scans for .gguf, .safetensors, .bin, .ckpt, .pt, .pth. Files with mmproj in the filename are pulled out of the main model list and offered as projectors instead.
The inputs that matter
model- the enum built from that folder. Empty dropdown means the folder is empty or missing.mmproj-Nonefor text-only models. Point it at a projector file and you've built a VLM, with one hard rule the code enforces:chat_handlercan't stayNonewhile an mmproj is loaded, or you get an error instead of a model.chat_handler- the chat template for your architecture (Qwen3-VL, MiniCPM, Gemma3, GLM-4.6V and friends). This list is discovered from your installedllama-cpp-python, so an old wheel silently gives you a shorter dropdown.-advanced_settings- off by default, and it hides everything below. Flip it on.n_ctx(32768) andmax_tokens(8192) - the author's tooltips are unusually specific here: a short story fits in 32768, a 56-shot script wants 131072–262144, and 6 shots run about 12K output tokens against ~128K for 56. Under-budget these and the model stops mid-storyboard.temperature(0.60) - the tooltip says why: it keeps the[SHOT_START]format strict and cuts hallucination. That marker is the tell for what this branch is built for, which is turning a story into per-shot prompt lines, not writing poetry.repeat_penalty(1.05) - a nudge, not a hammer. Too high and the LLM starts dropping dialogue it already wrote earlier in the story.vram_limit- the interesting one.-1means unlimited. Give it a number and the loader estimates per-layer size from the GGUF's file size and layer count, then computes how many layers fit in that budget (subtracting the projector's size when one is loaded). That's how a 9B Q4 lives alongside your diffusion model. The author's own tooltip warns it's a reference figure and you can overshoot - so set it below your free VRAM, not equal to it.state_uid--1uses the node's own unique id to persist conversation state, so each node keeps its own history.
Skip backend and gpu_device unless you know something I don't. The backend tooltip admits llama-server isn't wired in at all - picking it records the choice and changes nothing - and gpu_device only ever applied to that unimplemented subprocess path.
Outputs, and where they go
llama_model is the config dict that goes into a downstream inference node's model input - the pack's nodes take it as a wildcard type, so the same socket takes either a local config or an online API settings string. parameters carries the sampling settings into that node's optional parameters input. Wire both.
Install
ComfyUI Manager, search XB_ToolBox, or:
cd ComfyUI/custom_nodes
git clone https://github.com/wjluoxiao/XB_ToolBox.git
Restart ComfyUI. Ignore the README's "no extra pip dependencies" line for this branch - requirements.txt lists diskcache and gguf and leaves llama-cpp-python commented out, because you install that wheel yourself: CUDA builds from the JamePeng release page, ROCm/HIP compiled for AMD, matched to your Python version (their example is cp312). Then create ComfyUI/models/LLM/ and drop your GGUFs in it.
Where people get burned
- A
RuntimeErroraboutllama-cpp-pythonnot being installed: the wheel isn't there, or it's too old for the chat handler you picked. The error text includes the wheel links. - Empty
modeldropdown: emptymodels/LLMfolder, or files in a format outside the extension list. - mmproj selected, handler left at
None: hard error by design. - Expecting
vram_limitto be a promise. It's arithmetic on an estimate; leave headroom.
Inputs (23)
| Name | Type | Default | Description |
|---|---|---|---|
| model | COMBO | 0 options: | |
| mmproj | COMBO | 1 options: None | |
| chat_handler | COMBO | None | 1 options: None |
| advanced_settings | BOOLEAN | false | 开启后显示上下文长度、显存上限、图像token 及全部推理参数 |
| n_ctx | INT | 327681024–262144 | 上下文长度上限 Qwen3.5-9B 原生 262144(256K);短篇 32768,56 段调到 131072-262144 |
| vram_limit | INT | -1-1–1024 | 显存使用上限(GB), -1=不限制 参考值, 实际可能略超 |
| image_min_tokens | INT | 00–4096 | — |
| image_max_tokens | INT | 00–4096 | — |
| max_tokens | INT | 81920–262144 | 生成 Token 上限(Qwen3.5-9B 上限 262144) 6 段约 12K,56 段约 128K,请按段数调整 |
| top_k | INT | 400–1000 | 词汇库检索范围 40 配合 0.60 温度,兼顾格式严谨与词汇多样 |
| top_p | FLOAT | 0.900–1 | — |
| min_p | FLOAT | 0.050–1 | — |
| typical_p | FLOAT | 1.000–1 | — |
| temperature | FLOAT | 0.600–2 | 温度 0.60 确保 [SHOT_START] 格式严谨,减少幻觉 |
| repeat_penalty | FLOAT | 1.050–10 | 重复惩罚 1.05 轻微防句式复读,同时保留台词(太高会让 LLM 省略已在故事里写过的台词) |
| frequency_penalty | FLOAT | 0.000–1 | — |
| present_penalty | FLOAT | 0.000–2 | — |
| mirostat_mode | INT | 00–2 | — |
| mirostat_eta | FLOAT | 0.100–1 | — |
| mirostat_tau | FLOAT | 5.000–10 | — |
| state_uid | INT | -1-1–999999 | 使用特定 ID 保存对话状态 (-1 = 使用节点 unique_id) |
| backend | COMBO | llama-cpp-python | 本地推理后端。 llama-cpp-python:进程内后端(XB_ToolBox 当前实现,默认) llama-server:子进程后端,需额外的服务端运行环境;当前 XB 后端尚未接入,选它不会改变实际推理方式(仅记录到配置里) |
| gpu_device | COMBO | auto | GPU 设备索引(仅 llama-server 子进程后端使用)。 auto = 自动跟随 ComfyUI 当前显卡;当前 XB 进程内后端始终自动跟随 ComfyUI |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| llama_model | LLAMACPPMODEL | — |
| parameters | LLAMACPPARAMS | — |