Skip to main content

PosFormer: Recognizing Complex Handwritten Mathematical Expression with Position Forest Transformer

  • Conference paper
  • First Online:
Computer Vision – ECCV 2024 (ECCV 2024)

Part of the book series: Lecture Notes in Computer Science ((LNCS,volume 15080))

Included in the following conference series:

  • 662 Accesses

Abstract

Handwritten Mathematical Expression Recognition (HMER) has wide applications in human-machine interaction scenarios, such as digitized education and automated offices. Recently, sequence-based models with encoder-decoder architectures have been commonly adopted to address this task by directly predicting LaTeX sequences of expression images. However, these methods only implicitly learn the syntax rules provided by LaTeX, which may fail to describe the position and hierarchical relationship between symbols due to complex structural relations and diverse handwriting styles. To overcome this challenge, we propose a position forest transformer (PosFormer) for HMER, which jointly optimizes two tasks: expression recognition and position recognition, to explicitly enable position-aware symbol feature representation learning. Specifically, we first design a position forest that models the mathematical expression as a forest structure and parses the relative position relationships between symbols. Without requiring extra annotations, each symbol is assigned a position identifier in the forest to denote its relative spatial position. Second, we propose an implicit attention correction module to accurately capture attention for HMER in the sequence-based decoder architecture. Extensive experiments validate the superiority of PosFormer, which consistently outperforms the state-of-the-art methods 2.03%/1.22%/2.00%, 1.83%, and 4.62% gains on the single-line CROHME 2014/2016/2019, multi-line M\(^{2}\)E, and complex MNE datasets, respectively, with no additional latency or computational cost.

T. Guan and C. Lin—Equal contribution.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

