Beyond LLM Wiki: build and query Knowledge Graphs progressively

Part 1 turns any document with a URL into a knowledge graph. Part 2 produces query solutions from that graph. A beam follows the flow from the first step to the last and loops back to the start; as it passes left to right through the three graph snippets, each document adds more triples.

Companions: RDF-Turtle and animated SVG. Turtle is only a default preference; the same graph converts to other RDF serializations without changing its meaning.
Beyond LLM Wiki: build and query Knowledge Graphs progressivelyPart 1 · Build a KG from any document URLillustrativePart 2 · Produce query solutions from that graphillustrativethe doc URL, now the graph IRI, is what FROM names1Selectany document witha URL (http: or file:)2Invoke Agent SkillSKILLS.md, run in anagent: Claude, Codex3Fetchread the documentcontent4Extractentities and relationships,schema.org + domainontologies5Generate RDFTurtle by default,JSON-LD as an alternative6Saveto your localfile system7Uploadto local or remote Virtuoso instance viaWebDAV filesystem interface wheredoc URL becomes graph IRIcron · Claude Coworker · Codex Automations: next document+ triples+ triplesafter document 1after document 2after document NnewkeptAQueryDEFINE input:inference "…"DEFINE input:same-as "…"SELECT ?entity ?typeFROM <graph IRI>WHERE {  ?entity a ?type }BSPARQL endpointVirtuoso-backed;URIBurner is the defaultCNamed graphthe uploaded TurtleOntologiesschema.org, domainDReasonerinput:inferencesubclass closureinput:same-asowl:sameAs mergeinput:ifpshared-key mergeEQuery solutions?entity?typeArticle 1schema:ArticlePerson Aschema:PersonOrg Bschema:OrganizationAI agent via Data Twinglertabulated rows, entity IRIslinked through the resolverDescribe viewthe document URL shows itsSemantic Web representationFollow your nosehyperlinks lead to relatedentities and graphsFine-grained ABAC governs who can read the data spacePipeline per Kingsley Idehen’s LinkedIn article “Building on LLM Wikis”; query pragmas per Virtuosonext document · next question
Animated flow: build a KG from a document URL (steps 1 to 7), then produce query solutions (A to E) for an AI agent, a Describe view and follow-your-nose navigation.

How it works

How to build a KG from any document URL

Eight steps from selecting a document to a graph that grows with every further document.

  1. Select a document
    Choose a document that has a URL, using http: or file: addressing. Articles, PDFs and blog posts all qualify.
  2. Invoke an Agent Skill
    Run an Agent Skill defined in a SKILLS.md file, from an agent such as Claude or Codex.
  3. Fetch the content
    The skill fetches the content of the document at that URL.
  4. Extract entities and relationships
    The skill extracts entities and relationships, named using schema.org and other domain ontologies.
  5. Generate RDF
    The skill generates an RDF graph. Turtle is the default and JSON-LD an alternative; both are serializations of the same graph, which converts between them without changing its meaning.
  6. Save to your local file system
    Save the generated graph to your local file system.
  7. Upload through WebDAV
    Upload the saved file to a local or remote Virtuoso instance via its WebDAV filesystem interface, where the document URL becomes the graph IRI.
  8. Repeat for the next document
    A scheduler, such as cron, Claude Coworker or Codex Automations, repeats steps 1 to 7 for the next document. Each upload adds more triples to the graph; the terms in a triple are its components, so they are not a separate addition.

How to produce query solutions from the graph

Six steps from a SPARQL query to solutions that an AI agent, a Describe view and follow-your-nose navigation can use.

  1. A: Write the query
    A SPARQL query names the graph IRI in its FROM clause. It can also carry the pragmas input:inference, input:same-as and input:ifp, which are Virtuoso query options and not features that the article describes.
  2. B: Send it to a SPARQL endpoint
    Send the query to a SPARQL endpoint backed by Virtuoso. In this ecosystem URIBurner is the default endpoint.
  3. C: Read the named graph and the ontologies
    The endpoint reads the named graph that holds the uploaded Turtle, together with the schema.org and domain ontologies.
  4. D: Apply the reasoner
    The reasoner applies the pragmas: input:inference closes over subclass relations, input:same-as merges IRIs linked by owl:sameAs, and input:ifp merges entities that share an inverse functional property value.
  5. E: Return query solutions
    The endpoint returns rows of entities and types, each identified by an IRI.
  6. Use the solutions
    An AI agent receives tabulated rows through Data Twingler with entity IRIs linked through the resolver; a Describe view shows the document URL’s Semantic Web representation; and follow-your-nose hyperlinks lead to related entities and graphs.

Queries

Query with reasoning pragmas (illustrative)

The query shape in box A. The pragma values and the graph IRI are placeholders, so it is not executable as written.

DEFINE input:inference "…"
DEFINE input:same-as "…"
SELECT ?entity ?type
FROM <graph IRI>
WHERE {
  ?entity a ?type }

FAQ

It extends the LLM wiki idea, associated with Andrej Karpathy: an agent turns any document with a URL into a knowledge graph, the graph is saved and uploaded, and it is queried with SPARQL. Each further document makes the graph larger.

Any document that has a URL, using http: or file: addressing. Articles, PDFs and blog posts all qualify.

An Agent Skill is a reusable set of instructions that an agent such as Claude or Codex runs. The pattern defines it in a SKILLS.md file.

Entities and relationships, named using schema.org and other domain ontologies, which the skill then writes out as RDF.

Turtle is the default and JSON-LD an alternative. Turtle is only a default preference: RDF has other serializations, such as RDF/XML, N-Triples and N-Quads, and a graph converts between them without changing its meaning. Not every tool reads every serialization.

So the uploaded file is addressed by the URL it came from. A query then names that graph IRI in its FROM clause to target the triples of just that document.

More triples. The terms in a triple are its components, so a new document adds no terms separately from the triples that contain them.

A scheduler repeats the pipeline for the next document. The article names cron, Claude Coworker and Codex Automations.

With SPARQL sent to a SPARQL endpoint. The article’s example uses URIBurner.

They are Virtuoso query pragmas that switch on ontology-driven reconciliation: inference over subclass relations, merging of IRIs linked by owl:sameAs, and merging of entities that share an inverse functional property value.

No. The article says that explicit semantics reduce hallucinations but does not describe a reasoning mechanism, and it does not discuss entity reconciliation. The reasoner stage in Part 2 of this diagram comes from Virtuoso query pragmas.

An AI agent gets tabulated rows through Data Twingler, a Describe view shows the document URL’s Semantic Web representation, and follow-your-nose hyperlinks lead to related entities and graphs.

The article describes fine-grained attribute-based access control over the data space.

No. The query, the rows and the graph snippets are illustrative shapes. The snippets show a graph after document 1, document 2 and document N, with new nodes in orange and kept nodes in grey.

Glossary

LLM wiki
A pattern, associated with Andrej Karpathy, of raw files turned into a processed Markdown wiki and curated summaries. The Beyond LLM Wiki pattern adds a queryable knowledge graph.
Agent Skill
A reusable set of instructions, defined in a SKILLS.md file, that an agent such as Claude or Codex runs. Here it turns a document URL into a knowledge graph.
SKILLS.md
The file that defines an Agent Skill.
Knowledge graph
A graph of entities and the relationships between them, stored here as RDF.
RDF
A model that expresses statements as subject, predicate and object triples with globally identified terms.
Turtle
A compact text serialization of RDF and the default in this pattern. It is a default preference only: the same graph converts to JSON-LD, RDF/XML, N-Triples, N-Quads and other serializations without changing its meaning.
JSON-LD
A JSON serialization of RDF, named in the article as an alternative to Turtle.
schema.org
A shared vocabulary of types and properties used to name entities and relationships during extraction.
Ontology
A formal description of the classes and relationships in a domain. Here schema.org and domain ontologies guide extraction and feed the reasoner.
WebDAV
An HTTP extension for managing files on a remote server. Virtuoso offers a WebDAV filesystem interface for uploading the generated files.
Graph IRI
The IRI that names a graph. In this pattern the document URL becomes the graph IRI and a query’s FROM clause names it.
Triple
One statement of a graph: a subject, a predicate and an object. Its terms are its components.
SPARQL
The W3C query language for RDF.
SPARQL endpoint
A web service that accepts SPARQL queries and returns solutions.
Virtuoso
OpenLink’s server platform. Here it hosts the SPARQL endpoint, the WebDAV interface and the query pragmas.
Named graph
A graph identified by an IRI inside a triple store, so that a query can target the triples of one document.
Reasoner
Software that derives implied statements from an ontology. In Virtuoso, pragmas in the query switch it on.
owl:sameAs
An OWL property stating that two IRIs denote the same entity.
Inverse functional property
An OWL property class in which one value identifies at most one entity, so entities that share that value are the same entity.
Attribute-based access control
Access control decided by attributes of the user, the resource and the context.
Describe view
A page that shows what a graph holds about one IRI, such as the URL of a document.
Follow your nose
Navigating by following the hyperlinks of entities and graphs to related ones.
Data Twingler
An OpenLink skill that runs SQL, SPARQL, SPASQL, SPARQL-FED and GraphQL queries against live data spaces and tabulates the results.
URIBurner
OpenLink’s Virtuoso-backed Linked Data service, the default SPARQL endpoint in this ecosystem.
input:inference
A Virtuoso query pragma naming an inference rule set, so the query also sees statements implied by subclass and other ontology relations.
input:same-as
A Virtuoso query pragma that applies owl:sameAs links so that IRIs for one entity are treated as one.
input:ifp
A Virtuoso query pragma that applies inverse functional properties so that entities sharing a key value are treated as one.

Notes

Sources