Upgrade to Pro — share decks privately, control downloads, hide ads and more …

【論文紹介】DocTr_ Document Transformer for Structured Information Extraction in Documents / iccv2023-doctr

Yuya Matsumura
November 05, 2023

【論文紹介】DocTr_ Document Transformer for Structured Information Extraction in Documents / iccv2023-doctr

2023年11月05日 ICCV2023論文読み会(https://kantocv.connpass.com/event/297737/) における発表資料です。

以下の論文について概要を紹介しました。
DocTr: Document Transformer for Structured Information Extraction in Documents
https://openaccess.thecvf.com/content/ICCV2023/html/Liao_DocTr_Document_Transformer_for_Structured_Information_Extraction_in_Documents_ICCV_2023_paper.html

Yuya Matsumura

November 05, 2023
Tweet

More Decks by Yuya Matsumura

Other Decks in Science

Transcript

  1. © 2023 LayerX Inc. 【論文紹介】DocTr: Document Transformer for Structured Information

    Extraction in Documents 2023/11/04 第60回 コンピュータビジョン勉強会@関東 / ICCV2023論文読み会 Yuya Matsumura(@yu-ya4) https://openaccess.thecvf.com/content/ICCV2023/html/Liao_DocTr_Document_Transformer_for_Struct ured_Information_Extraction_in_Documents_ICCV_2023_paper.html
  2. © 2023 LayerX Inc. 2 バクラク事業部 Data&ML部 ML Group マネージャー

    経歴 京都大学大学院情報学研究科修士課程修了。情報検索や情報推薦に関する研究に取り 組む。 2018年ウォンテッドリー株式会社に新卒入社。レコメンドチームの立ち上げに携わる。 その後、機械学習領域のテックリード、プロダクトマネージャー、エンジニアリングマネー ジャーを務める。 2022年9月に株式会社LayerXに入社。機械学習チームにて、法人支出管理SaaSバ クラクのAI-OCR機能をはじめとする機械学習を活用した機能の開発およびマネジメ ントに従事。 その他活動として、ウォンテッドリー株式会社の機械学習領域の技術顧問やスタート アップの技術支援、大学の非常勤講師、書籍の執筆など。 画像を入れてね 自己紹介 松村 優也(Yuya Matsumura) @yu__ya4
  3. © 2023 LayerX Inc. 3 ドキュメントからentityとrelationshipを抽出 structured information extraction(SIE) from

    documents background • entity: “name”を表す“CHOCOLATE MILK SHAKE”、“cnt”を表す“1”、“price”を表す “22,000” • relationship: 上記3つのentityは関連する1つの グループ • これらはテキストの内容だけではなく、ドキュメント内 のレイアウト、図や表などによって決定される。 • 請求書や領収書など様々なドキュメントが画像やPDF で保存されており、未だに人手で構造化情報が抽出さ れている。これを自動で正確に実現することには意義 がある。 Figure 1
  4. © 2023 LayerX Inc. 4 IOB taggingベースの手法: LayoutLM, FormNet SIEへの主要なアプローチとその課題

    background Figure 1 • OCRで出力されるテキストが意味的に“正しい”語順で ない場合が存在する。 • (a)I-nameとE-nameの間にS-priceが存在。 • nameが複数ある場合など、それぞれがどのnameの entityに属するのか判定するのが困難。 グラフベースの手法: BROS, SPADE • (b)ドキュメント内には多くの単語(node)があり、複 雑なグラフになりうり、正確に再現するのが困難。 (Xu et al., 2020)(Xu et al., 2021) (Lee et al., 2022) (Hong et al., 2022) (Hwang et al., 2021)
  5. © 2023 LayerX Inc. 5 新しい形でのSIEの定式化 提案手法概要 approach Figure 1

    • (c)entityをアンカーワード(色付き単語)をもとにbbox (色付きbbox)とclass(nameなど)を推論する形で抽出 (後ほど説明) → OCR出力の語順に依存しないように • relationshipをアンカーワード間の関連(赤矢印)のみで 定義 → シンプルなグラフで表現可能に DOCument TRansformer(DocTr) • ドキュメント画像とOCR出力(text+bbox)の両方を扱う Masked Detection Modeling(MDM) • 本問題に適した新しい事前学習タスクの提案
  6. © 2023 LayerX Inc. 6 新しい形でのSIEの定式化:entityの抽出(entity extraction) approach Figure 2

    • まず最初に文書全体からアンカーワード(色付き単語)を特定。 ◦ ここではentityの先頭の単語と定義した上で学習している。wordごとに推論。 • アンカーワードごとにclassラベルとbboxを推論(破線矢印)。 ◦ アンカーワードのbboxではなく、entity全体を囲むbboxを推論する。 • 推論したbboxに含まれるテキストをそのentityのテキストとする。 ◦ class label cとbbox bを使って、entityはe=(c, b)と表現できる。
  7. © 2023 LayerX Inc. 7 新しい形でのSIEの定式化:relationshipの推論(entity linking) approach Figure 2

    • entityのグループは1つのprimary entityとそれ以外のsecondary entityから成り立つと定義 ◦ それぞれのアンカーワードをprimary/secondaryアンカーワードと呼ぶ ◦ entityどうしを関連づけてグループを作るのは、アンカーワードどうしを関連づけるのと等価 • どのアンカーワードをprimaryとするかは様々だが、key-value形式ならばkeyを、line item形式 ならnameが妥当か。 • アンカーワードごとにprimaryかsecondaryか、およびどのprimaryとsecondaryが関連するのか を推論
  8. © 2023 LayerX Inc. 8 マルチモーダルなencoder-decoder構造 DOCument TRansformer(DocTr): Overview approach

    Figure 3 • 画像情報(文書画像)と言語情報(OCRされたテキスト とbbox)の両方を入力として受け入れる。 • それぞれから特徴を獲得するための独立した2つの encoder(vision encoder, language encoder) • アンカーワードをもとにentity extraction(EE)と entity linking(EL)を行うための vision-language decoder
  9. © 2023 LayerX Inc. 9 Deformable DETRのencoderを参考に設計 DOCument TRansformer(DocTr): Vision

    Encoder approach Figure 3 • 文書画像をCNN(ResNet50)に通した後、 deformable transfomer encoder(6-layer)で encoding • 一般的なtransformerベースのvision encoderと 比較し効率的なattention • E2Eの物体検出におけるtransformerベースの decoderと相性が良いことが報告されている。 (Zhu et al., 2020) (Carion et al., 2020)
  10. © 2023 LayerX Inc. 10 BERTおよびLayoutLMを参考に設計 DOCument TRansformer(DocTr): Language Encoder

    approach Figure 3 • BERT-base(12-layer)がベース • LayoutLM同様、OCRの結果(text+bbox)をもと に2D position embeddingを付与 (Devlin et al., 2019) (Xu et al., 2020)
  11. © 2023 LayerX Inc. 11 DOCument TRansformer(DocTr): Vision-Language Decoder approach

    Figure 3 • Deformable DETRのdecoder(6-layer) がベース • language-conditioned queriesの導入 ◦ 入力単語と同じ数のqueryを用意し、そ れぞれにlanguage encoderと同じ position embeddingを利用。 ◦ i番目の入力(word+bbox)とi番目の queryを対応させる。 • vision encoderとlanguage encoderの 出力それぞれをdecodeするための2つの attention Deformable DETRのdecoderを参考に設計 (Zhu et al., 2020) Figure 9
  12. © 2023 LayerX Inc. 12 DOCument TRansformer(DocTr): 出力(EE and EL)

    approach • アンカーワードと推定した入力に対し、class labelおよび(entity全体の)bboxを出力 ◦ アンカーワード以外は出力しない(no anchor) Entity Extraction(EE) Figure 3 • アンカーワードがprimaryかsecondaryかの binaryおよびprimaryとsecondaryがリンク するかを判定するためのembeddingを出力 Entity Linking(EL)
  13. © 2023 LayerX Inc. 13 学習時の損失関数 approach Entity Linking(EL) Entity

    Extraction(EE) アンカーワード以 外を除く bbox loss (Carion et al., 2020) class labelにつ いてのロス primaryか secondaryか リンクが繋がって いるかどうか
  14. © 2023 LayerX Inc. 14 事前学習タスク:Masked Detection Modeling(MDM) approach textもbboxも両方maskする事前学習タスク

    Figure 4 • (a)masked language modeling(MLM)は textのみを入力とし、textをmaskする。 • (b)masked vision-language modeing(MVLM)はtextとbboxが入力さ れ、textのみがmaskされる。 • (c)masked detection modeling(MDM) はtextとbboxが入力され、textとbboxの両 方がmaskされる。 ◦ 文書画像はそのまま入力されるので、画像 をうまく使えるようになる気持ち。
  15. © 2023 LayerX Inc. 15 3つのデータセット experiment • IIT-CDIP ◦

    11 millionのラベルなしドキュメントデータ ◦ 事前学習に利用 • CORD ◦ 1000枚のラベル付きレシートデータ • FUNSD ◦ 200枚の様々なラベル付きフォームデータ
  16. © 2023 LayerX Inc. 16 3つのタスク experiment Figure 5 •

    receipt parsing ◦ 要するに一番やりたいこと。EE+EL ◦ (a)の例では2つのline itemと1組の key-valueを推論する必要がある。 • entity labeling ◦ 入力単語ごとにclass labelを推論。 • entity linking ◦ 推論されたkeyとvalueをうまく紐付けられ るか。
  17. © 2023 LayerX Inc. 17 既存モデルとの比較(receipt parsing) results • LayoutLMv2,3やDonut,

    Spadeなど既存モ デルをこえる性能を確認 • OCRの出力するテキストに対してIOB tagging を利用する既存手法について、今回提案された SIEの定式化を学習に利用したものでも検証し、提 案するDocTrの方が高い性能であることを確認
  18. © 2023 LayerX Inc. 18 既存モデルとの比較(entity linking, entity labeling) results

    • ともに概ね既存手法を大きく超える実験結果 • entity labelingについては、よりパラメタ数の 大きい既存手法と比較しても遜色ない結果
  19. © 2023 LayerX Inc. 19 Ablation Study: SIEの定式方法 results •

    (a)IOB tagging: DocTrをIOB taggingで学習 • (b)SPADE: DocTrのdecoderにSPADEと同様のものを利用して学習 • (c)提案手法 ともに提案手法の方が高い結果に。
  20. © 2023 LayerX Inc. 20 Ablation Study: テキストの入力順 results •

    raster scan: デフォルト • oracle: 正解のentity内のテキストの順番が崩れないように並び替え ともに提案手法が高い結果、かつ、oracle→raster scanの変更時の性能劣化が小さい(-0.6pt.)
  21. © 2023 LayerX Inc. 21 Ablation Study: 事前学習 results •

    事前学習時のタスクを変更して実験。 ◦ 提案手法が上回る • MDM利用時の出力例 ◦ bboxをマスクしても、値とともにほ ぼ推論できている様子が見える。
  22. © 2023 LayerX Inc. 22 Ablation Study: モデルアーキテクチャ results •

    画像情報を利用する重要性や、language conditioned queries(LCQ)の有効性を確認。 • VL-decoderを利用する場合は、LCQを使わなければ大きく性能が悪化する。
  23. © 2023 LayerX Inc. 23 新しい形でのSIEの定式化 structured information extraction(SIE) において以下を

    提案し、既存手法と比較した上で有効性を示す Summary • entityのアンカーワードを推論した上で、対応するbboxとclass labelを推論する形でentityを抽出 • relationshipをアンカーワード間のみで推論 DOCument TRansformer(DocTr) • ドキュメント画像とOCR出力(text+bbox)の両方を扱うマルチモーダルなencoder-decoderモデル • 独立した2つ(visionおよびlanguage)のencoderと、vision-language decoder • 入力と対応するクエリを明示的に紐づけるためのlanguage-conditioned queries Masked Detection Modeling(MDM) • OCR入力(text+bbox)に対して、textとbboxの両方をmaskする事前学習手法
  24. © 2023 LayerX Inc. 24 ❏ (Xu et al., 2020)Yiheng

    Xu, Minghao Li, Lei Cui, Shaohan Huang, Furu Wei, and Ming Zhou. Layoutlm: Pre-training of text and layout 19593 for document image understanding. In Proceedings of the 26th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, pages 1192–1200, 2020. ❏ (Xu et al., 2021)Yang Xu, Yiheng Xu, Tengchao Lv, Lei Cui, Furu Wei, Guoxin Wang, Yijuan Lu, Dinei Florencio, Cha Zhang, Wanxiang Che, et al. Layoutlmv2: Multi-modal pre-training for visually-rich document understanding. In Proceedings of the 59th Annual Meeting of the Association for Computational Linguistics and the 11th International Joint Conference on Natural Language Processing (Volume 1: Long Papers), pages 2579–2591, 2021. ❏ (Lee et al., 2022)Chen-Yu Lee, Chun-Liang Li, Timothy Dozat, Vincent Perot, Guolong Su, Nan Hua, Joshua Ainslie, Renshen Wang, Yasuhisa Fujii, and Tomas Pfister. Formnet: Structural encoding beyond sequential modeling in form document information extraction. In Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pages 3735–3754, 2022. ❏ (Hong et al., 2022)Teakgyu Hong, Donghyun Kim, Mingi Ji, Wonseok Hwang, Daehyun Nam, and Sungrae Park. Bros: A pre-trained language model focusing on text and layout for better key information extraction from documents. In Proceedings of the AAAI Conference on Artificial Intelligence, pages 10767– 10775, 2022. ❏ (Hwang et al., 2021)Wonseok Hwang, Jinyeong Yim, Seunghyun Park, SoheeYang, and Minjoon Seo. Spatial dependency parsing for semistructured document information extraction. In Findings of the Association for Computational Linguistics: ACL-IJCNLP 2021, pages 330–343, 2021 ❏ (Zhu et al., 2020)Xizhou Zhu, Weijie Su, Lewei Lu, Bin Li, Xiaogang Wang, and Jifeng Dai. Deformable detr: Deformable transformers for end-to-end object detection. In International Conference on Learning Representations, 2020 ❏ (Carion et al., 2020)Nicolas Carion, Francisco Massa, Gabriel Synnaeve, Nicolas Usunier, Alexander Kirillov, and Sergey Zagoruyko. End-to-end object detection with transformers. In European conference on computer vision, pages 213–229. Springer, 2020. ❏ (Devlin et al., 2019)Jacob Devlin, Ming-Wei Chang, Kenton Lee, and Kristina Toutanova. BERT: pre-training of deep bidirectional transformers for language understanding. In Jill Burstein, Christy Doran, and Thamar Solorio, editors, Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, NAACL-HLT 2019, Minneapolis, MN, USA, June 2-7, 2019, Volume 1 (Long and Short Papers), pages 4171–4186. Association for Computational Linguistics, 2019. Ref