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.
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.
- Select a document
Choose a document that has a URL, using http: or file: addressing. Articles, PDFs and blog posts all qualify. - Invoke an Agent Skill
Run an Agent Skill defined in a SKILLS.md file, from an agent such as Claude or Codex. - Fetch the content
The skill fetches the content of the document at that URL. - Extract entities and relationships
The skill extracts entities and relationships, named using schema.org and other domain ontologies. - 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. - Save to your local file system
Save the generated graph to your local file system. - 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. - 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.
- 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. - 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. - 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. - 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. - E: Return query solutions
The endpoint returns rows of entities and types, each identified by an IRI. - 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.
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
- Part 1 follows the pipeline in Kingsley Idehen’s LinkedIn article “Building on LLM Wikis”: select a URL, invoke an Agent Skill, fetch, extract with schema.org and domain ontologies, generate RDF, save, then upload so the document URL becomes the graph IRI.
- Each further document adds more triples to the graph; terms are components of those triples.
- The reasoner stage in Part 2 (input:inference, input:same-as, input:ifp) reflects Virtuoso query pragmas, not the article, which does not describe reasoning.
- The query, the result rows and the graphs are illustrative shapes, not output from a live run.
Sources
- Building on LLM Wikis. LinkedIn article by Kingsley Idehen that describes the pipeline from a document URL to a queryable knowledge graph. Publication date not retrieved.