Skip to main content

Extracting Weighted Finite Automata from Recurrent Neural Networks for Natural Languages

  • Conference paper
  • First Online:
Formal Methods and Software Engineering (ICFEM 2022)

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

Included in the following conference series:

  • 668 Accesses

Abstract

Recurrent Neural Networks (RNNs) have achieved tremendous success in sequential data processing. However, it is quite challenging to interpret and verify RNNs’ behaviors directly. To this end, many efforts have been made to extract finite automata from RNNs. Existing approaches such as exact learning are effective in extracting finite-state models to characterize the state dynamics of RNNs for formal languages, but are limited in the scalability to process natural languages. Compositional approaches that are scablable to natural languages fall short in extraction precision. In this paper, we identify the transition sparsity problem that heavily impacts the extraction precision. To address this problem, we propose a transition rule extraction approach, which is scalable to natural language processing models and effective in improving extraction precision. Specifically, we propose an empirical method to complement the missing rules in the transition diagram. In addition, we further adjust the transition matrices to enhance the context-aware ability of the extracted weighted finite automaton (WFA). Finally, we propose two data augmentation tactics to track more dynamic behaviors of the target RNN. Experiments on two popular natural language datasets show that our method can extract WFA from RNN for natural language processing with better precision than existing approaches. Our code is available at https://github.com/weizeming/Extract_WFA_from_RNN_for_NL.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

References

  1. Abdel-Hamid, O., Mohamed, A.R., Jiang, H., Deng, L., Penn, G., Yu, D.: Convolutional neural networks for speech recognition. IEEE/ACM Trans. Audio Speech Lang. Process. 22(10), 1533–1545 (2014)

    Article  Google Scholar 

  2. Angluin, D.: Learning regular sets from queries and counterexamples. Inf. Comput. 75(2), 87–106 (1987)

    Article  MATH  Google Scholar 

  3. Baier, C., Katoen, J.P.: Principles of Model Checking. MIT press (2008)

    Google Scholar 

  4. Cechin, A.L., Regina, D., Simon, P., Stertz, K.: State automata extraction from recurrent neural nets using k-means and fuzzy clustering. In: 23rd International Conference of the Chilean Computer Science Society, 2003. SCCC 2003. Proceedings, pp. 73–78. IEEE (2003)

    Google Scholar 

  5. Che, Z., Purushotham, S., Cho, K., Sontag, D., Liu, Y.: Recurrent neural networks for multivariate time series with missing values. Sci. Rep. 8(1), 1–12 (2018)

    Article  Google Scholar 

  6. Datta, D., David, P.E., Mittal, D., Jain, A.: Neural machine translation using recurrent neural network. Int. J. Eng. Adv. Technol. 9(4), 1395–1400 (2020)

    Article  Google Scholar 

  7. Dong, G., et al.: Towards interpreting recurrent neural networks through probabilistic abstraction. In: 2020 35th IEEE/ACM International Conference on Automated Software Engineering (ASE), pp. 499–510. IEEE (2020)

    Google Scholar 

  8. Du, X., Li, Y., Xie, X., Ma, L., Liu, Y., Zhao, J.: Marble: model-based robustness analysis of stateful deep learning systems. In: Proceedings of the 35th IEEE/ACM International Conference on Automated Software Engineering, pp. 423–435 (2020)

    Google Scholar 

  9. Du, X., Xie, X., Li, Y., Ma, L., Liu, Y., Zhao, J.: Deepstellar: model-based quantitative analysis of stateful deep learning systems. In: Proceedings of the 2019 27th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, pp. 477–487 (2019)

    Google Scholar 

  10. Gastin, P., Monmege, B.: A unifying survey on weighted logics and weighted automata. Soft. Comput. 22(4), 1047–1065 (2015). https://doi.org/10.1007/s00500-015-1952-6

    Article  MATH  Google Scholar 

  11. Goldberg, Y.: Neural network methods for natural language processing. Synth. Lect. Hum. Lang. Technol. 10(1), 1–309 (2017)

    Article  Google Scholar 

  12. He, K., Zhang, X., Ren, S., Sun, J.: Deep residual learning for image recognition. In: Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR) (2016)

    Google Scholar 

  13. Hochreiter, S., Schmidhuber, J.: Long short-term memory. Neural Comput. 9(8), 1735–1780 (1997)

    Article  Google Scholar 

  14. Jacobsson, H.: Rule extraction from recurrent neural networks: Ataxonomy and review. Neural Comput. 17(6), 1223–1263 (2005)

    Article  MATH  Google Scholar 

  15. Jigsaw: Toxic comment classification challenge. https://www.kaggle.com/c/jigsaw-toxic-comment-classification-challenge. Accessed 16 Apr 2022

  16. Li, X., Roth, D.: Learning question classifiers. In: COLING 2002: The 19th International Conference on Computational Linguistics (2002)

    Google Scholar 

  17. Okudono, T., Waga, M., Sekiyama, T., Hasuo, I.: Weighted automata extraction from recurrent neural networks via regression on state spaces. In: Proceedings of the AAAI Conference on Artificial Intelligence, vol. 34, pp. 5306–5314 (2020)

    Google Scholar 

  18. Omlin, C.W., Giles, C.L.: Extraction of rules from discrete-time recurrent neural networks. Neural Netw. 9(1), 41–52 (1996)

    Article  Google Scholar 

  19. Omlin, C.W., Giles, C.L.: Rule revision with recurrent neural networks. IEEE Trans. Knowl. Data Eng. 8(1), 183–188 (1996)

    Article  Google Scholar 

  20. Omlin, C., Giles, C., Miller, C.: Heuristics for the extraction of rules from discrete-time recurrent neural networks. In: Proceedings 1992 IJCNN International Joint Conference on Neural Networks, vol. 1, pp. 33–38. IEEE (1992)

    Google Scholar 

  21. Powers, D.M.: Applications and explanations of zipf’s law. In: New Methods in Language Processing and Computational Natural Language Learning (1998)

    Google Scholar 

  22. Wang, Q., Zhang, K., Liu, X., Giles, C.L.: Verification of recurrent neural networks through rule extraction. arXiv preprint arXiv:1811.06029 (2018)

  23. Wang, Q., Zhang, K., Ororbia, A.G., II., Xing, X., Liu, X., Giles, C.L.: An empirical evaluation of rule extraction from recurrent neural networks. Neural Comput. 30(9), 2568–2591 (2018)

    Article  Google Scholar 

  24. Wang, R., Li, Z., Cao, J., Chen, T., Wang, L.: Convolutional recurrent neural networks for text classification. In: 2019 International Joint Conference on Neural Networks (IJCNN), pp. 1–6. IEEE (2019)

    Google Scholar 

  25. Weiss, G., Goldberg, Y., Yahav, E.: Extracting automata from recurrent neural networks using queries and counterexamples. In: International Conference on Machine Learning, pp. 5247–5256. PMLR (2018)

    Google Scholar 

  26. Weiss, G., Goldberg, Y., Yahav, E.: Learning deterministic weighted automata with queries and counterexamples. In: Wallach, H., Larochelle, H., Beygelzimer, A., d’ Alché-Buc, F., Fox, E., Garnett, R. (eds.) Advances in Neural Information Processing Systems, vol. 32. Curran Associates, Inc. (2019). https://proceedings.neurips.cc/paper/2019/file/d3f93e7766e8e1b7ef66dfdd9a8be93b-Paper.pdf

  27. Xie, X., et al.: Rnnrepair: automatic rnn repair via model-based analysis. In: International Conference on Machine Learning, pp. 11383–11392. PMLR (2021)

    Google Scholar 

  28. Zeng, Z., Goodman, R.M., Smyth, P.: Learning finite state machines with self-clustering recurrent networks. Neural Comput. 5(6), 976–990 (1993)

    Article  Google Scholar 

  29. Zhang, X., Du, X., Xie, X., Ma, L., Liu, Y., Sun, M.: Decision-guided weighted automata extraction from recurrent neural networks. In: Thirty-Fifth AAAI Conference on Artificial Intelligence (AAAI), pp. 11699–11707. AAAI Press (2021)

    Google Scholar 

Download references

Acknowledgements

This research was sponsored by the National Natural Science Foundation of China under Grant No. 62172019, 61772038, and CCF-Huawei Formal Verification Innovation Research Plan.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Meng Sun .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2022 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Wei, Z., Zhang, X., Sun, M. (2022). Extracting Weighted Finite Automata from Recurrent Neural Networks for Natural Languages. In: Riesco, A., Zhang, M. (eds) Formal Methods and Software Engineering. ICFEM 2022. Lecture Notes in Computer Science, vol 13478. Springer, Cham. https://doi.org/10.1007/978-3-031-17244-1_22

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-17244-1_22

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-17243-4

  • Online ISBN: 978-3-031-17244-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics