Back to paper library
Paper notesarXiv 2020WACV 2021

DocVQA

Points for a Typo?

Original paper

DocVQA: A Dataset for VQA on Document Images

Paper authors

Minesh Mathew · Dimosthenis Karatzas · C. V. Jawahar

Publication
WACV 2021Conference
First submitted to arXiv
arXiv:2007.00398
Cite this paper · BibTeX

The citation identifies the linked source version. It cites the original paper and its authors.

@misc{documentunderstandingdocvqa2020,
  title = {{DocVQA: A Dataset for VQA on Document Images}},
  author = {Minesh Mathew and Dimosthenis Karatzas and C. V. Jawahar},
  year = {2020},
  eprint = {2007.00398},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2007.00398}
}
On this page

Document analysis research was carved up into many pieces early on. Some people did character recognition, some did table extraction, some did key-value pairing. Each piece had its own datasets and scores, but what the extracted information would eventually be used for was usually none of these modules' concern.

Minesh Mathew and C.V. Jawahar of IIIT Hyderabad in India, together with Dimosthenis Karatzas of the Computer Vision Center (CVC) at the Autonomous University of Barcelona in Spain, asked the question a different way. They put questions directly to a document image and checked whether a system could answer them.

Only the year before, Karatzas and Jawahar had helped build ST-VQA, a question-answering dataset about the text in street-scene photos. This time they carried the same idea over to documents and built DocVQA.

Defining the Problem

Ordinary VQA asks questions like "how many dogs are in the picture," and the answer is usually picked from a fixed vocabulary. Scene-text VQA (ST-VQA, TextVQA) started requiring models to read the text in an image, but a street photo usually holds only a dozen or so words.

Documents are different. A single page easily has hundreds of words, handwritten, typed and printed, plus tables, forms, checkboxes, dividing lines, charts and photos. To answer a question, reading the words isn't enough; you also have to know where each word is, which column it belongs to, and which row it lines up with.

Here is the example at the start of the paper:

Original Figure 1: a scanned envelope, with a round "ROCKFORD, IL, 23 SEP 1970" postmark at the top left, stamps and a wavy cancellation at the top right, a handwritten "Sales" in the middle, and the handwritten address "Great Western Sugar Co. Denver, Colo. 80202" below it. Three question-answer pairs are listed underneath: the zip code is 80202; the date of the postmark on the letter is 23 sep 1970; asked which company's address is on the letter, the answer is Great western sugar Co.
Original Figure 1, Mathew et al., from PDF page 1, arXiv license, scholarly quotation.

Three questions, three kinds of difficulty. The zip code is handwritten; the postmark is a circle with the place name running around its edge and the date squeezed into the middle; the company name has to be read from the first line of the address, which means knowing how an envelope address is written.

Before DocVQA, every VQA dataset with any connection to documents handled just one kind of thing. DVQA and FigureQA are programmatically synthesized charts with template-generated questions; OCR-VQA has over a million questions about book covers, also generated from templates. No dataset asked open-ended questions about real, varied documents.

Solving the Problem

Picking Pages from an Industry Documents Library

The images come from the Industry Documents Library at the University of California, San Francisco (UCSF). The library was first set up to hold the huge volume of documents made public in the 1990s tobacco litigation, and it later added internal documents from the drug, chemical, food and fossil fuel industries, organized by industry and collection.

The authors downloaded documents from different collections and then picked pages by hand, with two preferences.

First, avoid binarized images where possible. Many documents in the library had been converted to pure black and white, damaging their quality, and the authors didn't want poor image quality to become the bottleneck for answering questions.

Second, prefer pages with tables, forms, lists and figures, and pick fewer pages that are nothing but running text.

The final images come from 6,071 documents dated from 1900 to 2018, mostly between 1960 and 2000. They cover five industries, tobacco, food, drugs, fossil fuels and chemicals, with food and nutrition used especially heavily because that collection has more images that were never binarized.

Three-Stage Annotation

