knowledge-graph
Knowledge Graph
Build a document knowledge graph from four structured-output prompts that share one schema, then answer from it with cited evidence: extraction, resolution, summarization, and querying. Fact classification and community reports reuse resolution and summarization on other inputs. No NER or relation model is trained: the schema is the only training data. Adapting to a domain means tightening the schema and prompts, then re-scoring: "No NER model to train; tightening the type Literal is our retraining step."
When a graph is worth it
A graph pays for its ingestion and upkeep only when facts must be chained across documents, the question concerns the whole corpus (themes, recurrence, coverage), several agents need one shared world model, an evaluator needs ground truth with provenance, or memory must survive context flushes. Answer single-document questions by direct prompting, and multi-document single-hop questions with RAG and reranking. A corpus that fits in context should simply be read. When the work routes out, say so and stop.
Model plan
Two tiers. Extraction, mention linking, and report relevance scoring are high-volume and schema-constrained, so they go on the lookup route. Resolution, summarization, fact classification, community reports, and query answering weigh conflicting evidence, so they go on the analysis route. Resolve each with python3 shared/scripts/model_routing.py resolve <route> --provider <host> unless the user names models, and never pin model IDs. Show both models with the document count, prompt count, retries, and call ceiling, and ask: "Approve this plan, or specify changes." Then route by host: T3 Code delegate_task (a Muse route uses muse-runner), Claude Code or Codex a native subagent, otherwise cli-runner, pi-runner, or muse-runner. A route the host cannot serve blocks its stage; never swap in another model. Sending a private corpus to an external provider needs the user's explicit approval.
1. Extraction
One call per document returns typed entities (name, type Literal, one-line description) and triples (source, predicate, target, evidence). Each of the five prompt guidelines fixes a specific failure: