TL;DR
Open-domain question answering is the task of answering a natural-language question when the answer lives somewhere in a very large collection of text, such as all of Wikipedia, and the system is not told which document to use. It works in two stages. A retriever searches the collection and returns a short list of passages that are likely to contain the answer, and a reader looks at those passages and picks out the answer span. Retrieval has to be fast enough to search millions of passages, and reading has to be accurate enough to ignore the passages that only look relevant.
Builds on: Inverted Index, Bi-Encoder · Leads to: Retrieval-Augmented Generation, dense passage retrieval
Where it's used
Search engines answering questions directly. When a search box shows a short answer above the links, a retriever has found the page and a reader has pulled out the sentence that answers the question. The same two-stage design sits behind many "answer box" features.
Research benchmarks on Wikipedia. The 2017 DrQA system answered questions from about five million Wikipedia articles, using a keyword-based retriever and a neural reader. Later benchmarks such as Natural Questions and TriviaQA use the same setup, and they are the standard tests for new retrievers.
Grounding chatbots in documents. A company's help desk or a legal team can index its own documents and ask the system questions. Retrieved passages can be shown next to the answer, so a person can check where it came from. Retrieval-augmented generation is the modern form of this idea, where a language model writes the answer from the retrieved text.
How it works
We trace one tiny corpus of three short documents. Each document is a passage:
- D1: "Paris is the capital of France."
- D2: "The Seine flows through Paris."
- D3: "Berlin is the capital of Germany."
The question is "capital of France".
-
Index the passages. Lowercase the words and record which passages contain each word. The Inverted Index for the three passages is:
capital: D1, D3france: D1of: D1, D3paris: D1, D2
Check: a word that appears in no passage has no entry, so a search for it returns nothing.
-
Retrieve by word overlap. For the query, count how many of its words each passage contains. D1 contains
capital,ofandfrance, so its count is 3. D3 containscapitalandof, so its count is 2. D2 contains none, so its count is 0. Check: the index lets us visit only the passages that appear in some query word's list, here D1 and D3. -
Keep the top passages. Keep the best-scoring passages. With we keep D1 and D3. Check: a larger gives the reader more chances to find the answer, but it also gives the reader more distractors.
-
Read the passages. The reader looks at each passage and scores every possible answer span. In D1 the span "Paris" fits the question, because it is the capital of France. In D3 the best span is "Berlin", which is the capital of Germany and does not match France. Check: the reader must notice the word France in the question and prefer the span that answers about France.
-
Pick the answer. Compare the best span scores across passages and return the highest. Here it is "Paris" from D1. Check: the answer comes with its passage, so a person can verify it.
A bi-encoder can replace step 2 with vector search. It embeds the query and each passage as vectors ahead of time, then scores passages by a dot product. That finds passages with matching meaning even when the words differ, such as "French capital" for "capital of France".
flowchart LR Q[Question] --> R[Retriever: find top k passages] C[(Collection of passages)] --> R R --> P[k passages] P --> RD[Reader: extract answer span] Q --> RD RD --> A[Answer with its passage]
The math
Given a question and a collection of passages , find a span inside some passage in that answers . The system is not given the passage in advance, so it must search first.
Step 2 in symbols: scoring passages
A retriever assigns each passage a score . In the word-overlap version, with the set of query words and the set of words in passage ,
The vertical bars mean the size of the set, so this is the number of shared words. In the example , and .
In the bi-encoder version, the score is the dot product of two embeddings,
where and are the query and passage encoders from the Bi-Encoder. Because depends only on , it is computed once for the whole collection.
Step 3 in symbols: the top- set
The retriever returns
When has millions of passages, finding these exactly is slow, so systems use approximate search over the vectors, which skips most passages and accepts a small chance of missing a good one.
Step 4 in symbols: scoring answer spans
A passage of words has a start score and an end score for each word position and , produced by the reader's network. A span from to with scores
The reader considers only spans with , because an answer cannot end before it starts.
Step 5 in symbols: choosing the answer
Over all retrieved passages and all valid spans, the answer is
Here means the argument that gives the largest value, and is the retrieval score of passage . The walkthrough compared reader scores alone and so left out. Example 3 adds it, as many systems do, so the passage's relevance counts as well as the span's fit. This is a maximum over a finite set, so no optimisation is needed at answer time.
Worked examples
Corpus: D1 = "Paris is the capital of France." D2 = "The Seine flows through Paris." D3 = "Berlin is the capital of Germany." Query: "capital of France". Score each passage and pick the top one.
- Query words: .
- D1 words include capital, of and france. Shared count: .
- D2 words are the, seine, flows, through, paris. Shared count: .
- D3 words include capital and of, but not france. Shared count: .
- Ranking: D1 with , then D3 with , then D2 with .
- Interpretation: the top passage is D1, and the reader will find "Paris" there. D2 is never useful for this query, and the index let us skip it entirely.
Suppose the query encoder gives and the passage encoder, applied in advance, gives for D1, for D2 and for D3. Find the scores and the top passage.
- Score D1: .
- Score D2: .
- Score D3: .
- Ranking: D1 at , D2 at , D3 at .
- Interpretation: the top passage is D1, the same as the word-overlap version. The vectors are fixed for the whole collection, so only the query needs encoding at search time.
A retriever returns the top three passages for the question "Who wrote Nineteen Eighty-Four?". Their retrieval scores are , and . The reader gives the best span in each passage a score, and the answer is the span with the highest reader score after adding the retrieval score in its passage.
- Passage A, retrieval score , best span "George Orwell" with reader score . Combined: .
- Passage B, retrieval score , best span "Orwell's essays" with reader score . Combined: .
- Passage C, retrieval score , best span "1949" with reader score . Combined: .
- The highest combined score is , from passage A. The answer is "George Orwell".
- Interpretation: passage C contains a true fact, the year of the book, but it answers a different question, so the reader score is lower. Passage B mentions the author but not the answer span, so its best span scores lower. Combining the two scores lets the system prefer the passage that is both relevant and answers the question.
Try it: suppose passage B's reader score rose to and nothing else changed. Which span becomes the answer, and why might this be a mistake?
Answer: , which beats , so "Orwell's essays" becomes the answer. It is a mistake because the span is not the author's name, so a higher reader score on a wrong span means the reader is answering a different question. This is why spans should be judged against the question, not only by how confident the reader is.
Common mistakes and tradeoffs
It is tempting to think that open-domain question answering is just keyword search. In fact the retriever only narrows the search. A passage can contain every query word and still not answer the question, so the reader has to check meaning, not word counts.
It is tempting to think that retrieving more passages always helps. In fact a larger raises the chance that the answer is in the set, but it also adds distractors and makes reading slower. The best is found by measuring answer accuracy on held-out questions.
It is tempting to think that a language model answers these questions without retrieval. In fact a model can answer from what it memorised during training, which is called closed-book answering. That method cannot be checked against a source, and it cannot use documents added after training. Open-domain systems keep the evidence visible.
When to use it: when the answer exists in a large text collection, the collection changes or is too large to memorise, and you need to show where the answer came from.
When not to use it: when the answer needs reasoning over many documents, or when the collection is small enough to read in full. Then a single long-context reader or a summary may be simpler.
Alternatives: word-overlap retrieval with TF-IDF is simple, cheap and strong on rare words, while dense retrieval captures meaning. A Cross-Encoder can rerank the short list with a more careful comparison, at a higher cost per passage.
History
Early question-answering systems in the 1960s and 1970s worked on small, hand-built databases, and their answers were limited to the stored facts. Retrieval-based systems for large text collections came out of information retrieval, where keyword indexes had been the standard tool for decades.
In 2017 the DrQA system combined a TF-IDF retriever with a neural reader and answered questions from Wikipedia, which made the two-stage design the standard approach. In 2020 Karpukhin and colleagues showed that a dense bi-encoder retriever, trained on question and passage pairs, could beat the word-overlap retriever on open-domain benchmarks, which made dense retrieval the default for new systems. The approach caught on because the retrieved passages give a checkable answer, which mattered as language models began to produce fluent but unsupported text.
Recap
- An open-domain question has its answer somewhere in a large collection, and the system does not know where.
- A retriever scores passages, using word overlap or embeddings with a dot product, and keeps the top .
- A reader scores answer spans in those passages with start and end scores, and the best span across passages is the answer.
- The two stages trade speed against accuracy: the retriever must be fast over millions of passages, and the reader must be accurate on a few.
- Read next: Retrieval-Augmented Generation, where a language model writes the answer from the retrieved passages, and the dense passage retrieval paper for the dense retriever in practice.
Check yourself
QuestionRecall: what are the two stages of an open-domain question answering system, and what does each one return?Show answer
The retriever searches the whole collection and returns a short list of likely passages. The reader looks at those passages and returns the answer span, usually with the passage it came from.
QuestionComputation: a query has the words . Passage P has the words and passage Q has . Using word overlap, which passage scores higher and by how much?Show answer
P shares and , so its score is . Q shares , so its score is . P scores higher, by .
QuestionWhy: why does a bi-encoder allow the passage vectors to be computed once, before any question arrives?Show answer
The score is the dot product of the query vector and the passage vector, and the passage vector depends only on the passage. Nothing inside the encoders couples the query and the passage, so every passage can be encoded in advance and stored, and only the query needs encoding at search time.
QuestionApplied: a support team finds that the system returns the right passage most of the time, but often shows a wrong span from it. They can change either the retriever or the reader. Which should they look at first, and why?Show answer
They should look at the reader, because the right passage is already being found. The error is in choosing the span, so the reader's scoring of spans, such as its start and end scores on a validation set of questions, is the place to start. Changing the retriever would not fix a wrong span inside a passage that was already correct.
Sources
- Karpukhin et al. (2020), Dense Passage Retrieval for Open-Domain Question Answering: arXiv:2004.04906
- Chen, Fisch, Weston, Bordes (2017), Reading Wikipedia to Answer Open-Domain Questions: arXiv:1704.00051
- Question answering: Wikipedia