Back to paper library
Paper notesarXiv 2019ICDAR Workshop 2019

FUNSD

Please Print in Block Letters

Original paper

FUNSD: A Dataset for Form Understanding in Noisy Scanned Documents

Paper authors

Guillaume Jaume · Hazim Kemal Ekenel · Jean-Philippe Thiran

Publication
ICDAR OST Workshop 2019Workshop
First submitted to arXiv
arXiv:1905.13538
Cite this paper · BibTeX

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

@misc{documentunderstandingfunsd2019,
  title = {{FUNSD: A Dataset for Form Understanding in Noisy Scanned Documents}},
  author = {Guillaume Jaume and Hazim Kemal Ekenel and Jean-Philippe Thiran},
  year = {2019},
  eprint = {1905.13538},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1905.13538}
}
On this page

Forms are probably the most common documents in the world. Registration forms, reimbursement claims, questionnaires, the front page of a medical record: the formats all differ, but the structure is much the same. A field name is printed, and a blank space is left beside or below it for someone to fill in a value.

Before 2019, commercial software took a very down-to-earth approach to pulling these values out of scanned forms. Products such as ABBYY and Nuance had users first draw regions on a specific page to tell the system "the answer will appear here." One kind of form, draw once; ten kinds, draw ten times. Once the templates pile up, it stops scaling.

Research wasn't much better off. OCR had ICDAR's competition data and layout analysis had its own datasets, but for "which words are field names, which are filled-in values, and how they pair up," there was no public, fully annotated set of real forms to practice on.

Guillaume Jaume and Jean-Philippe Thiran of EPFL's Signal Processing Laboratory, together with Hazım Kemal Ekenel of Istanbul Technical University, picked 199 forms out of a batch of old files from American tobacco companies, labeled them word by word, and named the result FUNSD.

199 forms sounds like very few. But over the next few years, a long line of document pretraining papers each put a FUNSD column in their results tables.

Defining the Problem

The authors define form understanding (abbreviated FoUn in the paper) as two steps.

The first is to look at the layout and the text and find which parts of a form are questions, which are answers and which are headers. The second is to work out how these pieces connect; the answer to the question "Registration No.," for example, is the "533" filled in next to it.

The difficulty is that forms have no fixed look. A field name and its value may sit side by side or one above the other; one field name may have several lines of answers under it; some fields are simply left blank. The authors themselves admit in their limitations section that there is "no exact definition of what a form is or how we should represent it."

Table understanding is a close relative, but a table's rows and columns are neatly aligned, and the mapping from headers to cells is fairly rigid. Forms have no such gridlines to lean on.

So before talking about any model, you first have to decide where the forms come from, how finely to label them, how to split up the tasks and how to score them.

Solving the Problem

Picking Forms from the Tobacco Companies' Files

The authors wanted real forms with real noise, so they started from RVL-CDIP.

RVL-CDIP is a classification dataset of 400,000 grayscale document images in 16 classes, one of which is called form. The images date from the 1980s and 1990s, at a resolution of only about 100 dpi, and repeated printing and scanning have left them with all kinds of noise. RVL-CDIP is itself a subset of the Truth Tobacco Industry Documents, an archive of scientific research, marketing and advertising documents from major American tobacco companies.

The authors went through the 25,000 images of the form class by hand, discarding the unreadable ones and the near-duplicates, which left 3,200 usable images; from these they randomly sampled 199 to annotate. The forms span different areas such as marketing, advertising and scientific reports, and every one of them is a single page.

Labeling from the Bottom Up

The annotation is stacked up layer by layer.

The bottom layer, the word boxes, went to crowdsourced annotators on Figure Eight. The layers above it used an annotation tool written specifically for form understanding, built on GuiZero (a Python GUI library on top of tkinter).

Each form is stored as one JSON file, and the form is represented as a list of semantic entities. An entity is a group of words that belong together semantically and spatially, with an ID, a class, a bounding box, links and the words it contains. There are only four classes: question, answer, header and other.