Remote annotators created the questions and answers with a web tool, in three stages.

  1. Writing questions: an annotator looks at a document and writes up to 10 question-answer pairs. Each question must be answerable from the text in the image, and each answer must be copied verbatim from the document. If a question has several reasonable answers, annotators are encouraged to write more than one correct answer.
  2. Verification: another annotator sees only the image and the question, not the first-stage answer, answers it independently, and tags the question type. Questions that read badly or are ambiguous can be flagged, and flagged questions are dropped.
  3. Review: if none of the answers from the first and second stages match exactly, the question goes to the authors themselves, who can edit the question and answer and accept them, or simply throw them out.

Since answers must come verbatim from the document, DocVQA is extractive question answering, the same kind as SQuAD in NLP. In other words, it's an open-book exam. The answer is always written somewhere on the paper, and the hard part is finding it and reading it right.

Fifty Thousand Questions, Nine Question Types

The final data is 50,000 questions on 12,767 images, randomly split 80/10/10 into training, validation and test sets:

SplitQuestionsImages
Train39,46310,194
Val5,3491,286
Test5,1881,287

The second stage tags nine question types, and a question can belong to several at once:

Original Figure 3: a bar chart of question counts for the nine question types. layout has the most, close to 18,000 questions; table/list about 16,000; form about 14,000; running text about 5,400; handwritten about 2,900; other and figure just over a thousand each; photograph and yes/no only a few hundred.
Original Figure 3, Mathew et al., from PDF page 3, arXiv license, scholarly quotation.

layout questions need the layout to find the answer, such as asking for a title or the date in a page header. form covers key-value information, table/list means reading a table or list, running text has its answer in paragraph text, and handwritten has a handwritten answer. Charts, photos and yes/no questions are all rare.

The questions and answers in this data have a few obvious traits.

  • Questions average 8.12 words, many start with "what is the," and they ask about dates, titles, totals, amounts and names. The most common questions are about page numbers and dates.
  • Answers average only 2.17 words, and the most common answers are almost all numbers.
  • Each image has 182.75 OCR tokens on average. A SQuAD 1.1 paragraph averages 117.23, and VQA-style datasets average no more than 13.

So this is a dataset with lots of text, short answers, and questions that keep circling around numbers.

Partial Credit with ANLS

The most direct way to score is accuracy, where a prediction counts only if it exactly matches one of the correct answers. The problem is that OCR can't be perfect, and a model that found the right spot but scores zero because one character was misread isn't being treated quite fairly.

The authors adopt ANLS (Average Normalized Levenshtein Similarity), proposed earlier for ST-VQA, as the main metric. For question ii, suppose there are MM correct answers aija_{ij} and the model's answer is oqio_{q_i}:

