在文档理解任务中,目前的主流方案普遍使用端到端的多模态大语言模型。但是,此类方法对图片的输入分辨率有很高的要求,因此需要较强的视觉基座。这也成为了多模态大语言模型(MLLM)在文档理解任务中的瓶颈。文档理解作为text-rich的任务,实际发挥作用的信息大部分都来自于文字语义及其相对的布局信息。因此,利用成熟的OCR技术获得文字和布局(Layout)信息(即:文字坐标)并轻量级地扩展LLM,使其能够根据语义以及Layout信息来做预测。该方案也是解决文档理解的一条可行道路[1],即Layouts as “Lightweight Visual Information”。
近期,DocLLM[3]首次提出在LLM的基础上加入布局信息的文档理解方案,将正则化后的数值型坐标作为布局信息,并引入解耦的空间注意力机制,促进文本与布局模态之间的交叉对齐。该方案经过有监督微调(SFT)能够在VQA任务上取得与OCR-free的MLLM相当的性能。此外,得益于融入的布局信息,该方案在KIE任务上提升明显,有效解决了生成式模型在KIE任务上的短板。但是,该方案采用的MLM(Masked Language Model)训练方式使得预训练阶段未能与SFT阶段的任务较好的对齐,因此其SFT后的模型性能也仅能与MLLM的Zero-shot性能相当。
预训练(Layout-aware Next Token Prediction)
参考传统LLM的语言模型预训练,本文采用自回归方式预测整个输入的序列。不同于此前的预训练过程,提出的Layout-aware Next Token Prediction预训练方式当遇到需预测坐标占位符的Token时(下图中的"b"),不计算相应Token的损失。在预训练阶段,LLM参数被冻结,仅优化Layout Projector和新增的P-LoRA参数。得益于所提出的Self-supervised的预训练方式,预训练数据非常容易获得。
图2 LayTextLLM预训练方式比较
微调(Shuffled-OCR Supervised Fine-tuning)
现有LLM使用的主流位置编码Rotatory Embedding往往倾向于使得在序列上越接近的Token,越容易获得更大的Attention Score。因此,在图3的例子中,如果提问"What is the value of the field Change?"(蓝色框),模型很容易识别出正确结果"1.30",因为它在序列中紧挨“Change”一词。然而,对于一个更具挑战性的问题,如"What is the value of the field Total(RM)? "(红色框),由于"Total(RM)"后有多个紧跟输入的数字文本Token,模型很难确定正确的答案。
[1] Wang, D., Raman, N., Sibue, M., Ma, Z., Babkin, P., Kaur, S., Pei, Y., Nourbakhsh, A. and Liu, X., 2023. DocLLM: A layout-aware generative language model for multimodal document understanding. arXiv preprint arXiv:2401.00908.
[2] Xu, Y., Li, M., Cui, L., Huang, S., Wei, F. and Zhou, M., 2020, August. Layoutlm: Pre-training of text and layout for document image understanding. In Proceedings of the 26th ACM SIGKDD international conference on knowledge discovery & data mining (pp. 1192-1200).
[3] Wang, D., Raman, N., Sibue, M., Ma, Z., Babkin, P., Kaur, S., Pei, Y., Nourbakhsh, A. and Liu, X., 2023. DocLLM: A layout-aware generative language model for multimodal document understanding. arXiv preprint arXiv:2401.00908.
[4] Perot, V., Kang, K., Luisier, F., Su, G., Sun, X., Boppana, R.S., Wang, Z., Mu, J., Zhang, H. and Hua, N., 2023. LMDX: Language Model-based Document Information Extraction and Localization. arXiv preprint arXiv:2309.10952.
[5] He, J., Wang, L., Hu, Y., Liu, N., Liu, H., Xu, X. and Shen, H.T., 2023. ICL-D3IE: In-context learning with diverse demonstrations updating for document information extraction. In Proceedings of the IEEE/CVF International Conference on Computer Vision (pp. 19485-19494)
.