Fine-Tuning or RAG? An Empirical Evaluation of Text-to-Cypher Translation for Code Graph Analysis
Code graphs describe how parts of a software system relate to one another. This study explores how language models can turn questions about those relationships into Cypher queries, making the graphs accessible through natural language. It compares fine-tuning with retrieval-augmented generation (RAG) on a 790-question benchmark of industrial code graphs.
With limited training data, RAG outperformed fine-tuning. For fine-tuning, data from the target domain was more useful than a much larger cross-domain dataset.
Code graph dependencies
Prompt
What depends on headerfile_12—and what does it depend on?
Example Cypher query
MATCH p = (h:HeaderFile)
-[:Include]-(f:HeaderFile)
WHERE h.name = "headerfile_12"
RETURN pReturned graph
Visualized here; passed to the model as JSON.
Notes & source
Dependency query adapted from benchmark question 11. All three directed Include relationships are verified against the published GraphML; only HeaderFile neighbours are shown.
View dataset