ANLS=1N∑i=1Nmax⁡j s(aij,oqi)\mathrm{ANLS} = \frac{1}{N} \sum_{i=1}^{N} \max_{j} \, s(a_{ij}, o_{q_i}) s(aij,oqi)={1−dijif dij<τ0otherwises(a_{ij}, o_{q_i}) = \begin{cases} 1 - d_{ij} & \text{if } d_{ij} < \tau \\ 0 & \text{otherwise} \end{cases}

dij=NL(aij,oqi)d_{ij} = \mathrm{NL}(a_{ij}, o_{q_i}) is the normalized Levenshtein distance, that is, the edit distance divided by the length of the longer of the two strings, which falls between 0 and 1. The threshold τ=0.5\tau = 0.5 means that once the distance reaches half or more, the model is taken to have picked the wrong text rather than misread the right text, and it gets 0 outright. Each question takes the highest score against all its correct answers, and the result is averaged over all NN questions. According to the Robust Reading Competition's evaluation notes, the comparison ignores case, but spaces count.

Here are a few worked examples using answers that actually appear in the paper (all lowercased first):

CorrectPredictedEditsNLScore
$35,864$35 , 86420.220.78
dr. william j. darbydr. william j. darry10.050.95
1/7/771 / 730.500
802028020310.200.80

The first row is a BERT model's answer from the appendix. The number is right, with just two extra spaces, so accuracy gives 0 and ANLS gives 0.78. The second row is a human volunteer's answer with one wrong letter, which earns 0.95. The third row is the "1 / 7" a model gave after OCR chopped the date into pieces; its NL is exactly 0.5, not below the threshold, so it scores 0.

The fourth row is an example made up for this note. The zip code on the envelope at the start is 80202; if a model answers 80203, ANLS gives it 0.8. The letter goes to the wrong address, and the score still looks pretty good. This leniency is a deliberate design choice, but as we'll see later, it comes at a cost.

Discussion

Random Guesses and Upper Bounds

First, the lines that need no training (test-set numbers from Table 1 of the paper):

MethodANLSAccuracy (%)
Human0.98194.36
Random training-set answer0.0030.00
Random OCR token0.0140.58
Longest OCR token0.0030.07
Most common training answer0.0170.89
Upper bound (answer in vocab)–33.78
Upper bound (OCR substring)–87.00
Upper bound (OCR token subsequence)–77.00

The human score comes from volunteers at the authors' institutions, who answered every question in the test set.

Random guessing stays under 1% accuracy across the board, as expected. The three upper bounds carry more information.

The "vocabulary" upper bound assumes the model can only choose from the 4,341 answers that appear more than once in the training set; at best it gets 33.78% right. In other words, if you treat document QA as a classification problem, the ceiling is very low.

The "OCR" upper bounds string the words read by a commercial OCR engine into one long sequence from top-left to bottom-right and check whether the correct answer is a piece of it. The substring upper bound is 87%, but it overestimates, because the most common answer, "2," can match the 2 inside "2020"; switch to subsequences at the token level and 77% remain. In other words, even if a model picks perfectly from the OCR output, for over a fifth of the questions the correct answer simply isn't in the OCR output, or OCR has broken it apart.

Bringing Over Scene-Text VQA Models

The authors first tried two representative scene-text VQA models, using the official implementations in the MMF framework and the original papers' hyperparameters.

LoRRA uses attention to weight image features and OCR tokens, then picks an answer from a fixed vocabulary or copies an OCR token from the image. It can copy only one token at a time, so it can't produce answers made of several words.

M4C uses a multimodal Transformer that puts the question, objects and OCR tokens in one space where they attend to each other, then emits the answer autoregressively, step by step, each step either copying an OCR token or choosing a word from a vocabulary of common words.

On the test set, LoRRA with its original settings gets an ANLS of 0.112, and M4C with its original settings 0.306.

Both models got an ablation that removes the object-detection features standard in ordinary VQA (objects detected by a Faster R-CNN trained on Visual Genome). LoRRA drops from 0.112 to 0.100, while M4C actually rises from 0.306 to 0.310. Documents have no cats, dogs or cars, so these features have nothing to work with.

After removing the object features, raising the number of OCR tokens M4C considers per image from 50 to 500 lifts its ANLS to 0.391, with 24.81% accuracy, the best result on the VQA-model side. LoRRA dips slightly with more OCR tokens, to 0.095 at 500.

Treating the Document as a Reading Test

The other route is reading comprehension from NLP. A BERT question-answering model takes a passage and a question and outputs the start and end positions of the answer in the passage.

A document image first has to become text. The authors string the OCR tokens together from top-left to bottom-right into a single string, then, following TriviaQA, take the first occurrence of the correct answer in that string as the answer span for training.

Results (test set):

ModelTuned on DocVQAANLSAccuracy (%)
bert-baseYes0.57447.60
bert-largeYes0.61051.08
bert-large-squadNo0.47538.26
bert-large-squadYes0.66555.77

bert-large-squad is a model already fine-tuned on SQuAD 1.1. Without any training on DocVQA, it gets an ANLS of 0.475, above every VQA model; fine-tuned further, it reaches 0.665, the best in the paper.

This result is a little awkward. A model that never sees the image and only reads a flattened string of text beat the VQA models designed specifically to "read text in images." It is still a long way from the human 0.981, though.

Which Questions Are Hardest

Original Figure 7: three qualitative examples. Left: a table with an underlined heading, "INDICATIONS FOR IMPLANTATION," above it; asked what the underlined heading is, M4C and the human answer correctly, while BERT answers total aneurism. Middle: a business expense voucher; asked for the Extension Number, the correct answer is (910) 741-0673, which BERT and the human get right, while M4C answers 963.12. Right: a diagram of tanker truck unloading steps; asked how many boxed illustrations there are, the correct answer is 9, and both models answer 4.
Original Figure 7, Mathew et al., from PDF page 8, arXiv license, scholarly quotation.

On the left is a layout question whose answer is the underlined heading above the table. M4C's input includes the coordinates of every OCR token, and it gets this one right; BERT reads the flattened text and grabs "total aneurism" from inside the table.

In the middle is a form question asking for the extension number on the voucher. BERT copies the whole phone number correctly from after "Extension Number"; M4C copies an amount from another field.

The one on the right asks how many boxed illustrations there are. The correct answer is 9, and both models say 4. This is no longer a reading problem.

Broken down by question type, the differences get clearer:

Original Figure 8: ANLS by question type for the best BERT model, the best M4C model and humans. Humans are close to 1 in every type. BERT scores about 0.7 to 0.75 on form, running text and layout, and about 0.35 to 0.45 on figure, photograph, handwritten and yes/no. M4C is around 0.39 overall and comes close to BERT only on handwritten.
Original Figure 8, Mathew et al., from PDF page 8, arXiv license, scholarly quotation.

Humans are above 0.97 in every type, with little variation. BERT does best on form, running text and layout, where the answer is right there in the text, at roughly 0.7 to 0.75; on figure, photograph and handwritten it falls to around 0.35 to 0.45. On handwritten questions, M4C and BERT are about even. The authors write in the caption, "We need models which can understand figures and text on photographs better. We need better handwriting recognizers too!"

The appendix has one more example that shows the problem well. On the same table, one question asks for the number of committee members at the first meeting and another for the number at the last meeting. The correct answers are 6 and 5, and both models answer 6 to both. The models found the table but didn't tell first from last.

What Came After

DocVQA quickly became the standard exam for document understanding.

From March to May 2020, the authors ran a challenge at a CVPR 2020 workshop. Nine teams took part, and the winner's ANLS was 0.85, almost 0.19 above the paper's best baseline of 0.665. LayoutLMv2 went further at the end of 2020: its large version reached 0.8348 with the training set alone, and 0.8672 after adding the validation set and an extra set of generated questions. Donut took another route, dropping OCR altogether and generating answers straight from the image.

The CVC and IIIT group went on to build InfographicVQA (infographics) and MP-DocVQA (multi-page documents), pushing the exam toward harder questions.

The original DocVQA, meanwhile, has gradually been maxed out. Researchers from Carnegie Mellon University and J.P. Morgan noted in a 2025 paper that, as of January 2025, the top of the DocVQA leaderboard was less than 2 points short of human performance. They also pointed out that ANLS looks only at surface similarity and ignores whether the answer's type and meaning are right. If the correct answer is one number and the model answers a different number, it still scores as long as enough characters overlap, just like the zip code answered as 80203 still earning 0.8.

Conclusion

DocVQA pulled document understanding out of a pile of extraction tasks that each went their own way and turned it into something anyone can understand. Give it a page, ask a question. Its three-stage annotation, its nine question types and that 87% OCR upper bound showed later research where the problems lie, and its baselines showed that the best models of 2020 still trailed humans by more than 0.3 ANLS.

ANLS is one reason this dataset caught on so widely, and it's also the part that needs the most care. It is lenient toward small OCR mistakes, and just as lenient toward answers that are wrong but look very similar.

When you evaluate a system that reads invoice amounts or zip codes, compute exact-match accuracy alongside ANLS. A zip code that is off by one digit still earns 0.8, and the package still gets lost.