multi-model · Xenova/multi-qa-MiniLM-L6-cos-v1 (22.97 MB) → onnx-community/tinyroberta-squad2-ONNX (82.14 MB) · WASM q8

2-stage open-book QA: retrieve, then read

A reader model can only answer from the text it is given, and reading every passage is slow. So chain two local workers: Stage 1 · Multi-QA MiniLM embeds the corpus and picks the top-K passages for the question in milliseconds; Stage 2 · TinyRoBERTa-SQuAD2 reads only those and extracts the exact answer span — or abstains, because SQuAD 2.0 taught it to recognise unanswerable questions.

1 · Workflow models

Stage 1 · Multi-QA MiniLM-L6-cos-v1

feature-extraction · 384-d mean-pooled unit vectors · 22.97 MB q8 · Apache-2.0 · ./worker.js

Stage 2 · TinyRoBERTa-SQuAD2

question-answering · span extraction + null-answer abstention · 82.14 MB q8 · CC-BY-4.0 · reuses ../tinyroberta-squad2/worker.js

2 · Corpus, question & pipeline

Prepare both models above to run the pipeline.

Stage 1 query–
Corpus index–
Stage 2 reading–
Passages read–
Reader confidence–
NaN count–
no answer yet

Run the pipeline to get an answer.

3 · Stage 1 shortlist (dense retrieval)

Run Stage 1 to shortlist passages.

4 · Stage 2 readings (extractive QA per passage)

Run Stage 2 to read the shortlist.

Known failure mode to try: ask the Solar-system corpus “Who was the first person to walk on Mars?”. Retrieval correctly surfaces the Apollo 11 passage, and an extractive reader can still lift “Neil Armstrong” from it with moderate confidence (≈51% in our Chrome runs) — a near-miss passage fools span extraction. Raising the threshold trades such errors for more abstentions; nothing on this page is post-edited.
Show the code — combining per-passage readings into one answer or an honest abstention
Show the code — the Stage 2 reader client reusing the TinyRoBERTa worker