journal article·2025-07-23Open access

Refining Text2Cypher on Small Language Model with Reinforcement Learning Leveraging Semantic Information

Quoc-Bao-Huy Tran, Aagha Abdul Waheed, Syed Mudasir, Sun-Tae Chung

Applied Sciences· Volume 15· Issue 15

Abstract

Text2Cypher is a text-to-text task that converts natural language questions into Cypher queries. Recent research by Neo4j on Text2Cypher demonstrates that fine-tuning a baseline language model (a pretrained and instruction-tuned generative model) using a comprehensive Text2Cypher dataset can effectively enhance query generation performance. However, the improvement is still insufficient for effectively learning the syntax and semantics of complex natural texts, particularly when applied to unseen Cypher schema structures across diverse domains during training. To address this challenge, we propose a novel refinement training method based on baseline language models, employing reinforcement learning with Group Relative Policy Optimization (GRPO). This method leverages extracted semantic information, such as key-value properties and triple relationships from input texts during the training process. Experimental results of the proposed refinement training method applied to a small-scale baseline language model (SLM) like Qwen2.5-3B-Instruct demonstrate that it achieves competitive execution accuracy scores on unseen schemas across various domains. Furthermore, the proposed method significantly outperforms most baseline LMs with larger parameter sizes in terms of Google-BLEU and execution accuracy scores over Neo4j’s comprehensive Text2Cypher dataset, with the exception of colossal LLMs such as GPT4o, GPT4o-mini, and Gemini.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Topic Modeling

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

Department of Intelligent Systems, Soongsil University, Seoul 06978, Republic of Korea

Department of AI Convergence, Soongsil University, Seoul 06978, Republic of Korea

Funding

MSIT (Ministry of Science and ICT), Korea

References (30)

