Graph Convolution for Multimodal Information Extraction from Visually Rich Documents
- Publication
- NAACL Industry Track 2019Conference
- First submitted to arXiv
- arXiv:1903.11279
Cite this paper · BibTeX
The citation identifies the linked source version. It cites the original paper and its authors.
@misc{documentunderstandinggcnvrd2019,
title = {{Graph Convolution for Multimodal Information Extraction from Visually Rich Documents}},
author = {Xiaojing Liu and Feiyu Gao and Qiong Zhang and Huasha Zhao},
year = {2019},
eprint = {1903.11279},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1903.11279}
}
Panel (b) below is a Chinese general VAT invoice photographed with a phone. The enlarged area holds three amounts: "¥160.19," "¥4.81" and "(小写)¥165.00," where 小写 marks the amount written in numerals.

Which one is the tax amount?
A person would do the arithmetic: 160.19 plus 4.81 is exactly 165.00, so 4.81 is the tax. A model doesn't calculate like that. To it, the three strings look exactly alike, each a yuan sign followed by a number. The paper says bluntly that there is "a lack of any textual context to determine which one is tax amount," so all that's left is where the text sits on the page relative to everything else. The tax and the pre-tax amount are squeezed into the same row, while the total sits alone on the next row, with "小写" hanging in front of it.
The four authors of this paper are from Alibaba. Around the same time, SAP's Chargrid laid documents out as a grid of characters for a convolutional network; this paper takes a different road, treating each text segment cut out by OCR as a node and connecting the nodes into a graph. In the related work, the authors make a point of mentioning Chargrid and say the difference is that this paper uses a graph network whose unit is the text segment rather than the character.
Defining the Problem
The paper calls documents like these visually rich documents (VRD): receipts, insurance policies, customs declarations and so on. Half of their meaning is written in the text and half in the layout.
The traditional approach is templates. For each kind of document you write down "the tax is in row such-and-such, column such-and-such" and fetch it by coordinates. The authors argue this can't hold up in real business. For receipts alone there are thousands of vendors on the market, each with a different format, and every new template has to be checked so it doesn't clash with the existing rules. Even with a nationally standardized format like the VAT invoice, the photos users upload are often skewed or blurry and catch other objects in the frame, so fixed coordinates soon stop lining up.
The other approach is to hand the text to a sequence labeling model such as BiLSTM-CRF. It does very well at named entity recognition on plain text, but it consumes a one-dimensional sequence. In a sequence, those three amounts keep nothing but their order; who shares a row with whom and who sits right below whom are no longer visible.
What the authors want lies between the two. Keep BiLSTM-CRF, a mature sequence labeler, but before it reads each text segment, tell it "who is around you, how far away they are, and what shape they have."
Solving the Problem
The Document Becomes a Graph
The first step is building the graph. Alibaba's in-house OCR system first cuts the document into text segments, each with a box and the string inside it; "¥4.81," for example, is one segment. Each segment is a node, and every pair of nodes is linked by directed edges, making a fully connected graph.
A document has about 100 to 300 text segments. Fully connected, that means each graph convolution layer has to handle roughly 10,000 to 90,000 node pairs.
Nodes Handle Text, Edges Handle Position
Each node's initial feature is the vector a single BiLSTM layer produces after reading through that segment's text.
The edge features are the core of this paper, made up of five numbers:
They are:
- , : the horizontal and vertical distances between the two boxes.
- : the aspect ratio of the source segment itself.
- , : the height and width of the target segment, both divided by the source's height.
Walk through it with "¥4.81" as the source . The edge to "¥160.19" has a large horizontal distance and a vertical distance near 0, because they're in the same row; the two segments have about the same text height, so is close to 1; "¥160.19" is longer, so is a bit larger than "¥4.81"'s own aspect ratio. The edge to "¥165.00" is different: its vertical distance is clearly not 0, because the total is on the next row.
The authors give two reasons. Related information usually sits close together, such as a field name and its value; and the shape of a text segment carries meaning too, since an address segment, for example, is usually longer than the buyer's name. Note that these features are directional: looking at from and looking at from use different divisors, so they come out different.
In the paper's words, "node embedding encodes textual features, while edge embedding primarily represents visual features."
Graph Convolution: Three Things at a Time

