← All models

question-answering · text · WASM · ~65 MB

DistilBERT SQuAD — find the answer inside a passage

This is extractive question answering: give it a passage and a question, and instead of writing a new sentence it points at the exact span of the passage that answers you — and tells you how confident it is. Type a question below and watch it highlight the answer, then look inside to see the real start/end token probabilities it used to pick that span. Nothing leaves your device.

At a glance

ModelXenova/distilbert-base-cased-distilled-squad
Task / pipelinequestion-answering (extractive span prediction)
How it workspredicts two distributions over the passage tokens — where the answer starts and where it ends
ArchitectureDistilBERT (6-layer, cased) fine-tuned on SQuAD 1.1
Quantizationq8 (8-bit) ONNX
BackendWebAssembly (runs anywhere; no WebGPU needed)
Download~65 MB, cached after first load
LicenseApache-2.0
Web APIsWebAssembly, Web Workers — all Baseline widely available

Run it

Paste any passage, ask a question about it, and the model highlights the answer span in the passage. The candidate list shows its next-best guesses with their probabilities.

See inside — the start/end token probabilities

The model never "reads" an answer out — it outputs two numbers per passage token: how likely that token is the first word of the answer, and how likely it is the last. The answer is just the span from the best start to the best end. Below is the real (softmaxed) distribution over the passage tokens for your last question — the outlined tokens are the chosen start and end.

Answer a question above to inspect the token probabilities.

Why it matters

Extractive QA is the quiet engine behind "answer from my documents". Because it returns a span of the source rather than inventing text, the answer is always grounded — it literally can't hallucinate a fact that isn't in the passage. And at 65 MB it runs in a tab, so you can query private documents, contracts, or logs without any of it leaving the device.

Use cases

Basics

Ask a question about a short passage and watch the exact answer span light up.

Practical

Paste your own document and query it — a tiny FAQ bot over text you control.

Wild

Trick it: adversarial and unanswerable questions, and spotting when it's guessing.

Multi-model

MiniLM retrieves the right paragraph, then this model pulls the exact answer from it.

How the API works

The pipeline takes a question and a context and returns the best span with a score:

import { pipeline } from "@huggingface/transformers";

const qa = await pipeline(
  "question-answering",
  "Xenova/distilbert-base-cased-distilled-squad",
); // downloads + caches ~65 MB once

const out = await qa(
  "How tall is the Eiffel Tower?",
  "The tower is 330 metres tall …",
  { topk: 5 },
);
// → [{ answer: "330 metres", score: 0.97, start: 12, end: 22 }, …]

"See inside" reuses that same loaded model instance (qa.model + qa.tokenizer) to read the raw start_logits / end_logits, softmax them over the passage tokens, and draw the distribution. All of it runs in a Web Worker so the UI never janks.

References