github.com/YunyueLi/LoreGraph
No hallucinated edges. No trust me.
I. Cover plate Design for a theater set, The Met 001 / 007
Evidence-anchored knowledge graphs for fiction

Knowledge graphs that quote the page they came from.

LoreGraph turns a novel, play, screenplay or libretto into a queryable graph: characters, objects, events, concepts, and the typed relations between them. Every claim carries an evidence_span, so clicking any relation lands you on the sentence it came from.

85 worksreference corpus
11 languagessource to interface
08 passesone of them a gate
↳   uv sync   →   loregraph extract eight passes, one gate
Israel Silvestre, 1654 The Met, CC0 literal match  ≥ 95% Design for a theater set created by Giacomo Torelli da Fano for the ballet 'Les Noces de Thétis'. The Met, CC0, treated as a collage plate.
01Chunk 02Extract 03Verify 04Note
II. The rule docs/8-pass-pipeline.md 002 / 007
The rule

A graph that quietly invents a relationship is worse than no graph.

Most tools that pull a knowledge graph out of text extract triples and ask you to trust them. For fiction that is fatal. LoreGraph holds one rule instead: every extracted claim carries an evidence_span, a literal substring of the source, and the verification pass rejects any claim whose span is not a 95% literal match.

Read the pipeline spec
Sphaera Mundi. The Met, CC0, treated as a collage plate.
The model may only use
the text in front of it.
It is told, explicitly,
to forget the Elizabeth
Bennet it already knows.
Closed-world extraction: every claim goes back to a line in the book. (Sphaera Mundi, 1485. The Met, CC0.)
III. Engineering src/loregraph 003 / 007
New Inventions of Modern Times [Nova Reperta], The Invention of Book Printing, plate 4. The Met, CC0, treated as a collage plate.
LOREGRAPH     8-PASS PIPELINE
Engineering

Strict about evidence, relaxed about models.

Reading Splink, ComEM and GraphRAG settled four things: a literal-evidence gate, entity resolution that works across scripts, per-pass commits with idempotent re-runs, and a client that is not tied to one provider.

01Evidence

Every claim
cites its line

The extractor writes an evidence_span as it goes, and the verification pass drops anything under a 95% literal match.

02Closed world

Only the text
in front of it

The model is told to forget the Elizabeth Bennet or 孫悟空 it already knows, and to report what this book says.

03Multilingual

Aliases merge
across scripts

Entity resolution runs on multilingual-e5-large, so 林黛玉 and 颦儿 merge into one node with no string overlap.

04Any backend

One key,
any model

DeepSeek V4 Pro through OpenRouter by default, swappable to 15+ backends. Anthropic models go direct and reuse the cached prompt prefix.

IV. Reading room src/loregraph/web 004 / 007
Reading room

One book, five views, one graph underneath.

05
Five views Reader, Graph, Timeline,
Index and Ask all read
the same graph.
TextManuscript Leaf with text in Bolorgir. The Met, CC0, treated as a collage plate.
01Shipped

Reader

The original text, with every entity mention highlighted and clickable.

GraphThe Celestial Map- Northern Hemisphere. The Met, CC0, treated as a collage plate.
02Shipped

Graph

A force-directed network of characters, objects, events and concepts. Hover an edge to see the source line.

TimeBamboo and the Thousand-Character Classic. The Met, CC0, treated as a collage plate.
03Shipped

Timeline

The story's events in reading order. The graph carries story-time on every fact.

IndexAlphabet Letters (5 Vowels). The Met, CC0, treated as a collage plate.
04Shipped

Index

A searchable entity catalogue, one profile card per entity, with facts and inferences kept apart.

AskTerracotta bell-krater (bowl for mixing wine and water). The Met, CC0, treated as a collage plate.
05Shipped

Ask

Question answering grounded in the graph. Every answer cites its evidence.

All five views live in src/loregraph/web     read the source →
V. The pipeline eight passes 005 / 007
The pipeline

Eight passes from raw text to a claim you can check.

+

Passes 1 and 4 are deterministic. Passes 2, 3, 5, 6 and 8 call a model. Pass 7 is a gate, not a suggestion. Every pass commits on its own, so a failed run resumes with --from N and nothing is written twice.

01

Chunk

Deterministic, chapter-aware splitting that reads English headings and 第N回 alike. Each chunk gets a position in global story time.

Manuscript Leaf from a Royal Psalter. The Met, CC0, treated as a collage plate.
02

Extract

Typed mentions, entity resolution (lexical plus embedding-kNN blocking, then batched matching), coreference, five typed relations, and the facts they imply.

Neu inventiert genealogischer Stamm-Baum der Griechisch Kayser. The Met, CC0, treated as a collage plate.
03

Verify

Chain-of-verification. A claim whose evidence span is not a literal match of the source is dropped here. The gate is 95%.

Fragmentary marble inscription. The Met, CC0, treated as a collage plate.
04

Note

One Hybrid Note per entity: facts and inferences in separate columns, every inference labelled with a confidence, plus a subtype and an importance tier.

Bookbinding (Jild-i kitab). The Met, CC0, treated as a collage plate.
If it is not in the text, it does not enter the graph.
VII. Quick start Apache-2.0 007 / 007
Quick start

Three commands and your own book has a graph.

uv sync, then alembic upgrade head against Postgres 16+ with pgvector, then loregraph ingest and loregraph extract. One OpenRouter key is enough. A mid-size novel runs in minutes rather than hours, and a per-book budget ceiling of $20 is enforced between passes.

● Live v0.1.0-dev / Apache-2.0 eight passes, one gate
Parte di ampio magnifico Porto all'uso degli antichi Romani, ove si scuopre l'interno della gran Piazza pel Comercio. The Met, CC0, treated as a collage plate.
VII
LOREGRAPH     APACHE-2.0