Question Answering
Extract Answers From Text in ComfyUI (Question Answering)
- answer
- score
Question Answering is the node that reads a block of text and pulls out a direct answer to your question. It's extractive QA - the classic "here's a paragraph, now tell me the answer" task - and it's a genuinely useful utility inside a ComfyUI graph for anything text-heavy: summarizing the salient point of a script, pulling a value out of a specification, or answering questions about prompt text without leaving the workflow.
It wraps the question-answering pipeline from Hugging Face, defaulting to distilbert-base-cased-distilled-squad. That's a compact model (about 67M parameters) fine-tuned on SQuAD, the benchmark for extractive QA. Small and fast, it runs comfortably on CPU - one of the lighter nodes in this pack. The pipeline takes your question and context, finds the span of the context most likely to answer it, and returns it with a confidence score.
The inputs that matter
- question - the question, a single-line string.
- context - the passage to search, a multiline string. This is where the answer has to be; the model can't go beyond the text you give it.
- model_name - Hub model ID as a string, default
distilbert-base-cased-distilled-squad.
Two outputs: answer (a STRING with the extracted span) and score (a FLOAT confidence between 0 and 1). That score is worth wiring into a display node - a 0.98 answer is reliable, a 0.35 answer means the question and context probably don't align.
How to install it
Standard pack install - ComfyUI Manager (search "ComfyUI-Transformers") or:
cd ComfyUI/custom_nodes
git clone https://github.com/kadirnar/ComfyUI-Transformers
Restart ComfyUI. The pack's requirements.txt brings in transformers>=4.42, torch, numpy, and the distilbert checkpoint downloads quickly on first use.
Where people get burned
The limit is the model's, not yours: extractive QA answers from the context it's given, it doesn't reason. If the answer isn't literally in the text, you'll get either a wrong span or a low-confidence garbage answer - and the node doesn't flag that for you. That's why the score output matters more than it looks. Also keep in mind that "answer" here is a phrase pulled from the context, not a sentence written fresh - don't expect it to synthesize. If you're reaching for something more like a general-purpose assistant, you're on the wrong node; if you want "find the price in this paragraph," this is exactly right.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| question | STRING | — | |
| context | STRING | — | |
| model_name | STRING | distilbert-base-cased-distilled-squad | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| answer | STRING | — |
| score | FLOAT | — |