References

  1. Anderson, R.H.: Syntax-directed recognition of hand-printed two-dimensional mathematics. In: Symposium on Interactive Systems for Experimental Applied Mathematics: Proceedings of the Association for Computing Machinery Inc. Symposium, pp. 436–459 (1967)

    Google Scholar 

  2. Bian, X., Qin, B., Xin, X., Li, J., Su, X., Wang, Y.: Handwritten mathematical expression recognition via attention aggregation based bi-directional mutual learning. In: AAAI, vol. 36, pp. 113–121 (2022)

    Google Scholar 

  3. Chan, K.F., Yeung, D.Y.: Elastic structural matching for online handwritten alphanumeric character recognition. In: ICPR, vol. 2, pp. 1508–1511 (1998)

    Google Scholar 

  4. Chan, K.F., Yeung, D.Y.: Mathematical expression recognition: a survey. IJDAR 3, 3–15 (2000)

    Article  Google Scholar 

  5. Chen, Z., Han, J., Yang, C., Zhou, Y.: Language model is suitable for correction of handwritten mathematical expressions recognition. In: Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 4057–4068 (2023)

    Google Scholar 

  6. Deng, Y., Kanervisto, A., Ling, J., Rush, A.M.: Image-to-markup generation with coarse-to-fine attention. In: ICML, pp. 980–989 (2017)

    Google Scholar 

  7. Ding, H., Chen, K., Huo, Q.: An encoder-decoder approach to handwritten mathematical expression recognition with multi-head attention and stacked decoder. In: ICDAR, pp. 602–616 (2021)

    Google Scholar 

  8. Guan, T., et al.: Industrial scene text detection with refined feature-attentive network. IEEE TCSVT 32(9), 6073–6085 (2022)

    Google Scholar 

  9. Guan, T., et al.: Self-supervised implicit glyph attention for text recognition. In: CVPR, pp. 15285–15294 (2023)

    Google Scholar 

  10. Guan, T., Shen, W., Yang, X., Feng, Q., Jiang, Z., Yang, X.: Self-supervised character-to-character distillation for text recognition. In: ICCV, pp. 19473–19484 (2023)

    Google Scholar 

  11. Guan, T., Shen, W., Yang, X., Wang, X., Yang, X.: Bridging synthetic and real worlds for pre-training scene text detectors. arXiv preprint arXiv:2312.05286 (2023)

  12. Hu, L., Zanibbi, R.: HMM-based recognition of online handwritten mathematical symbols using segmental K-means initialization and a modified pen-up/down feature. In: ICDAR, pp. 457–462 (2011)

    Google Scholar 

  13. Huang, G., Liu, Z., Van Der Maaten, L., Weinberger, K.Q.: Densely connected convolutional networks. In: CVPR, pp. 4700–4708 (2017)

    Google Scholar 

  14. Keshari, B., Watt, S.: Hybrid mathematical symbol recognition using support vector machines. In: ICDAR, vol. 2, pp. 859–863 (2007)

    Google Scholar 

  15. Kosmala, A., Rigoll, G., Lavirotte, S., Pottier, L.: On-line handwritten formula recognition using hidden Markov models and context dependent graph grammars. In: ICDAR, pp. 107–110 (1999)

    Google Scholar 

  16. Le, A.D.: Recognizing handwritten mathematical expressions via paired dual loss attention network and printed mathematical expressions. In: CVPRW, pp. 566–567 (2020)

    Google Scholar 

  17. Le, A.D., Indurkhya, B., Nakagawa, M.: Pattern generation strategies for improving recognition of handwritten mathematical expressions. Pattern Recogn. Lett. 128, 255–262 (2019)

    Article  Google Scholar 

  18. Li, B., et al.: When counting meets HMER: counting-aware network for handwritten mathematical expression recognition. In: Avidan, S., Brostow, G., Cissé, M., Farinella, G.M., Hassner, T. (eds.) Computer Vision – ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXVIII, pp. 197–214. Springer Nature Switzerland, Cham (2022). https://doi.org/10.1007/978-3-031-19815-1_12

    Chapter  Google Scholar 

  19. Li, Z., Jin, L., Lai, S., Zhu, Y.: Improving attention-based handwritten mathematical expression recognition with scale augmentation and drop attention. In: ICFHR, pp. 175–180 (2020)

    Google Scholar 

  20. Li, Z., Yang, W., Qi, H., Jin, L., Huang, Y., Ding, K.: A tree-based model with branch parallel decoding for handwritten mathematical expression recognition. Pattern Recognit. 149, 110220 (2024)

    Google Scholar 

  21. Liu, Y., et al.: Roberta: a robustly optimized BERT pretraining approach. arXiv preprint arXiv:1907.11692 (2019)

  22. Mahdavi, M., Zanibbi, R., Mouchere, H., Viard-Gaudin, C., Garain, U.: ICDAR 2019 CROHME+ TFD: competition on recognition of handwritten mathematical expressions and typeset formula detection. In: ICDAR, pp. 1533–1538 (2019)

    Google Scholar 

  23. Mouchere, H., Viard-Gaudin, C., Zanibbi, R., Garain, U.: ICFHR 2014 competition on recognition of on-line handwritten mathematical expressions (CROHME 2014). In: ICFHR, pp. 791–796 (2014)

    Google Scholar 

  24. Mouchère, H., Viard-Gaudin, C., Zanibbi, R., Garain, U.: ICFHR2016 CROHME: competition on recognition of online handwritten mathematical expressions. In: ICFHR, pp. 607–612 (2016)

    Google Scholar 

  25. Shi, B., Bai, X., Yao, C.: An end-to-end trainable neural network for image-based sequence recognition and its application to scene text recognition. IEEE TPAMI 39(11), 2298–2304 (2016)

    Article  Google Scholar 

  26. Truong, T.N., Nguyen, C.T., Phan, K.M., Nakagawa, M.: Improvement of end-to-end offline handwritten mathematical expression recognition by weakly supervised learning. In: ICFHR, pp. 181–186 (2020)

    Google Scholar 

  27. Vaswani, A., et al.: Attention is all you need. In: NeurIPS, vol. 30 (2017)

    Google Scholar 

  28. Vuong, B.Q., He, Y., Hui, S.C.: Towards a web-based progressive handwriting recognition environment for mathematical problem solving. Expert Syst. Appl. 37(1), 886–893 (2010)

    Article  Google Scholar 

  29. Wang, J., Du, J., Zhang, J., Wang, Z.R.: Multi-modal attention network for handwritten mathematical expression recognition. In: ICDAR, pp. 1181–1186 (2019)

    Google Scholar 

  30. Winkler, H.J.: HMM-based handwritten symbol recognition using on-line and off-line features. In: ICASSP, vol. 6, pp. 3438–3441 (1996)

    Google Scholar 

  31. Wu, C., et al.: TDv2: a novel tree-structured decoder for offline mathematical expression recognition. In: AAAI, vol. 36, pp. 2694–2702 (2022)

    Google Scholar 

  32. Wu, J.W., Yin, F., Zhang, Y.M., Zhang, X.Y., Liu, C.L.: Handwritten mathematical expression recognition via paired adversarial learning. IJCV 128, 2386–2401 (2020)

    Article  MathSciNet  Google Scholar 

  33. Wu, J.W., Yin, F., Zhang, Y.M., Zhang, X.Y., Liu, C.L.: Graph-to-graph: towards accurate and interpretable online handwritten mathematical expression recognition. In: AAAI, vol. 35, pp. 2925–2933 (2021)

    Google Scholar 

  34. Yang, W., Li, Z., Peng, D., Jin, L., He, M., Yao, C.: Read ten lines at one glance: line-aware semi-autoregressive transformer for multi-line handwritten mathematical expression recognition. In: ACM MM, pp. 2066–2077 (2023)

    Google Scholar 

  35. Yuan, Y., et al.: Syntax-aware network for handwritten mathematical expression recognition. In: CVPR, pp. 4553–4562 (2022)

    Google Scholar 

  36. Yue, X., Kuang, Z., Lin, C., Sun, H., Zhang, W.: RobustScanner: dynamically enhancing positional clues for robust text recognition. In: Vedaldi, A., Bischof, H., Brox, T., Frahm, J.-M. (eds.) ECCV 2020. LNCS, vol. 12364, pp. 135–151. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-58529-7_9

    Chapter  Google Scholar 

  37. Zhang, J., Du, J., Dai, L.: Multi-scale attention with dense encoder for handwritten mathematical expression recognition. In: ICPR, pp. 2245–2250 (2018)

    Google Scholar 

  38. Zhang, J., Du, J., Dai, L.: Track, attend, and parse (tap): An end-to-end framework for online handwritten mathematical expression recognition. IEEE TMM 21(1), 221–233 (2018)

    Google Scholar 

  39. Zhang, J., Du, J., Yang, Y., Song, Y.Z., Dai, L.: SRD: a tree structure based decoder for online handwritten mathematical expression recognition. IEEE TMM 23, 2471–2480 (2021)

    Google Scholar 

  40. Zhang, J., Du, J., Yang, Y., Song, Y.Z., Wei, S., Dai, L.: A tree-structured decoder for image-to-markup generation. In: ICML, pp. 11076–11085 (2020)

    Google Scholar 

  41. Zhang, J., et al.: Watch, attend and parse: an end-to-end neural network based approach to handwritten mathematical expression recognition. Pattern Recognit. 71, 196–206 (2017)

    Google Scholar 

  42. Zhang, T., Mouchere, H., Viard-Gaudin, C.: Tree-based BLSTM for mathematical expression recognition. In: ICDAR, vol. 1, pp. 914–919 (2017)

    Google Scholar 

  43. Zhao, W., Gao, L.: CoMER: modeling coverage for transformer-based handwritten mathematical expression recognition. In: Avidan, S., Brostow, G., Cissé, M., Farinella, G.M., Hassner, T. (eds.) Computer Vision – ECCV 2022: 17th European Conference, Tel Aviv, Israel, October 23–27, 2022, Proceedings, Part XXVIII, pp. 392–408. Springer Nature Switzerland, Cham (2022). https://doi.org/10.1007/978-3-031-19815-1_23

    Chapter  Google Scholar 

  44. Zhao, W., Gao, L., Yan, Z., Peng, S., Du, L., Zhang, Z.: Handwritten mathematical expression recognition with bidirectionally trained transformer. In: ICDAR, pp. 570–584 (2021)

    Google Scholar 

  45. Zhong, S., Song, S., Li, G., Chan, S.H.G.: A tree-based structure-aware transformer decoder for image-to-markup generation. In: ACM MM, pp. 5751-5760 (2022)

    Google Scholar 

Download references

Acknowledgment

This work was supported by the NSFC under Grant 62176159 and 62322604, and in part by the Shanghai Municipal Science and Technology Major Project under Grant 2021SHZDZX0102. The computations in this paper were run on the AI for Science Platform supported by the Artificial Intelligence Institute at Shanghai Jiao Tong University.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Wei Shen .

Editor information

Editors and Affiliations

1 Electronic supplementary material

Below is the link to the electronic supplementary material.

Supplementary material 1 (pdf 453 KB)

Rights and permissions

Reprints and permissions

Copyright information

© 2025 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Guan, T., Lin, C., Shen, W., Yang, X. (2025). PosFormer: Recognizing Complex Handwritten Mathematical Expression with Position Forest Transformer. In: Leonardis, A., Ricci, E., Roth, S., Russakovsky, O., Sattler, T., Varol, G. (eds) Computer Vision – ECCV 2024. ECCV 2024. Lecture Notes in Computer Science, vol 15080. Springer, Cham. https://doi.org/10.1007/978-3-031-72670-5_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-72670-5_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-72669-9

  • Online ISBN: 978-3-031-72670-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics