[Paper Review] Text2Cypher: Bridging Natural Language and Graph Databases
The paper builds a large, cleaned Text2Cypher dataset by merging public sources, benchmarks various models, and shows fine-tuning improves Cypher query translation accuracy.
Knowledge graphs use nodes, relationships, and properties to represent arbitrarily complex data. When stored in a graph database, the Cypher query language enables efficient modeling and querying of knowledge graphs. However, using Cypher requires specialized knowledge, which can present a challenge for non-expert users. Our work Text2Cypher aims to bridge this gap by translating natural language queries into Cypher query language and extending the utility of knowledge graphs to non-technical expert users. While large language models (LLMs) can be used for this purpose, they often struggle to capture complex nuances, resulting in incomplete or incorrect outputs. Fine-tuning LLMs on domain-specific datasets has proven to be a more promising approach, but the limited availability of high-quality, publicly available Text2Cypher datasets makes this challenging. In this work, we show how we combined, cleaned and organized several publicly available datasets into a total of 44,387 instances, enabling effective fine-tuning and evaluation. Models fine-tuned on this dataset showed significant performance gains, with improvements in Google-BLEU and Exact Match scores over baseline models, highlighting the importance of high-quality datasets and fine-tuning in improving Text2Cypher performance.
Motivation & Objective
- Motivate translating natural language to Cypher to broaden access to graph databases for non-experts.
- Create a large, clean, usable Text2Cypher dataset by combining public sources.
- Benchmark foundational and fine-tuned models on the Text2Cypher task.
- Demonstrate that fine-tuning yields performance gains over baselines.
Proposed method
- Aggregate and harmonize 16 public Text2Cypher datasets into a single format with fields: question, schema, cypher, data_source, database_reference, instance_id.
- Clean data via manual checks, removal of invalid queries, and syntax validation using EXPLAIN in a local Neo4j database.
- Split data into training (≈39,554) and test (≈4,833) sets totaling 44,387 instances and analyze distribution.
- Benchmark a range of baseline and fine-tuned models using translation-based (Google-BLEU) and execution-based (Exact Match) metrics.
- Fine-tune selected models on the new dataset and compare to baselines to quantify gains.
![Figure 1: User wants to write a Cypher query for ‘What are the movies of Tom Hanks‘. A Text2Cypher model translates the input natural language question into Cypher, i.e., ‘MATCH (actor:Person {name: "Tom Hanks"})-[:ACTED_IN]->(movie:Movie) RETURN movie.title AS movies‘](https://ar5iv.labs.arxiv.org/html/2412.10064/assets/figures/text2cypher.png)
Experimental results
Research questions
- RQ1Can a large, unified Text2Cypher dataset improve the performance of natural language to Cypher translation models?
- RQ2Do fine-tuned models outperform their baselines on Text2Cypher translation and execution metrics?
- RQ3Which model families (open-weighted, closed-foundational) benefit most from fine-tuning for Text2Cypher?
- RQ4How do translation-based and execution-based evaluations compare for Text2Cypher models?
Key findings
- The final dataset contains 44,387 instances with 39,554 training and 4,833 testing examples.
- Fine-tuned models consistently outperform their baseline versions on Google-BLEU and Exact Match metrics.
- Among baselines, OpenAI/GPT-4o and Gemini-1.5-Pro-001 led in performance under certain settings, with larger models generally performing better.
- Among fine-tuned models, improvements include up to ~0.34 Google-BLEU and ~0.11 Exact Match over baselines.
- The best fine-tuned results were achieved by Finetuned-OpenAI/Gpt4o, Finetuned-OpenAI/Gpt4o-mini, and Finetuned-GoogleAIStudio/Gemini-1.5-Flash-001.
- The dataset and tuning approach highlight the importance of high-quality data and fine-tuning for Text2Cypher.

Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.