Skip to main content

Using Quantum Natural Language Processing for Sentiment Classification and Next-Word Prediction in Sentences Without Fixed Syntactic Structure

  • Conference paper
  • First Online:
Information and Software Technologies (ICIST 2023)

Abstract

Quantum Computing is envisioned as one of the scientific areas with greater transformative potential. Already there exist applications running in quantum devices for different areas, like cybersecurity, chemistry, or machine learning. One subarea being developed under quantum machine learning is quantum natural language processing. Following the promising results existing in problems like sentiment classification or next-word prediction, this paper presents two proofs of concept to demonstrate how these two tasks can be solved using quantum computing. For the first task showcased, sentiment classification, we employ the removal of caps and cups morphisms to make the string diagrams simpler and more efficient. In the case of next-word prediction, we show how to solve the task for sentences with previously unknown syntactic structures by applying a classical Random Forest machine learning algorithm that classifies the syntactic structure and enables our QNLP algorithm to infer the proper string model.

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. Bauer, C.W., Freytsis, M., Nachman, B.: Simulating collider physics on quantum computers using effective field theories (2021)

    Google Scholar 

  2. Bennett, C.H., Brassard, G.: Quantum cryptography: public key distribution and coin tossing. Theor. Comput. Sci. 560, 7–11 (2014). https://doi.org/10.1016/j.tcs.2014.05.025

    Article  MathSciNet  Google Scholar 

  3. Bergholm, V., et al.: Pennylane: automatic differentiation of hybrid quantum-classical computations (2022)

    Google Scholar 

  4. Biamonte, J., Wittek, P., Pancotti, N., Rebentrost, P., Wiebe, N., Lloyd, S.: Quantum machine learning. Nature 549(7671), 195–202 (2017). https://doi.org/10.1038/nature23474

    Article  Google Scholar 

  5. Cherrat, E.A., Kerenidis, I., Mathur, N., Landman, J., Strahm, M., Li, Y.Y.: Quantum vision transformers (2022)

    Google Scholar 

  6. Coecke, B.: The mathematics of text structure (2020)

    Google Scholar 

  7. Coecke, B., Duncan, R.: Interacting quantum observables: categorical algebra and diagrammatics. New J. Phys. 13(4), 043016 (2011). https://doi.org/10.1088/1367-2630/13/4/043016

    Article  MathSciNet  Google Scholar 

  8. Developers, C.: Cirq (2022). https://doi.org/10.5281/zenodo.7465577. See full list of authors on Github: https://github.com/quantumlib/Cirq/graphs/contributors

  9. de Felice, G., Toumi, A., Coecke, B.: DisCoPy: monoidal categories in Python. Electr. Proc. Theor. Comput. Sci. 333, 183–197 (2021). https://doi.org/10.4204/eptcs.333.13

    Article  MathSciNet  Google Scholar 

  10. García, D.P., Cruz-Benito, J., García-Peñalvo, F.J.: Systematic literature review: quantum machine learning and its applications (2022)

    Google Scholar 

  11. Grover, L.K.: A fast quantum mechanical algorithm for database search. In: Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing, STOC ’96, pp. 212–219. Association for Computing Machinery, New York (1996). https://doi.org/10.1145/237814.237866

  12. Kartsaklis, D., et al.: Lambeq: an efficient high-level python library for quantum NLP. arXiv preprint: arXiv:2110.04236 (2021)

  13. Kim, Y., et al.: Evidence for the utility of quantum computing before fault tolerance. Nature 618, 500–505 (2023). https://doi.org/10.1038/s41586-023-06096-3

    Article  Google Scholar 

  14. Meichanetzidis, K., Gogioso, S., de Felice, G., Chiappori, N., Toumi, A., Coecke, B.: Quantum natural language processing on near-term quantum computers. Electr. Proc. Theor. Comput. Sci. 340, 213–229 (2021). https://doi.org/10.4204/eptcs.340.11

    Article  MathSciNet  Google Scholar 

  15. Miranda, E.R., Yeung, R., Pearson, A., Meichanetzidis, K., Coecke, B.: A quantum natural language processing approach to musical intelligence (2021)

    Google Scholar 

  16. Nachman, B., Provasoli, D., de Jong, W.A., Bauer, C.W.: Quantum algorithm for high energy physics simulations. Phys. Rev. Lett. 126(6), 062001 (2021). https://doi.org/10.1103/physrevlett.126.062001

    Article  Google Scholar 

  17. Qiskit contributors: Qiskit: an open-source framework for quantum computing (2023). https://doi.org/10.5281/zenodo.2573505

  18. Scarani, V., Bechmann-Pasquinucci, H., Cerf, N.J., Dušek, M., Lütkenhaus, N., Peev, M.: The security of practical quantum key distribution. Rev. Modern Phys. 81(3), 1301–1350 (2009). https://doi.org/10.1103/revmodphys.81.1301

    Article  Google Scholar 

  19. Schuld, M., Sinayskiy, I., Petruccione, F.: An introduction to quantum machine learning. Contemp. Phys. 56(2), 172–185 (2014). https://doi.org/10.1080/00107514.2014.964942

    Article  Google Scholar 

  20. Shor, P.W.: Polynomial-time algorithms for prime factorization and discrete logarithms on a quantum computer. SIAM J. Comput. 26(5), 1484–1509 (1997). https://doi.org/10.1137/s0097539795293172

    Article  MathSciNet  Google Scholar 

  21. Tacchino, F., Barkoutsos, P., Macchiavello, C., Tavernelli, I., Gerace, D., Bajoni, D.: Quantum implementation of an artificial feed-forward neural network. Quantum Sci. Technol. 5(4) (2020). https://doi.org/10.1088/2058-9565/abb8e4. arXiv:1912.12486

  22. Toumi, A., Koziell-Pipe, A.: Functorial language models (2021)

    Google Scholar 

  23. van de Wetering, J.: ZX-calculus for the working quantum computer scientist (2020)

    Google Scholar 

  24. Zhang, W., Ding, D.S., Sheng, Y.B., Zhou, L., Shi, B.S., Guo, G.C.: Quantum secure direct communication with quantum memory. Phys. Rev. Lett. 118(22), 220501 (2017). https://doi.org/10.1103/physrevlett.118.220501

    Article  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to David Peral-García .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2024 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

Peral-García, D., Cruz-Benito, J., García-Peñalvo, F.J. (2024). Using Quantum Natural Language Processing for Sentiment Classification and Next-Word Prediction in Sentences Without Fixed Syntactic Structure. In: Lopata, A., Gudonienė, D., Butkienė, R. (eds) Information and Software Technologies. ICIST 2023. Communications in Computer and Information Science, vol 1979. Springer, Cham. https://doi.org/10.1007/978-3-031-48981-5_19

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-48981-5_19

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-48980-8

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

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics