Replicate meta/meta-llama-3-8b-instruct
Run an LLM inside your ComfyUI graph
- STRING
This drops a text LLM - Meta's Llama 3 8B Instruct - straight into a ComfyUI graph. Send it a prompt, get text back. In an image workflow that's mostly good for one thing: prompt expansion. Feed it a scrappy idea ("cyberpunk cat") and a system prompt telling it to act as a Stable Diffusion prompt writer, and it hands you a detailed prompt you wire into your text encoder. It's also handy for rewriting captions, summarizing, or any string-munging step you'd otherwise do by hand.
It runs through Replicate's cloud - the model runs on Replicate's GPU, not yours - so you need a Replicate account and a REPLICATE_API_TOKEN, and you pay per call. Nothing installs locally beyond the wrapper.
How it works
It's a standard instruction-tuned chat model. You give it a system_prompt (its role/instructions) and a prompt (the user turn), and it generates a completion. The catch specific to Llama 3 is the chat template: the model expects its special tokens (<|begin_of_text|>, <|start_header_id|>, and so on) wrapped around your text. This node handles that via the prompt_template field, which already contains the correct template with {system_prompt} and {prompt} placeholders - leave it alone unless you know exactly what you're doing.
The inputs and outputs that matter
prompt(required) - your input / question / idea.system_prompt(default "You are a helpful assistant") - the lever that turns this into a prompt-enhancer. Set it to something like "You expand short ideas into detailed image-generation prompts. Reply with only the prompt."temperature(0.7) - creativity. Lower = focused and repeatable, higher = more varied and loose.top_p(0.95) /top_k(0) - sampling controls; the defaults are fine for most uses.
Output is a single STRING you wire into a CLIP/text encode, a show-text node, or downstream logic. stop_sequences, length_penalty, presence_penalty, and seed give finer control, prompt_template holds the Llama 3 chat template, and force_rerun bypasses Replicate's cache when identical inputs would return the same text.
How to install it
One install covers every Replicate node.
- ComfyUI Manager: search ComfyUI-Replicate, install, restart.
- Manual:
then restart.cd ComfyUI/custom_nodes git clone https://github.com/replicate/comfyui-replicate cd comfyui-replicate pip install -r requirements.txt
No model weights download - Llama runs on Replicate. Only the replicate pip package installs. Set your token first: export REPLICATE_API_TOKEN="r8_..." (replicate.com/account/api-tokens).
Common issues & troubleshooting
The output is rambly or includes "Sure, here's your prompt:" preamble. That's the model chatting. Tighten the system_prompt - tell it explicitly to reply with only the prompt and nothing else - and drop temperature a bit. You can also set a stop_sequences value to cut it off.
The output is garbled or the special tokens leaked into it. You probably edited prompt_template and broke the Llama 3 format. Restore the default template; the model depends on those exact tokens to know where the system and user turns start and end.
It's not as smart as I hoped. It's an 8B model - capable, but not GPT-4. For prompt expansion and light rewriting it's plenty; don't lean on it for complex reasoning. Keep the task narrow and the system prompt specific.
Same text on a re-run. Replicate returned the cached result for identical inputs. Set force_rerun, or change seed/temperature, to get a fresh generation.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| system_promptopt | STRING | You are a helpful assistant | — |
| temperatureopt | FLOAT | 0.700–5 | — |
| top_popt | FLOAT | 0.950–1 | — |
| top_kopt | INT | 0 | — |
| stop_sequencesopt | STRING | <|end_of_text|>,<|eot_id|> | — |
| length_penaltyopt | FLOAT | 1.000–5 | — |
| presence_penaltyopt | FLOAT | 0.00 | — |
| seedopt | INT | — | |
| prompt_templateopt | STRING | <|begin_of_text|><|start_header_id|>system<|end_header_id|> {system_prompt}<|eot_id|><|start_header_id|>user<|end_header_id|> {prompt}<|eot_id|><|start_header_id|>assistant<|end_header_id|> | — |
| force_rerunopt | BOOLEAN | false | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |