Structured Keyword Extraction
Squeeze a clean keyword list out of a VLM caption
- model
- STRING
The name undersells it. KeywordExtraction (displayed as Get Keywords) is one half of the pack's automatic prompt-generation pipeline, and it exists because raw LLM output is messy. You feed it a caption or description - ideally the STRING output of a LLaVA node - and it returns a structured, JSON-shaped keyword list you can actually wire into the next node. No "here are the keywords I extracted:" preamble, no rambling. Just the data.
What it's for
This is the text-middleman in a caption-to-prompt chain: VLM describes an image → Get Keywords pulls the salient terms → a prompt generator builds a usable prompt. The whole point of the pack's structured-output machinery is that prompt engineering alone can't reliably make an LLM return clean JSON, so these nodes bake the structure in instead of hoping for it.
How it works
The node runs a structured chat against whatever GGUF model you hand it: a system message that demands "return only the requested JSON object," a JSON schema describing the analysis, and a response format constraint from llama.cpp so the model literally can't wander off into prose. Out comes valid JSON - a keyword/entity breakdown of your input. The old README described this as llama-cpp-agents/GBNF grammar territory; the current version uses llama.cpp's structured JSON support, same idea, less breakage.
The inputs that matter
- prompt - the text to analyze. The richer it is, the better the keywords.
- model - a
CUSTOMhandle from LLMLoader, i.e. any GGUF you've loaded. LLaVA 1.5/1.6 GGUFs work great here too. - temperature - default 0.15. Keep it low; you want extraction, not creativity.
Output and the pipeline
One STRING containing the JSON. The author's own guidance: outputs are JSON-looking text, so put a JsonToText or ViewText node on the end to read it, and feed the result into the pack's LLavaPromptGenerator to turn the keywords into a generation prompt. That three-node chain - LLaVA → Get Keywords → Prompt Generator - is the pack's flagship automatic-prompt demo.
Install and gotchas
Same pack install:
cd ComfyUI/custom_nodes
git clone https://github.com/gokayfem/ComfyUI_VLM_nodes
python -m pip install -r ComfyUI/custom_nodes/ComfyUI_VLM_nodes/requirements.txt
This node rides on llama.cpp, so the usual llama-cpp-python rule applies: install a wheel built for your GPU backend, or it runs on CPU and feels glacial. If the output is not valid JSON, the model is fighting the schema - usually a too-small or chat-tuned GGUF - and the pack will raise a clear "did not return valid JSON" error rather than silently handing you garbage. That error is a feature: it tells you to swap the model before it pollutes your workflow.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| prompt | STRING | — | |
| model | CUSTOM | — | |
| temperature | FLOAT | 0.150–2 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |