This project combines a YAGO knowledge graph subset, LLM-generated grounding facts, and PyReason inference.
The goal is to show that explicit rules can fire on top of trusted graph facts plus new facts suggested by an LLM.
- Knowledge graph input:
src/data/yago_subset.graphml - Rules input:
src/data/rules.json(five PyReason-compatible rules) - LLM grounding output:
src/output/llm_facts_pyreason.json - Inference output:
src/output/inference_result.jsonandsrc/output/inference_rule_trace_edges.csv - Human summary:
src/FINDINGS.txt
The dashboard overlays three layers in one graph view:
- YAGO edges (solid)
- LLM fact edges (dashed)
- Inferred rule-head edges (thick)
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .envSet OPENAI_API_KEY in .env before running inference.
python -m src.buildYagoSubsetFromHuggingFaceHow this works: buildYagoSubsetFromHuggingFace streams VLyB/YAGO3-10 and keeps a small fixed set of required triples.
It writes only that minimal subset to src/data/yago_subset.graphml.
python -m src.runInferenceThis step:
- reads
yago_subset.graphmlandrules.json - calls OpenAI once per showable rule
- converts model output into PyReason fact JSON
- runs
reason() - writes inference artifacts under
src/output/
Run:
./run_dashboard.shThe dashboard is read-only and loads files from disk.
- Default mode: reads
src/output/ - Demo mode: reads frozen sample artifacts in
src/brunoOutput/
Demo mode command:
LEIBNIZ_USE_BRUNO_OUTPUT=1 ./run_dashboard.shrunInference always writes to src/output only.
It does not modify src/brunoOutput.
python -m src.cleanOutputsThis removes generated files under src/output and keeps:
src/data/rules.jsonsrc/data/yago_subset.graphml
- LLM prompt/reply audit:
src/output/llm_openai_prompts_and_replies.json - Merged LLM payload:
src/output/llm_full_payload.json - PyReason fact file:
src/output/llm_facts_pyreason.json - Inference bundle:
src/output/inference_result.json - Full trace CSV:
src/output/inference_rule_trace_edges.csv
If OpenAI calls fail with CERTIFICATE_VERIFY_FAILED, install dependencies again and retry:
pip install -r requirements.txt
python -m src.runInference