Skip to content

Latest commit

 

History

History
233 lines (191 loc) · 7.25 KB

File metadata and controls

233 lines (191 loc) · 7.25 KB

Sample Queries & Responses

This document demonstrates how the knowledge graph data is used to ground and verify answers from the LLM. For each query, we show:

  1. The user question
  2. The Cypher query used to retrieve data from Neo4j
  3. The raw graph facts retrieved (before LLM processing)
  4. The final LLM answer (grounded synthesis)

Query 1

1. User Question

Which gene is responsible for Spider-Man's powers?

2. Cypher Query

MATCH (c:Character {name: "Spider-Man"})
        OPTIONAL MATCH (c)-[:POSSESSES_POWER]->(p:Power)
        OPTIONAL MATCH (c)-[:HAS_MUTATION]->(g:Gene)
        WITH c, collect(DISTINCT p.name) AS powers, collect(DISTINCT g.gene_name) AS character_genes
        OPTIONAL MATCH (c)-[:POSSESSES_POWER]->(p2:Power)<-[:CONFERS]-(g2:Gene)
        WHERE g2.gene_name IN character_genes
        RETURN
          c.name AS character,
          powers AS powers,
          character_genes AS character_genes,
          collect(DISTINCT g2.gene_name) AS conferring_genes
        LIMIT 1

3. Retrieved Graph Facts

The following data was retrieved from Neo4j before the LLM processed it:

{
  "intent": "powers_of_character",
  "entities": {
    "character": "Spider-Man",
    "gene": null,
    "power": null,
    "team": null
  },
  "facts": {
    "character": "Spider-Man",
    "powers": [
      "Web Generation",
      "Superhuman Strength",
      "Spider-Sense",
      "Superhuman Agility",
      "Wall-Crawling"
    ],
    "character_genes": [
      "Arachnid DNA Fusion Gene",
      "Wall-Adhesion Gene WA1",
      "Precognitive Gene P1"
    ],
    "conferring_genes": [
      "Arachnid DNA Fusion Gene",
      "Precognitive Gene P1",
      "Wall-Adhesion Gene WA1"
    ]
  }
}

4. Final LLM Answer (Grounded Synthesis)

Accessing S.H.I.E.L.D. Intelligence Database... Subject: Spider-Man (Peter Parker) Genetic Profile Analysis: Complete.

According to our records, Spider-Man’s superhuman abilities are the result of three specific genetic markers integrated into his DNA following exposure to a radioactive spider bite:

  • Arachnid DNA Fusion Gene: This gene is responsible for the fusion of arachnid characteristics into his physiology, granting him superhuman strength, superhuman agility, and web generation.
  • Wall-Adhesion Gene WA1: This specific gene facilitates his wall-crawling ability.
  • Precognitive Gene P1: This gene is responsible for his "Spider-Sense," providing him with precognitive awareness of immediate danger.

These genetic alterations allow the subject to manifest the full suite of powers associated with his arachnid-based mutation.


Query 2

1. User Question

What gene gives Wolverine his healing power?

2. Cypher Query

MATCH (c:Character {name: "Wolverine"})
        OPTIONAL MATCH (c)-[:POSSESSES_POWER]->(p_actual:Power)
        OPTIONAL MATCH (c)-[:HAS_MUTATION]->(g:Gene)
        WITH c, collect(DISTINCT p_actual.name) AS character_powers, collect(DISTINCT g.gene_name) AS character_genes
        OPTIONAL MATCH (p:Power {name: "Accelerated Healing"})
        WHERE p.name IS NOT NULL AND p.name IN character_powers
        OPTIONAL MATCH (g2:Gene)-[:CONFERS]->(p)
        WHERE g2.gene_name IN character_genes
        RETURN
          c.name AS character,
          CASE WHEN p.name IS NOT NULL AND p.name IN character_powers
               THEN p.name
               ELSE null
          END AS power,
          character_powers AS powers,
          character_genes AS character_genes,
          collect(DISTINCT g2.gene_name) AS conferring_genes
        LIMIT 1

3. Retrieved Graph Facts

The following data was retrieved from Neo4j before the LLM processed it:

{
  "intent": "gene_of_character_power",
  "entities": {
    "character": "Wolverine",
    "gene": "Healing Factor Gene HF2",
    "power": "Accelerated Healing",
    "team": null
  },
  "facts": {
    "character": "Wolverine",
    "power": "Accelerated Healing",
    "powers": [
      "Accelerated Healing",
      "Retractable Bone Claws",
      "Superhuman Durability",
      "Longevity",
      "Enhanced Senses"
    ],
    "character_genes": [
      "Regenerative Mutation Gene X",
      "Enhanced Sensory Gene ES1",
      "Bone Density Gene BD1"
    ],
    "conferring_genes": [
      "Regenerative Mutation Gene X"
    ]
  }
}

4. Final LLM Answer (Grounded Synthesis)

According to S.H.I.E.L.D. genetic records, Wolverine’s power of Accelerated Healing is directly attributed to the Regenerative Mutation Gene X.

While the subject also possesses the Enhanced Sensory Gene ES1 and Bone Density Gene BD1, it is the Regenerative Mutation Gene X that facilitates his ability to recover from virtually any wound.


Query 3

1. User Question

Which gene gives Wolverine his telepathy?

2. Cypher Query

MATCH (c:Character {name: "Wolverine"})
        OPTIONAL MATCH (c)-[:POSSESSES_POWER]->(p_actual:Power)
        OPTIONAL MATCH (c)-[:HAS_MUTATION]->(g:Gene)
        WITH c, collect(DISTINCT p_actual.name) AS character_powers, collect(DISTINCT g.gene_name) AS character_genes
        OPTIONAL MATCH (p:Power {name: "Telepathy"})
        WHERE p.name IS NOT NULL AND p.name IN character_powers
        OPTIONAL MATCH (g2:Gene)-[:CONFERS]->(p)
        WHERE g2.gene_name IN character_genes
        RETURN
          c.name AS character,
          CASE WHEN p.name IS NOT NULL AND p.name IN character_powers
               THEN p.name
               ELSE null
          END AS power,
          character_powers AS powers,
          character_genes AS character_genes,
          collect(DISTINCT g2.gene_name) AS conferring_genes
        LIMIT 1

3. Retrieved Graph Facts

The following data was retrieved from Neo4j before the LLM processed it:

{
  "intent": "gene_of_character_power",
  "entities": {
    "character": "Wolverine",
    "gene": null,
    "power": "Telepathy",
    "team": null
  },
  "facts": {
    "character": "Wolverine",
    "power": null,
    "powers": [
      "Accelerated Healing",
      "Retractable Bone Claws",
      "Superhuman Durability",
      "Longevity",
      "Enhanced Senses"
    ],
    "character_genes": [
      "Regenerative Mutation Gene X",
      "Enhanced Sensory Gene ES1",
      "Bone Density Gene BD1"
    ],
    "conferring_genes": []
  }
}

4. Final LLM Answer (Grounded Synthesis)

Based on current S.H.I.E.L.D. intelligence records, there is no information indicating that Wolverine possesses telepathy or a gene associated with it.

According to the provided knowledge graph, Wolverine’s genetic profile consists of the following:

  • Regenerative Mutation Gene X: Responsible for his healing factor.
  • Enhanced Sensory Gene ES1: Linked to his animal-keen senses.
  • Bone Density Gene BD1: Associated with his enhanced physical capabilities.

The records explicitly state "None" under the Power category in the knowledge graph, and the character background does not list telepathy among his abilities. Therefore, the provided facts do not contain information regarding a gene for telepathy.