Read this figure from left to right. On the left are and its five neighbors. Ordinary graph convolution aggregates only the neighbors' node features; this paper defines the convolution on "node, edge, node" triplets. and each neighbor , together with the edge between them, are concatenated into one long vector and fed to an MLP:
is concatenation. You can think of as "what neighbor looks like from where stands."
Why put itself in as well? The authors explain that this way every neighbor message carries information about the center node, so a neighbor's features can decide whether they deserve attention depending on "who is looking right now." The same "¥160.19" is an important same-row neighbor for "¥4.81," but may be irrelevant to the invoice number far away at the top of the page.
Next, attention takes a weighted sum of the five messages to produce the new node representation:
is a single weight vector shared by all nodes; it turns each message into a score , which softmax then normalizes. This is very much like GAT, except that GAT's scores come from the features of two nodes, while here they come from , which already has the edge features mixed in. The authors chose LeakyReLU to keep ReLU from chopping every negative value to 0, and to spread the attention coefficients further apart.
The edges are updated as well, . The new node and edge representations go into the next graph convolution layer, which repeats the same computation. In the experiments, two layers worked best.
Back to BiLSTM-CRF
After graph convolution, each text segment has a graph embedding with the surrounding text and positions mixed in. From here it goes to a standard BiLSTM-CRF:

