Παρουσιαση της διπλωματκης εργασιας του φοιτητή Σπυριδάκη Νικόλαου (ΤΗ20422) την Τετάρτη 9/12 στις 12 πμ, η οποια θα λαβει χωρα διαδικτυακα μεσω του συνδεσμου: https://vdc.hmu.gr/b/spy-zdo-all-zry
ΠΕΡΙΛΗΨΗ
LLM TRAINING FOR TRANSLATING NATURAL LANGUAGE INTO STRUCTURED QUERIES AND EXECUTING THEM IN A GRAPH DATABASE
Graph Databases are being used to store highly connected data represented by Nodes and Relationships. But getting information out of them is only possible through Cypher Queries which require knowledge of the language and the specific dataset in order to write them. Large Language Models (LLMs) can be used to translate natural language questions into Cypher Queries but this process is still error-prone. This happens because Cypher Queries are less common than SQL thus LLMs know less for them and tend to make mistakes. Also, Cypher Queries are strict about Relationship directions, Node labels and Property names. There is a lot to keep track and wrong queries can still run and return the wrong answer. This thesis designs, implements and evaluates a System that can answer Questions about Neo4J graph databases written in natural language. The System uses only open-weight LLMs without weight fine-tuning while the evaluation includes a fine-tuned one. The System evaluates 2 different methods; Cypher Generation and Graph-CoT. Cypher Generation is the concept of generating Cypher Queries from natural language questions and then running them. It is improved step by step in 5 different versions, each adding an improvement while comparing it to the previous one. The improvements include a Cypher Corrector, prompt Rules, a retry mechanism and Chain-Of-Thought reasoning. An automatic Rule generation procedure is also proposed which can save time from writing Rule by hand. It works by using an LLM to analyze its own mistakes and trying to find Rules which make it answer correctly. The automatic Rules’ performance matched the hand-written Rules. Graph-CoT is a completely different approach which explores the graph Node by Node using a set of functions. These functions use pre-defined Cypher Queries in the background and the LLM can run any of them until it finds the answer. Both methods are benchmarked using three datasets, each one having different structural challenges. The benchmarks are done using synthetic Questions and multiple LLMs are evaluated. Cypher Generation, with all the improvements applied, reached about 95% success on all three datasets using the Qwen 3 Coder Next LLM, when baseline only reached 45-65%. The Cypher Corrector and the Rules gave the largest improvements. Graph-CoT, using the much smaller Qwen 3.8 LLM, reached 91-96% success on all three datasets when excluding the subset of Questions it cannot answer. Comparing Cypher Generation with Graph-CoT on the subset of Questions that both can answer, Cypher Generation is slightly ahead and runs faster. In contrast, Graph-CoT which can answer way less Questions, requires a considerably lighter LLM. The results suggest the System is reliable enough for unsupervised automation use cases with the option of method depending on the requirements and available computing infrastructure.
Keywords: Artificial Intelligence, Large Language Models, Chain-Of-Thought, Graph Databases, Neo4J, Cypher Query Generation, AI Automation
