Subdomain 1.7: Integrate knowledge graphs to enable relational reasoning.
1.When designing an agentic system that translates natural language into graph database queries (e.g., Text-to-Cypher), which technique is most critical for minimizing hallucinated relationships and ensuring the LLM generates syntactically valid queries?
- A.Providing the LLM with a complete dump of all graph nodes and edges in the prompt context.
- B.Injecting the graph schema, including node labels, relationship types, and property keys, directly into the LLM's system prompt.
- C.Using a lower temperature setting and increasing the top-p parameter to 1.0 to enforce deterministic query generation.
- D.Converting the graph database into a relational SQL database schema before prompting the LLM.
Show answer & explanation
Correct answer: B — Injecting the graph schema, including node labels, relationship types, and property keys, directly into the LLM's system prompt.
- A. Providing a complete dump of all graph data is impractical as it would likely exceed the context window and introduce significant noise. Grounding the model in raw instance data is far less effective for query generation than providing an explicit, structured schema.
- B. Injecting the graph schema (node labels, relationship types, and property keys) is the standard best practice for grounding LLMs in Text-to-Cypher tasks. It provides the authoritative set of constraints needed to ensure the model uses existing relationship names and property keys, thereby minimizing hallucinations and ensuring the output aligns with the database's architecture.
- C. Adjusting temperature and top-p can increase the determinism of the output, but these parameters do not provide the factual grounding or structural knowledge required to generate syntactically correct queries against a specific database schema.
- D. Converting a graph database into a relational SQL schema is counterproductive. It removes the graph-specific semantics that Cypher is designed to express and does not address the fundamental requirement of mapping natural language to the existing graph structure.