Suppose the -th text segment has tokens . Each token's input is
looks up Word2Vec word vectors. Every token in the segment gets the same graph embedding attached, then passes through the BiLSTM and a fully connected layer, and finally the CRF outputs IOB tags such as B-Tax, I-Tax and O.
One point of this design is easy to miss. The BiLSTM runs only inside a single text segment, so all information across segments comes from that graph embedding. In other words, whether "¥4.81" gets tagged as tax depends entirely on whether graph convolution has packed "there's a larger amount to the left in the same row, and a total marked 小写 on the next row" into .
Graph convolution and BiLSTM-CRF are trained together end to end. The authors also add an auxiliary task that sends each segment's graph embedding to a sigmoid classifier to predict directly which class the segment belongs to. The two tasks share the graph convolution parameters, and the loss weights are set automatically with Kendall et al.'s method of weighting by task uncertainty.
Matching Labels to OCR
Annotators draw entity boxes on the image, while OCR cuts out text-segment boxes, and the two will never overlap exactly. The authors use a simple rule to decide which segment an entity belongs to:
The denominator takes the smaller of the two boxes. If OCR cuts a whole row into one segment while the annotation box covers just one amount in it, the overlap area divided by the annotation box's area is still close to 1, so the segment claims the entity. The threshold is set by hand, and the paper doesn't give its value. Once matched, the tokens in a segment are tagged in IOB format, and segments without any entity are tagged O throughout.
Discussion
Data and Baselines
Both datasets are real business data:
- VATI (VAT invoices): 3,000 photos uploaded by users, in Chinese, with 16 entities such as the buyer and seller names, date and tax amount. The format is nationally standardized and the template fixed, but the photos come with skew and distracting objects.
- IPR (international purchase receipts): 1,500 scanned receipts, in English, with 4 entities (invoice number, vendor name, payer name, total amount) across 146 templates.
Both are split 70% for training, 15% for validation and 15% for testing, and the metric is F1.
The baselines are two ways of turning the text into a sequence:
- Baseline I: each text segment is treated as a sentence of its own and run through BiLSTM-CRF separately, with no view of any other segment.
- Baseline II: following CloudScan, the whole document is joined left to right and top to bottom into one long string, then run through BiLSTM-CRF. At least it has one-dimensional context.
Main Results
| Model | VATI | IPR |
|---|---|---|
| Baseline I | 0.745 | 0.747 |
| Baseline II | 0.854 | 0.820 |
| BiLSTM-CRF + GCN | 0.873 | 0.836 |
Compiled from Table 1 of the paper, F1.
Graph convolution beats Baseline II by 1.9 and 1.6 points on the two datasets. Broken down by entity on VATI, the difference is clearer:
| Entity | Baseline I | Baseline II | + GCN |
|---|---|---|---|
| Invoice number | 0.952 | 0.961 | 0.975 |
| Date | 0.962 | 0.963 | 0.963 |
| Price | 0.527 | 0.910 | 0.943 |
| Tax | 0.584 | 0.902 | 0.924 |
| Buyer | 0.402 | 0.797 | 0.833 |
| Seller | 0.681 | 0.731 | 0.782 |
Compiled from Table 2 of the paper, F1 on the VATI dataset.
On invoice number and date, the three models are almost identical. These two strings are easy to recognize on their own, a fixed-length run of digits and a date format, with no need to look around.
Price and tax are the question from the opening. Baseline I sees only the text "¥4.81," and its F1 is just 0.584; Baseline II strings the whole document together, the order itself gives away a good deal of position information, and it jumps straight to 0.902; graph convolution adds another 2.2 points on top. Buyer and seller follow a similar trend, with seller improving the most, from 0.731 to 0.782.
Set this against the table in Chargrid and you'll see the sequence baseline is much stronger here. Chargrid's line-item fields repeat row after row, and once flattened there's no telling which goes with which; most of this paper's entities appear only once per document, so stringing them together in reading order already keeps most of the clues. The two papers have different tasks, and the ceilings for sequence models differ accordingly.
Ablation: Edges Matter More Than Attention
| Setting | VATI | IPR |
|---|---|---|
| Full model | 0.873 | 0.836 |
| No visual features (edges) | 0.808 | 0.775 |
| No text features (nodes) | 0.871 | 0.817 |
| No attention | 0.872 | 0.821 |
Compiled from Table 3 of the paper, F1.
Remove the edge features and both datasets drop by more than 6 points, more than graph convolution's entire gain over Baseline II. The remaining 0.808 and 0.775 even lose to Baseline II, which merely strings the document together. Without position information, this graph does worse than a one-dimensional sequence.
Remove the nodes' text features and VATI drops only 0.2, IPR 1.9. That's not hard to understand, since the tokens' Word2Vec vectors go straight into BiLSTM-CRF anyway, so the text information still gets in from the other end.
What attention does depends on whether the layout is fixed. On VATI, with its fixed template, removing attention makes almost no difference; on IPR, with 146 templates, attention contributes 1.5 points. When the authors pulled out the attention weights, the two datasets looked very different.
- On VATI, no matter which segment is looking, attention concentrates on the same fixed segment, one carrying address information with strong text features. The authors speculate that the model is looking for the document's "anchor." Every invoice shares one template, so once you find an anchor, the positions of all the other fields follow.
- On IPR, with its varied layouts, attention goes to nearby text segments, with neighbors to the left and above weighted more heavily; segments containing field keywords such as "address," "amount" and "name" also get higher weights.
The latter is really how people read forms. Field names are usually written to the left of or above their values; when you see a number, you look left and up for its label first.
How Many Layers Are Enough
| Entity | 1 layer | 2 layers | 3 layers |
|---|---|---|---|
| Invoice number | 0.959 | 0.975 | 0.964 |
| Date | 0.960 | 0.963 | 0.960 |
| Price | 0.931 | 0.943 | 0.931 |
| Tax | 0.915 | 0.924 | 0.917 |
| Buyer | 0.829 | 0.833 | 0.827 |
| Seller | 0.772 | 0.782 | 0.775 |
Compiled from Table 4 of the paper, F1 on the VATI dataset.
Every entity does best with two layers, and three layers regress across the board, which the authors attribute to overfitting. In a fully connected graph, a single layer already sees every node; the second layer lets each node look again at its neighbors' updated representations. Stacking further mostly adds parameters while bringing few new sources of information; that part is this note's conjecture. The authors also say frankly that the best number of layers should be decided automatically for each task, and they leave that to future work.
Auxiliary Task
Adding the auxiliary task of segment classification lifts VATI from 0.873 to 0.881 and IPR from 0.836 to 0.849, and the authors mention that training also converges much faster. These are actually the best numbers in the whole paper.
If You Want to Reproduce It
This is an industry paper, and its limitations are industry limitations too. Both datasets are Alibaba's internal business data and not public; the text segments come from Alibaba's in-house OCR; the label-alignment threshold is some "manually set" number; hidden size, optimizer, learning rate, number of epochs: the paper reports none of them (you even have to guess how wide the BiLSTM is). No official code turns up online either.
The cost of the fully connected graph goes unexplained as well. With 100 to 300 text segments per document, each layer runs the MLP once for each of 10,000-plus triplets, and the paper only says attention can be computed in parallel across node pairs, without a single speed or memory figure. It's also a pity that the authors spend a paragraph of the related work explaining how they differ from Chargrid, yet the experiments never compare against it.
Conclusion
To sum up:
- The unit is the text segment, and the structure is a fully connected graph. Nodes read text with a BiLSTM, edges record relative position and shape with five numbers, graph convolution computes on "node, edge, node" triplets, and the result is attached to every token and handed to BiLSTM-CRF.
- Position information carries most of the gain. Removing the edge features costs more than 6 points; removing attention has almost no effect on a fixed template.
- Stringing the whole document together in order is already a strong baseline. On these two datasets, Baseline II gets 0.854 and 0.820, and graph convolution adds 1.6 to 1.9 points on top, concentrated in fields such as price, tax, buyer and seller that only position can tell apart.
If your task is also pulling a few non-repeating fields out of forms, first string the documents together and run a sequence model as a baseline. See whether the remaining errors cluster in fields that "look identical and can only be told apart by position," and then decide whether to bring in a graph.
This idea of "relative position between every pair" didn't go away, either. Two years later, LayoutLMv2 added learnable biases to the Transformer's self-attention scores according to the horizontal and vertical relative positions of each pair of tokens. It's the same kind of idea as this paper's edge features, minus the need to build a separate graph.