Show source-provided references
1. An Overview of Graph Databases and Their Applications in the Biomedical Domain10.1093/database/baab026 ↗
2. Almabdy, S. (2018, January 4–6). Comparative Analysis of Relational and Graph Databases for Social Networks. Proceedings of the 2018 1st International Conference on Computer Applications & Information Security (ICCAIS), Riyadh, Saudi Arabia.10.1109/CAIS.2018.8441982 ↗
3. Syed, M.H., Huy, T.Q.B., and Chung, S.-T. (2022). Context-Aware Explainable Recommendation Based on Domain Knowledge Graph. Big Data Cogn. Comput., 6.10.3390/bdcc6010011 ↗
4. Xu, Z., Cruz, M.J., Guevara, M., Wang, T., Deshpande, M., Wang, X., and Li, Z. (2024, January 10). Retrieval-Augmented Generation with Knowledge Graphs for Customer Service Question Answering. Proceedings of the 47th International ACM SIGIR Conference on Research and Development in Information Retrieval, Washington, DC, USA.10.1145/3626772.3661370 ↗
5. Kobeissi, M., Assy, N., Gaaloul, W., Defude, B., and Haidar, B. (2021, January 31). An Intent-Based Natural Language Interface for Querying Process Execution Data. Proceedings of the 2021 3rd International Conference on Process Mining (ICPM), Eindhoven, The Netherlands.10.1109/ICPM53251.2021.9576850 ↗
6. Nie, L., Cao, S., Shi, J., Sun, J., Tian, Q., Hou, L., Li, J., and Zhai, J. (2022, January 7–11). GraphQ IR: Unifying the Semantic Parsing of Graph Query Languages with One Intermediate Representation. Proceedings of the 2022 Conference on Empirical Methods in Natural Language Processing, Abu Dhabi, United Arab Emirates.10.18653/v1/2022.emnlp-main.394 ↗
7. Ozsoy, M.G., Messallem, L., Besga, J., and Minneci, G. (2024). Text2Cypher: Bridging Natural Language and Graph Databases. arXiv.
8. DeepSeek-AI, Guo, D., Yang, D., Zhang, H., Song, J., Zhang, R., Xu, R., Zhu, Q., Ma, S., and Wang, P. (2025). DeepSeek-R1: Incentivizing Reasoning Capability in LLMs via Reinforcement Learning. arXiv.
9. Papineni, K., Roukos, S., Ward, T., and Zhu, W.-J. (2001, January 1). BLEU: A Method for Automatic Evaluation of Machine Translation. Proceedings of the 40th Annual Meeting on Association for Computational Linguistics—ACL’02, Philadelphia, PA, USA.10.3115/1073083.1073135 ↗
10. Guo, A., Li, X., Xiao, G., Tan, Z., and Zhao, X. (2022, January 17). SpCQL: A Semantic Parsing Dataset for Converting Natural Language into Cypher. Proceedings of the 31st ACM International Conference on Information & Knowledge Management, Atlanta, GA, USA.10.1145/3511808.3557703 ↗
11. Mohammadjafari, A., Maida, A.S., and Gottumukkala, R. (2024). From Natural Language to SQL: Review of LLM-Based Text-to-SQL Systems. arXiv.
12. Liu, X., Shen, S., Li, B., Ma, P., Jiang, R., Zhang, Y., Fan, J., Li, G., Tang, N., and Luo, Y. (2024). A Survey of NL2SQL with Large Language Models: Where Are We, and Where Are We Going?. arXiv.10.1109/TKDE.2025.3592032 ↗
13. Lewis, M., Liu, Y., Goyal, N., Ghazvininejad, M., Mohamed, A., Levy, O., Stoyanov, V., and Zettlemoyer, L. (2020, January 5–10). BART: Denoising Sequence-to-Sequence Pre-Training for Natural Language Generation, Translation, and Comprehension. Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics, Online.10.18653/v1/2020.acl-main.703 ↗
14. Large Language Model Based Semantic Parsing for Intelligent Database Query Engine10.4236/jcc.2024.1210001 ↗
15. Robust NL-to-Cypher Translation for KBQA: Harnessing Large Language Model with Chain of Prompts10.1016/j.cag.2023.09.001 ↗
16. Hornsteiner, M., Kreussel, M., Steindl, C., Ebner, F., Empl, P., and Schönig, S. (2024). Real-Time Text-to-Cypher Query Generation with Large Language Models for Graph Databases. Future Internet, 16.10.3390/fi16120438 ↗
17. Zhong, Z., Zhong, L., Sun, Z., Jin, Q., Qin, Z., and Zhang, X. (2024, January 19–24). SyntheT2C: Generating Synthetic Data for Fine-Tuning Large Language Models on the Text2Cypher Task. Proceedings of the 31st International Conference on Computational Linguistics, Abu Dhabi, United Arab Emirates.
18. Tiwari, A., Malay, S.K.R., Yadav, V., Hashemi, M., and Madhusudhan, S.T. (May, January 29). Auto-Cypher: Improving LLMs on Cypher Generation via LLM-Supervised Generation-Verification Framework. Proceedings of the 2025 Conference of the Nations of the Americas Chapter of the Association for Computational Linguistics: Human Language Technologies (Volume 2: Short Papers), Albuquerque, NM, USA.10.18653/v1/2025.naacl-short.53 ↗
19. Coffelt, J.P., Kampmann, P., and Beetz, M. (2025, January 2). Implementation and Application of a Knowledge Service for AUV Mission Explainability. Proceedings of the 2025 IEEE Underwater Technology (UT), Taipei, Taiwan.10.1109/UT61067.2025.10947388 ↗
20. Ozsoy, M.G. (2025). Enhancing Text2Cypher with Schema Filtering. arXiv.
21. Tran, Q.-B.-H., Waheed, A.A., and Chung, S.-T. (2024). Robust Text-to-Cypher Using Combination of BERT, GraphSAGE, and Transformer (CoBGT) Model. Appl. Sci., 14.10.3390/app14177881 ↗
22. Francis, N., Green, A., Guagliardo, P., Libkin, L., Lindaaker, T., Marsault, V., Plantikow, S., Rydberg, M., Selmer, P., and Taylor, A. (2018, January 27). Cypher: An Evolving Query Language for Property Graphs. Proceedings of the 2018 International Conference on Management of Data, Houston, TX, USA.10.1145/3183713.3190657 ↗
23. Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. (2017). Proximal Policy Optimization Algorithms. arXiv.
24. Wei, J., Bosma, M., Zhao, V.Y., Guu, K., Yu, A.W., Lester, B., Du, N., Dai, A.M., and Le, Q.V. (2021). Finetuned Language Models Are Zero-Shot Learners. arXiv.
25. GPT (Generative Pre-Trained Transformer)—A Comprehensive Review on Enabling Technologies, Potential Applications, Emerging Challenges, and Future Directions10.1109/ACCESS.2024.3389497 ↗
26. Gemini Team, Anil, R., Borgeaud, S., Alayrac, J.-B., Yu, J., Soricut, R., Schalkwyk, J., Dai, A.M., Hauth, A., and Millican, K. (2023). Gemini: A Family of Highly Capable Multimodal Models. arXiv.
27. Enis, M., and Hopkins, M. (2024). From LLM to NMT: Advancing Low-Resource Machine Translation with Claude. arXiv.
28. On Information and Sufficiency10.1214/aoms/1177729694 ↗
29. (2025, June 23). Text-to-Cypher Data. Available online: https://huggingface.co/datasets/tomasonjo/text2cypher-gpt4o-clean.
30. (2025, June 23). Gemma2-9B-Text2Cypher Model. Available online: https://huggingface.co/neo4j/text2cypher-gemma-2-9b-it-finetuned-2024v1.