Take the example from the paper. The form has this line:

Original Figure 1: part of a FUNSD form, with "Registration No." printed on it and "533" written on the underline after it.
Original Figure 1, Jaume et al., from PDF page 3, arXiv license, scholarly quotation.

The corresponding annotation looks like this (excerpted from the paper's Listing 1):

json
{
  "form": [
    {
      "id": 0,
      "text": "Registration No.",
      "box": [94, 169, 191, 186],
      "linking": [[0, 1]],
      "label": "question",
      "words": [
        {"text": "Registration", "box": [94, 169, 168, 186]},
        {"text": "No.", "box": [170, 169, 191, 183]}
      ]
    },
    {
      "id": 1,
      "text": "533",
      "box": [209, 169, 236, 182],
      "linking": [[0, 1]],
      "label": "answer",
      "words": [{"text": "533", "box": [209, 169, 236, 182]}]
    }
  ]
}

The box format is [left, top, right, bottom]. A link is a directed [source id, target id]; here [0, 1] points from question 0 to answer 1. The same link is recorded on both entities, so both carry [[0, 1]].

This structure lets one dataset serve several purposes. Look only at the word boxes and text, and it's data for text detection and OCR; look at how the words are grouped into entities, and it's layout analysis data; look at the classes and links, and only then is it form understanding data.

The overall size of the dataset (compiled from Tables I and II of the paper):

SplitFormsWordsEntitiesRelations
Train14922,5127,4114,236
Test508,9732,3321,076

The entities broken down by class:

Splitheaderquestionanswerother
Train4413,2662,802902
Test1221,077821312

Only 199 forms, yet over 30,000 words and nearly 10,000 entities. Computing from the public data files, a form has about 49 entities on average and an entity 3 to 4 words, and the busiest form has 181 entities. Counting forms alone underestimates how dense the data is.

Five Tasks, Five Ways to Score

The authors break the work around form understanding into a pipeline: detect the words, recognize the text, group the words into entities, give the entities classes, and finally find the links between entities. Each step gets its own scoring method.

Text detection is done at the word level: an IoU above 0.5 counts as a detection, and precision, recall and F1 are computed. Some systems output quadrilaterals while FUNSD labels rectangles, so the smallest rectangle enclosing the four vertices is used.

OCR is scored with Levenshtein similarity, comparing the predicted string wpw_p with the ground truth wgtw_{gt}:

S(wp,wgt)=1−L(wp,wgt)max⁡(∣wp∣,∣wgt∣)S(w_p, w_{gt}) = 1 - \frac{L(w_p, w_{gt})}{\max(|w_p|, |w_{gt}|)}

LL is the edit distance and ∣⋅∣|\cdot| the number of characters. Reading "Registration" as "Registratlon," for example, gets one character wrong out of 12, so the similarity is 1−1/12≈0.9171 - 1/12 \approx 0.917. The similarity is case-sensitive and also counts checkbox recognition.

There are two normalizations. "Detection + OCR" divides by the total number of ground-truth words, so undetected words score zero; "OCR" divides only by the number of detected words, looking at recognition on its own.

Word grouping is treated as a clustering problem, with words as data points and entities as clusters. The score is the adjusted Rand index (ARI), which checks whether every pair of words is correctly judged as "belonging in the same cluster or not," then subtracts what random clustering would get right anyway, so 0 is random and 1 is perfect. Undetected words are put into one artificial cluster.

Entity labeling is four-way classification, scored by F1. Entity linking checks, only among entities that have already been correctly found and correctly classified, whether each predicted link exists, and then computes precision, recall and F1.

The figure below shows a form after grouping and labeling:

Original Figure 2: a "SPECIAL EVENT INFORMATION SHEET" form with a box around every word. Orange marks headers (SPECIAL EVENT INFORMATION SHEET, GENERAL INFORMATION:, HOURS:), blue marks questions (EVENT NAME:, EVENT LOCATION:, EVENT DATES:, MONDAY-FRIDAY:, SATURDAY-SUNDAY:), and green marks answers (The USO Spring Festival, 42nd - 57th Street, New York, NY, June 3, 1995, 11am - 6pm).
Original Figure 2, Jaume et al., from PDF page 4, arXiv license, scholarly quotation.

Each small box is one word, and connected words of the same color make up an entity. "EVENT NAME:" is a question, and "The USO Spring Festival" is its answer. Nothing follows "MONDAY-FRIDAY:"; fields nobody filled in like this one show up too, as questions without any link.

Discussion

How Weak the Baselines Are

Most of the authors' baselines are off-the-shelf tools. The point isn't to chase scores but to draw a starting line for each task.

Here are the text detection results (%, with F1 as a decimal):

MethodRetrainedPrecisionRecallF1
TesseractNo45.468.00.54
EASTNo51.684.00.64
Google VisionNo79.862.00.69
Faster R-CNNYes70.484.80.76

Faster R-CNN uses ResNet-101 with ImageNet initialization, anchors from 16 to 256 pixels and aspect ratios from 0.5 to 8, and it's the one retrained on FUNSD, so its top F1 is no surprise. Google Vision had never seen this data and still reaches an F1 of 0.69.

The OCR gap is even wider. On correctly detected words, Google Vision's Levenshtein similarity reaches 94.4%, or 76.4% counting the undetected ones. Tesseract manages only 7.3% and 3.4%, a near-total wipeout; the authors explain that Tesseract needs images of at least 300 dpi, while FUNSD is only around 100 dpi.

Word grouping just takes the text lines cut out by the two OCR engines as the groups, giving an ARI of 0.20 for Tesseract and 0.41 for Google Vision. Text lines and semantic entities were never the same thing; a single line may hold both a question and an answer.

The entity labeling baseline is more of a model. Each entity's feature concatenates three parts, semantic features extracted by BERT, spatial features from the box coordinates and meta features recording length, for 733 dimensions in all. These go into an MLP with two layers of 500 units each, and a final softmax sorts them into four classes. Note that this assumes grouping, positions and text are all perfectly correct, so only this one step is evaluated. F1 is 0.57.

Entity linking fares worst. The authors concatenate the features of every pair of entities and feed them into an MLP of the same size to decide whether a link exists. The result is a precision of 2.1%, a recall of 99.2% and an F1 of 0.04.

With recall near 100% and precision at only 2%, this classifier seems to answer "yes" for almost every pair. Computing from the public data, the 50 test forms hold about 69,000 entity pairs in all, and only about 1.5% of them are actually linked. With pairs this sparse, concatenating two feature vectors and forcing a classification doesn't let the model learn much.

Here the authors leave one line: "Stronger baselines should include the relational side of semantic entities that can naturally be represented as a graph." Earlier that same year, researchers at Alibaba had already treated text boxes as nodes and used graph convolution to extract information from receipts and invoices.

199 Forms Holding Up a Generation of Pretrained Models

FUNSD's most common later use is the one LayoutLM established at the end of 2019.

LayoutLM recast the task as word-level sequence labeling, tagging each word as the beginning, inside or end of an entity of some class, or as a single-word entity, and then computing F1. In this setting BERT-base scores 0.603, LayoutLM-base with 2D position pretraining reaches 0.7866, and adding image features brings it to 0.7927. With only 149 training forms, the authors used it precisely to show that pretraining pays off most when data is scarce.

As for linking, the LayoutLM paper says outright that it is "out of the scope" and does labeling only. Later, in the main results tables of LayoutLMv2 and LayoutLMv3, the FUNSD column likewise covers labeling only.

The following year, LayoutLMv2's large version pushed the score to 0.8420, against 0.7895 for the LayoutLM-large in its own comparison table. Then, in 2022, LayoutLMv3 reached 90.29 with base and 92.08 with large.

These numbers can't be lined up against the 0.57 in the FUNSD paper. The original paper assumes the grouping is known and only classifies ready-made entities; the LayoutLM series has the model carve out the entities itself from per-word labels, doing grouping and classification together.

For the jump from the 80s into the 90s, the LayoutLMv3 paper attaches an explanation of its own. LayoutLMv3 and StructuralLM use segment-level positions, meaning the words in one text segment share a single bounding box, and "using segment-level positions may benefit the semantic entity labeling task on FUNSD," so they aren't directly comparable with work that uses word-level positions.

Why would it help? For that we have to go back to how FUNSD is annotated.

Problems in the Labels

A FUNSD entity box is simply the bounding box of a block. When the model's input has "the words of one segment share one box," and FUNSD's "segments" happen to be its "entities," every word in an entity has exactly the same coordinates. The input has already quietly told the model where each entity's boundaries are.

In 2024, researchers from Fudan University, Nankai University and Ant Group put a number on this. They reorganized FUNSD into EC-FUNSD, labeling segments (the text lines an OCR engine would output) and entities (semantic entities) separately. With the same models and training settings, LayoutLMv3-base's entity labeling F1 fell from 90.85 on FUNSD (their own rerun) to 82.30, large from 91.70 to 83.88, and GeoLayoutLM from 91.10 to 83.62.

A more direct experiment was run on the original FUNSD. The model is fine-tuned as usual with segment-level boxes, but at inference it gets only word-level boxes, and LayoutLMv3-base's F1 plunges from 90.85 to 22.75. If both fine-tuning and testing use only word-level boxes, the score is 81.06. (so part of that 90 was the boxes sitting the exam for it)

Errors in the labels themselves have been dug up one after another as well. In 2020, Vu and Nguyen of Vietnam National University, setting out to use FUNSD for key-value detection, found:

  • Wrong OCR text and wrong word boxes.
  • Inconsistent entity granularity: sometimes a whole block, sometimes a line, sometimes a single word, and occasionally one word split into several.
  • Some relations that don't follow the logic of the others and look like slips of the hand.
  • header is sometimes really a heading and sometimes used to express chains of relations more than two levels deep; a Lorillard logo on one form was also labeled header.

In their revision, only the last entity of each relation chain counts as answer; every other entity on the chain becomes question, and anything not in any relation becomes other. They also admit that while fixing relations they fixed text and boxes along the way, but can't promise that nothing slipped through.

In 2024, RFUND from South China University of Technology relabeled the data from another angle. Real OCR engines output text line by line, but FUNSD is labeled at the block level; in multi-line entities with a first-line indent, the first line is cut out on its own and the rest merged into one block, which produces redundant links. RFUND switched to line-level labels, removed these redundant links, and fixed some classes that made no sense, such as "CONFIDENTIAL" labeled as a question.

In addition, LayoutXLM's XFUND followed FUNSD's labeling scheme to build forms in seven languages, Chinese, Japanese, Spanish, French, Italian, German and Portuguese, while Konfuzio's FUNSD+ expanded the dataset to 1,113 documents and fixed the labeling inconsistencies mentioned above.

License

One last practical point. The terms of use on the FUNSD website state that the dataset may be used only for non-commercial research and educational purposes; the images carry their own copyright, the originals belong to RVL-CDIP, and users have to check for themselves what other permissions they need.

Using it for research and comparing models is fine. If you want to train a form extraction system that will go into production and charge money, you'll have to find other data.

Conclusion

FUNSD proposes no new method; its baselines are mostly off-the-shelf tools, and the linking task's F1 is just 0.04. What it left behind is a way of carving up the problem into five steps, word detection, recognition, grouping, labeling and linking, each with its own data fields and scoring, and the later multilingual XFUND was labeled the same way.

It's also a very small test set. Its 50 forms and 2,332 entities later carried the rankings of a whole generation of document pretraining models; scores climbed past 90, and part of that came from the input boxes happening to coincide with the labeled blocks.

Next time you see a paper report a score in the 90s on FUNSD, flip to the experimental setup first and check whether it feeds the model word boxes or whole-block boxes.