Natural Language to SPARQL Generator
Type a question in plain English - “films directed by Christopher Nolan”, “how many children did Bach have”, “largest country” - and the tool matches it to a query template, grounds the mentions to real Wikidata entities and properties, compiles a SPARQL query, runs it against the live Wikidata Query Service, and shows you the answer, the generated query, and an Explain panel of exactly how it got there.
The design choice that shapes everything is deterministic-first: rather than handing the whole problem to a language model, it uses transparent templates plus a curated lexicon and live entity linking, then over-generates candidate queries and keeps whichever actually returns results (the QAnswer idea). When a name is ambiguous - “Inception” the concept versus the film - the runner-up links are surfaced as clickable chips; one click re-runs the query pinned to the sense you meant. An optional LLM parser can be switched on with your own key, but it only fires when no template matches, and even then it emits the same structured match the templates do - never raw SPARQL - so grounding and validation stay deterministic.
It isn’t limited to Wikidata. Upload your own ontology (Turtle, RDF, OWL) and it is parsed into an
in-browser triple store with a fuzzy label index, then queried the same way - entirely client-side,
no server. A multi-source engine routes each question to the source that best resolves its terms
(“which graph should answer this?”), you can register additional SPARQL endpoints for the built-in
editor, and every generated query is editable and re-runnable, federated SERVICE blocks included.
The whole thing is built on a source-agnostic intermediate representation, so a query means the same
thing whether it lands on Wikidata, your ontology, or several sources at once.
Like the Ontology Explorer, this app lives in its own repository (kglabs) with its own build pipeline, linked into this site as a git submodule and mounted as static files, so it can move to its own domain later without touching anything but this page’s demo link.