Check if cypher is correct and according to the schema provided for Cypher generated by LLM

Hello everyone,

I am using LLM for generating cypher for the RAG use case. Right now I get two cases where i need to validate cypher.

  1. In some cases, it generates some cypher queries stating properties that don't even exist.
  2. Also, in some cases generated cypher itself is invalid and throws issue while running the query.

Is there any way we know if the generated cypher is correct in both properties/schema as well as syntax-wise?

hi, you can look into this

Hello @v2belleville , thanks for the help. But this is not what I was looking forward to. My actual need is to find a way to validate the entire cypher query.

My concern is while LLM is generating cypher queries, a common issue I found was LLM frequently generates a query that tries to return or extract the properties that don't exist on the graph. Thus, resulting in None value while running the query.

E.g.

  1. MATCH (x: Person{name:"Tom"}) RETURN x.address. But in the actual graph Person node doesn't have the address as its properties.
  2. MATCH (x: Organization {"location":"Nepal"}) RETURN (x). Here actually Organization node doesn't have location as its properties.

So, basically, I am trying to figure out if there is a way I can validate the entire cypher query not only the relationship based on the schema provided.