ComfyUI-Prompt-Rewriter
Prompt Rewriter for ComfyUI using llama.cpp for local inference. Supports LLMs, VLMs, and both Instruct and Thinking models.
ComfyUI Prompt Rewriter
This is a custom fork of this repository incorporating some enhancements.
Use case
This node can rewrite your prompts with the help of a chosen instruct (or thinking) LLM/VLM (GGUF).
<img width="700" alt="AA" src="https://github.com/user-attachments/assets/c2b4de17-0121-4f9f-a845-3c0c52f74bce" />Installation
- Navigate to the ComfyUI/custom_nodes folder, open cmd and run:
git clone https://github.com/BigStationW/ComfyUI-Prompt-Rewriter
- Navigate to the ComfyUI\custom_nodes\ComfyUI-Prompt-Rewriter folder, open cmd and run:
..\..\..\python_embeded\python.exe -s -m pip install -r "requirements.txt"
Backend: Vulkan -> Works on all GPUs
If you have Windows, open cmd and run:
winget install llama.cpp
If you have another OS, you can refer to this.
To update llama.cpp, open cmd and run:
winget upgrade llama.cpp
Backend: CUDA -> Specialized for Nvdia
Double click the Install llama.cpp (CUDA).bat file.
To update your version, you can run that file again.
Instruct/Thinking LLMs
- Navigate to the ComfyUI\models folder and create a folder named "LLM"
- Navigate to the ComfyUI\models\LLM folder and create a folder named "gguf"
- Navigate to the ComfyUI\models\LLM\gguf folder and place your chosen GGUF LLM file there.
For example you can go for this (Instruct model):
- https://huggingface.co/Qwen/Qwen3-4B-GGUF
Or something like this (thinking model):
- https://huggingface.co/unsloth/Qwen3-4B-Thinking-2507-GGUF
You can even go for uncensored LLMs, like that one for example:
- https://huggingface.co/mradermacher/Josiefied-Qwen3-8B-abliterated-v1-GGUF
Usage
It should look like this.
<img width="700" alt="image" src="https://github.com/user-attachments/assets/e29ec62a-8770-41cf-99ed-7438a6fd4894" />An example workflow (for Z-image turbo) can be found here.
PS: The Display Any (rgthree) node can be found here.
MultiGPU and offloading
This node allows you to split the model into your GPUs and the CPU with the gpu_layers placeholder.
For example:
- Empty placeholder -> All layers go to the first GPU (default)
- gpu0:0.7 -> 70% to GPU:0, 30% to CPU
- gpu0:0.5, gpu1:0.4 -> 50% GPU:0, 40% GPU:1, 10% CPU
Image inputs
For Vision Language Models (VLMs), you can add up to 5 images to the Prompt Generator Options node.
- Download a VLM gguf file and put it to the ComfyUI\models\LLM\gguf folder, like that one for example:
- https://huggingface.co/unsloth/Qwen3-VL-4B-Thinking-GGUF
- Download its mmproj file and put it to the ComfyUI\models\LLM\gguf folder.
- https://huggingface.co/unsloth/Qwen3-VL-4B-Thinking-GGUF/blob/main/mmproj-BF16.gguf
- You have to rename "mmproj-BF16.gguf" to "Qwen3-VL-4B-Thinking-mmproj-BF16.gguf"
At the end it'll look like this:
<img width="700" alt="image" src="https://github.com/user-attachments/assets/a2f602a4-f156-49b8-b70b-4f94b7900d95" />