nodes / builtin / ai / localai
Answer Question
Extract an answer from a passage, on-device
Find the answer to a question inside a passage of text, with a model that runs in your browser.
What it does
Section titled “What it does”Answer Question reads the Context passage and returns the piece of it that best answers the Question, with a confidence score. The answer is always copied word for word from the context: the model does not write new text, so it cannot make up facts that are not there.
It runs on your device with a question-answering model such as DistilBERT SQuAD or the TensorFlow.js MobileBERT Q&A. There is no cost per run and no API key.
When to use it
Section titled “When to use it”- Pull one fact out of an email, an invoice or a scraped page: an order number, a date, a price.
- Ask the same question of many items, such as “Who is the sender?” for every message in a list.
When you need a written answer that combines several facts, use Q&A Agent with a chat model. To pull several named fields at once, use Information Extractor.
Inputs and settings
Section titled “Inputs and settings”| Setting | Type | What it does |
|---|---|---|
| Model | Model picker | Any installed question-answering model, across engines. |
| Question | Text | |
| Context | Text | The passage to find the answer in. |
Both Question and Context must have text. Ask short, direct questions (“What is the delivery date?”). Keep the context focused: these small models read a limited amount of text, so pass the relevant paragraph rather than a whole page.
Outputs
Section titled “Outputs”-
Output
Each output item has these fields:
| Field | Type | What it holds |
|---|---|---|
| answer | Text | |
| score | Number |
{ "answer": "…", "score": 0}answer is the extracted text (empty when the model finds nothing). score is the model’s confidence from 0 to 1. Use an IF on {{ $input.score }} to skip low-confidence answers.
Dependencies and credentials
Section titled “Dependencies and credentials”None. This node needs no connection and has no slots for other nodes.
The Model picker lists your installed models first, then models that download on first use. Manage them on the Local AI page.
Example workflow
Section titled “Example workflow”Pull the order number from the email text you select:
- Context Menu with Menu Contexts set to Selection.
- Answer Question with Model DistilBERT SQuAD, Question
What is the order number?and Context{{ $input.selectionText }}. - Clipboard Write with Text
{{ $input.answer }}.
Common issues
Section titled “Common issues”- “Choose a Q&A model.” Model is empty. Pick one.
- “Provide both a question and a context passage.” Question or Context is empty after expressions run. Check the field names in your expressions.
- The answer is wrong or very short. The answer must appear in the context. Rephrase the question with words used in the text, or trim the context to the relevant part.
- “Model “…” isn’t available. Install it from Local AI.“ The saved model is no longer in your list, for example a removed custom model. Pick another model.
Related nodes
Section titled “Related nodes”- Q&A Agent: answer with a chat model.
- Information Extractor: pull several fields at once.
- Run Local Model: its Answer question task takes question and context as one JSON input.
- Summarize: condense a passage on-device.