Source-linked AI summary
What Does an Ontology Catch? Curated, LLM-Generated and Data-Derived Ontologies as Checkers of LLM Agents over Knowledge Graphs
Michal Orzechowski, Rund Tawfiq, Tomasz Kosciolek
TL;DR
LLM agents can produce executable SPARQL that answers a different question, while ontology checks can miss errors or flag correct answers. This paper compares curated, LLM-generated, and data-derived ontologies as checks and as agent context. On UniProt, the curated ontology flags more correct answers than data-derived or masked LLM-generated ontologies, and its flags on real answers are only marginally more precise than random flags.
Problem
Ontology checks may accept wrong answers or flag correct ones, but existing ontology evaluation does not assess their suitability as judges of agent answers.
Source: §1 · p. 1Method
The study compares curated, LLM-generated, and data-derived ontology checks on the same real answers and artificial faults, and evaluates ontology use as context, checks, or both.
Source: §1 · p. 2, §4.6 · p. 5Results
On real agent answers, the curated ontology catches more wrong answers but most of its flags concern correct answers, and its flags are hardly more often right than random flags.
Source: RQ1: Curated checks raise more false… · p. 6Takeaways & Limitations
On UniProt, data-derived and masked LLM-generated ontologies raise fewer false alarms than the curated ontology, which can disagree with its graph’s published data.
Source: §6 · p. 8Confirmatory claims apply only to UniProt’s frozen questions, artificial faults, and ontologies; results on other graphs are exploratory.
Source: §6 · p. 8
Abstract
from arXiv · showhide
LLM agents that answer questions over Web knowledge graphs are increasingly wrapped in checks derived from the graph's ontology, on the assumption that a formal schema makes a reliable judge. Yet a checker can be wrong as well: it can miss errors, and it can flag correct answers and push the agent into "fixing" them. Whether a curated ontology is worth its cost as such a judge, and how it compares with an ontology an LLM writes or a schema mined from the data, is unknown. We make the checker itself the object of study. Across curated, LLM-generated and data-derived ontologies, used as prompt context, as a checker, or both, and across open-weight and proprietary agents on public graphs and a private graph of nearly $10^{9}$ triples, we account for what ontology-derived checks catch and what they wrongly flag. We show how each source trades caught errors against false alarms, how a curated schema used as published can contradict its own data, which errors structural checks miss, and whether combining sources or giving the agent the checker's specific feedback pays off. On UniProt, the curated ontology flags more correct answers than either an ontology derived from the data or one an LLM derives from a summary of the data with masked identifiers. On real agent answers, its flags are only marginally more precise than random flags.
1 Introduction
LLM-generated SPARQL can execute successfully yet answer a different question, and ontology checks can both miss errors and flag correct answers. This paper evaluates curated, LLM-generated, and data-derived ontologies as judges of agent answers, measuring both catches and false alarms.
1 Introduction
- Ontology checks can accept incorrect answers or flag correct ones, potentially prompting an agent to turn a correct answer into an incorrect one.Existing ontology evaluation methods do not address this judging role, where a violation may reflect an ontology error rather than an answer error.Source: §1 · p. 1
- The evaluation measures both errors detected and correct answers incorrectly flagged, rather than treating ontology violations as errors in the data by default.A violation can instead reflect an error in the ontology, causing a correct answer to be rejected.Source: §1 · p. 1
- The study asks how ontology sources trade off catches, false alarms, and setup and runtime costs, and what errors checks miss.It also examines ontology context, combined sources, and feedback after a check triggers.Source: §1 · p. 2
- The design tests real agent answers and artificially introduced faults, separates check-detected errors from errors exposed by query execution, and masks identifiers when LLMs derive ontologies from graph summaries.Each check judges the same answers and faults against pre-defined answers.Source: §1 · p. 2
- The study compares curated, LLM-generated, and data-derived ontologies as checks across five open-weight and two proprietary models, public graphs, and a private graph of nearly 10^9 triples.It also analyzes why checks fail and releases artificial faults, their pre-defined answers, and a protocol for measuring catches and false alarms against retrying on empty results.Source: §1 · pp. 1–2
2 Related Work
Prior work checks, constrains, or evaluates ontologies and agent answers in several ways, but typically does not assess ontology-derived checks by both their catches and false alarms on downstream agent answers.
2 Related Work
- Existing ontology-checking methods are commonly evaluated by overall response accuracy, whereas this study evaluates flags against correct answers to distinguish detected errors from false alarms.Related approaches include ontology-conflict checks that prompt revisions and restrictions to ontology terms represented in data.Source: §2 · p. 2
- Ontology axioms have been translated into SPARQL tests for data validation, while other work type-checks queries and rejects those whose results must be empty on any database.SHACL and ShEx provide languages for validating RDF data against structural constraints.Source: §2 · p. 2
- Ontology-based checks can flag correct answers when vocabularies omit terms or when combining vocabularies exposes conflicting definitions under a closed-world interpretation.Earlier work also found limitations in ontologies used to evaluate biological annotations.Source: §2 · p. 2
- Prior ontology and constraint generation work assesses schemas against reference schemas or data, not by their performance as checks on downstream tasks.Examples include LLM-generated shape schemas and shapes mined from knowledge graphs.Source: §2 · p. 2
- Evaluation design must account for artificial faults that may not represent real faults and for possible model recall of identifiers from public graphs.This study therefore evaluates checks on both real agent answers and artificial SPARQL faults.Source: §2 · p. 3
3 Ontologies as Checks
The paper standardizes ontology sources and their uses, then defines how checks flag answers and how those flags are scored and acted on. Its distinctions make explicit what a check can decide and how a retry is evaluated.
3.1 Ontology sources
- A data-derived ontology summarizes class instances and property subject/object classes, allowing patterns only when they occur at least five times; the LLM-generated ontology uses that summary plus sampled instances.The curated ontology is used as published, and the study also includes a no-ontology baseline.Source: §3.1 · p. 3
3.2 Ontology uses
- Each ontology is tested as prompt context, as a check, or in both roles, using a common rendering procedure and the same compiler for checks.This keeps source comparisons from reflecting differences in implementation.Source: §3.2 · p. 3
3.3 Check types
- Query checks test inferred types against domains, ranges, disjointness, and declaration requirements; data-derived checks additionally test patterns absent from the data.Binding checks test asserted types of bound resources, with collection limited to 10,000 triples per answer.Source: §3.3 · p. 3
3.4 Axiom interpretation
- The study distinguishes contradictions, which violate axioms under both open- and closed-world readings, from mismatches, which violate only the closed-world reading.A missing asserted domain type is a mismatch because OWL would instead infer that type.Source: §3.4 · p. 3
3.5 Check verdicts
- A check can pass, flag, return unknown when needed evidence is unavailable, or be inapplicable when no relevant axiom exists.Unknown answers are not flagged and do not trigger a retry.Source: §3.5 · p. 3
3.6 Scoring checks
- The scoring distinguishes caught wrong answers from missed wrong answers and false alarms on correct answers, reporting catch rate over wrong answers and false-alarm rate over correct answers.Figure 2 illustrates a caught answer, a false alarm, and a missed answer.Source: §3.6 · pp. 3–4, Figure 2 · p. 4
3.7 Retries
- A flagged answer triggers one retry, with either specific feedback identifying the failed constraint and query part or a generic re-check message.A retry that fails or abstains counts as wrong; fixed and corrupted outcomes measure the benefit of a flag and the risk of acting on a false alarm.Source: §3.7 · p. 4
4 Study Design
The study compares curated, data-derived, and LLM-generated ontologies as checks and context for agents, using generated questions, artificial query faults, and preregistered comparisons. It evaluates results across seven models, with confirmatory claims limited to UniProt and other-graph results exploratory.
4 Study Design
- Confirmatory claims focus on UniProt; results on other graphs, human-written questions, and analyses not registered in advance are exploratory.The claims, outcomes, tests, and margins were registered before test answers were examined.Source: §4 · p. 4
4.1 Graphs
- The study uses UniProt, Rhea and masked Rhea, a corporate graph, and a private graph of nearly 10^9 triples.UniProt supports all confirmatory claims; Rhea supports class-membership checks, and only rates are reported for the private graph.Source: §4.1 · p. 4
4.2 Ontologies
- Each graph has curated, data-derived, and LLM-generated ontologies plus a no-ontology baseline; UniProt LLM draws include masked-identifier variants.For UniProt, every ontology fits the shared token budget; masked draws are used only as checks.Source: §4.2 · p. 4
4.3 Questions and correct answers
- Questions come from seven graph-structure templates, with paired SPARQL queries defining correct answers and guards excluding ambiguous readings.UniProt has 210 test questions; the study also uses published UniProt and Rhea question–query pairs as a reference set.Source: §4.3 · pp. 4–5
4.4 Agents
- Seven proprietary and open-weight models answer through a SPARQL tool, with three independent attempts per model and condition.Turn and time limits are held constant across models.Source: §4.4 · p. 5
4.5 Artificial faults
- Artificial faults apply one operator to correct queries, covering invented identifiers, type swaps, and meaning changes; answer-preserving rewrites and correct queries measure false alarms.A flag counts as a catch only when a fault changes the answer; rates are also separated by whether faulty queries still return rows and compared with retrying on empty results.Source: §4.5 · p. 5
4.6 Claims and statistics
- The preregistered claims test ontology checks, prompt context, combined checks, and retry feedback, with weighted-Holm error control and calibrated paired cluster bootstraps.Inference is conditional on the seven frozen question templates, artificial faults, and ontology-generation recipe; several tests were expected to be inconclusive at their margins.Source: §4.6 · p. 5
4.7 Baselines
- Comparators include an LLM judge, SPARQL-LLM validation, published Ontology-based Query Check rules, and always-flag or never-flag checks.They run alongside the baseline that retries when a query returns no rows.Source: §4.7 · p. 5
5 Results
The results analysis combines real agent answers and artificial faults on UniProt, with exploratory per-answer rates and confirmatory comparisons weighted by question.
5 Results
- The real-answer analysis covers 4,410 answers to 210 UniProt test questions from seven models, of which 3,383 had checkable queries.Each question was attempted three times per model.Source: §5 · p. 6
- Artificial-fault rates pool 9,753 faults that change answers and 3,630 correct queries.Source: §5 · p. 6
- Confirmatory comparisons weigh questions equally and use 95% confidence intervals from a paired cluster bootstrap over questions.Source: §5 · p. 6
RQ1: Curated checks raise more false alarms than data-derived and masked LLM-generated checks
Ontology checks trade error catches against false alarms, and the trade-offs differ between real answers and artificial faults. The confirmatory artificial-fault comparisons favor the data-derived ontology on the registered measures, while design choices qualify that result.
RQ1: Curated checks raise more false alarms than data-derived and masked LLM-generated checks
- On real answers, curated checks catch more wrong answers than data-derived and masked LLM checks, but most curated flags concern correct answers and are hardly more precise than random flags.Data-derived and masked checks flag fewer correct answers but catch fewer than one in ten wrong answers.Source: RQ1: Curated checks raise more false… · p. 6
- Original-summary LLM ontologies vary across generations: two catch few errors, while a third catches more than the curated ontology but flags far more correct answers.Source: RQ1: Curated checks raise more false… · p. 6
- Every ontology catches a smaller share of errors in real answers than in artificial faults, where faults more often yield empty results than wrong agent answers do.Specific curated-check feedback fixes more than a quarter of flagged wrong answers but corrupts about one in a hundred flagged correct answers.Source: RQ1: Curated checks raise more false… · p. 6
- On artificial faults, the data-derived check raises fewer false alarms and catches more type swaps than the curated check by more than the registered 5-point margin; curated checks also exceed masked LLM checks in false alarms.No single ontology catches as many artificial faults as retrying on empty results, which raises no false alarm.Source: RQ1: Curated checks raise more false… · p. 6
- The registered type-swap advantage for data-derived checks is qualified by design: its ontology is built from the checked graph, and swaps come from its co-occurrence graph.The catch-rate difference arises for swaps four steps apart; a difference for two-step swaps is not established, and masked checks catch fewer faults with nonempty results than curated or data-derived checks.Source: RQ1: Curated checks raise more false… · p. 6
- An LLM judge catches more wrong answers than either ontology at a false-alarm rate similar to the curated check’s, but its flags are not more often right than random flags.Retries using the judge’s reasons corrupt more flagged correct answers than they fix wrong ones.Source: RQ1: Curated checks raise more false… · p. 6
- Invented identifiers and type swaps mostly yield empty results, while same-type constant swaps and meaning changes usually return rows and are caught less often than random flags at the curated check’s rate.Source: RQ1: Curated checks raise more false… · p. 6
RQ2: Domain, range and declaration checks raise the curated ontology’s false alarms, and ontology checks miss changes of meaning
The curated ontology’s domain, range, and declaration checks drive false alarms, while structural checks miss important semantic errors. Its published axioms can also conflict with the data they are meant to check.
RQ2: Domain, range and declaration checks raise the curated ontology’s false alarms, and ontology checks miss changes of meaning
- The curated ontology’s domain and range axioms raise false alarms, and requiring every query term to be declared raises them most; class membership and subsumption alone produce almost none.On real answers, domain and range checks flag correct and incorrect answers at similar rates, while class membership and term declarations do better than random.Source: RQ2: Domain, range and declaration… · pp. 6–7
- Curated ontologies disagree with their own data through logical contradictions in UniProt, omitted properties in Rhea, and mostly naming on the private graph.Most audited false alarms came from undeclared terms; most of the rest reflected a closed-world reading, and every audited false alarm was a correct answer.Source: RQ2: Domain, range and declaration… · p. 7, Table 5 · p. 7
- The curated, data-derived, and masked ontologies catch none of the artificial changes of meaning and few same-type constant swaps, although a random flag at the curated rate catches many of both.An LLM-generated ontology from the original summary catches 25.7% of changes of meaning and 17.2% of same-type swaps, but flags the most correct items; an LLM judge catches all 41 changes of meaning it judged.Source: RQ2: Domain, range and declaration… · p. 7, Table 4 · p. 7
- Most missed wrong answers followed a wrong graph path or used a wrong filter or scope, errors that almost no structural check could flag even over a correct schema.Table 6 reports a blind audit of sampled false alarms and missed answers, counting cases where both annotators agreed.Source: RQ2: Domain, range and declaration… · p. 7, Table 6 · p. 7
RQ3: Data-derived context does better; combining and specific messages show no gain
The paper compares ontology context, combined checks, and checker-specific retry feedback. Data-derived context performs better than curated context, while the other tested additions show no established gain.
RQ3: Data-derived context does better; combining and specific messages show no gain
- Pooled over seven models, data-derived ontology context yields higher accuracy than curated ontology context.Equivalence within 3 points was not established for Qwen3.8 and Sonnet, the two models fixed for that comparison in advance.Source: RQ3: Data-derived context does better;… · p. 8
- Combining curated and data-derived checks shows no established net detection gain: it catches more faults but raises more false alarms than either check alone.The combination does no better than the curated check alone and worse than the data-derived check alone.Source: RQ3: Data-derived context does better;… · p. 8
- Checker-specific retry messages do not detectably improve accuracy over a generic re-check request, whether models are weighted equally or by their flags.Specific feedback fixes more flagged wrong answers but also corrupts more flagged correct ones; the comparison bounds possible gains rather than showing they are absent.Source: RQ3: Data-derived context does better;… · p. 8
- Using data-derived context with the curated check yields small or no accuracy gains across seven models on UniProt, and smaller or negative changes on other graphs tested.These deployment-configuration results are exploratory.Source: RQ3: Data-derived context does better;… · p. 8
6 Discussion
The discussion cautions that published curated ontologies are not necessarily reliable checks and that false alarms and catches both matter in deployment. The paper’s confirmatory scope is limited to UniProt’s frozen questions, artificial faults, and ontologies.
6 Discussion
- On UniProt, data-derived ontologies and LLM ontologies from masked-identifier summaries raise fewer false alarms than the published curated ontology.The LLM-generated versions cost under one US dollar each; curated ontologies can disagree with their graph data, making a check unreliable unless it declares every data-used term and its axioms fit that data.Source: §6 · p. 8
- A data-derived summary can reveal where a curated ontology falls short, supporting release of summaries or their use to validate ontologies before each release.The curated ontologies studied do not meet the stated reliability standard.Source: §6 · p. 8
- For agent developers, compare a check with retrying empty-result queries and scrutinize false alarms as well as catches; the tested checks exceeded the cited 10% false-positive threshold by a wide margin on generated questions.In the likely deployment configuration, retries slightly improved accuracy on UniProt but yielded smaller gains or losses on other graphs tested.Source: §6 · p. 8
- Confirmatory claims apply only to UniProt’s frozen questions, artificial faults, and ontologies; the other graphs are exploratory, and private-graph results cannot be independently reproduced.The LLM-generated ontologies came from a single model, and the UniProt context difference was not replicated on Rhea.Source: §6 · p. 8
7 Conclusion and Future Work
Ontology checks can trade false alarms against caught errors, and the curated ontology’s real-answer flags are only marginally more precise than random. The paper also releases artificial faults for evaluating checks without running an agent, while noting that its measurements assume known correct answers.
7 Conclusion and Future Work
- The curated ontology raises more false alarms than data-derived or masked LLM-generated ontologies, and its real-answer flags are only marginally more precise than random.Combining the checks or giving the agent the check’s specific message showed no gain.Source: §7 · p. 8
- Artificial faults with pre-defined correct answers let researchers measure a check’s catches and false alarms without running an agent.Source: §7 · p. 9
- The measurements require knowing each question’s correct answer, unlike real use, where a flag is the only automatic sign that an answer may be wrong.The authors plan to apply the checks to agents supporting biologists analyzing a large graph of genomes, proteins, and computational predictions.Source: §7 · p. 9
A The replication package
- The replication package includes code, frozen inputs and configurations, model settings, run commands, and the analysis reproducing reported numbers; private-graph data and related materials are not released.Source: A The replication package · p. 10
B.1 The checks in detail
- The checks compile ontology rules into SPARQL queries over query bindings and tests on parsed queries; unsupported constructs such as UNION and subqueries receive an unknown verdict.The supported fragment includes basic graph patterns, OPTIONAL, negation, aggregates, and fixed-length paths; the numbers-traceable check uses no ontology.Source: §B.1 · p. 10, Table 7 · p. 10
B.2 The LLM-generated ontologies
The LLM-generated ontologies vary by model and differ structurally from the curated ontology. Across per-model checks and comparisons, the curated check often flags more correct answers, while evidence from human-written questions is less certain because few correct answers remain.
B.2 The LLM-generated ontologies
- The three masked LLM ontologies retain 87–90% of the data-derived ontology’s domain and range pairs, add no such pairs, and have Jaccard similarity 0.93 with it.Their domain and range overlap little with the curated ontology (Jaccard similarity 0.21–0.22); they add 73, 759, and 77 disjointness pairs.Source: §B.2 · p. 10
- On UniProt artificial faults, Opus ontologies catch 60.4% of answer-changing faults and flag 10.3% of untouched correct queries; DeepSeek catches 84.1% and flags 59.5%, while Qwen catches 81.9% and flags 61.0%.Source: §B.2 · p. 10
B.3 The cost of checking
- One retry after a curated flag costs more tokens and time than after a data-derived flag; the curated check’s specific message costs about as much as a generic re-check request.The time to build the data-derived ontology and the time a check takes were not recorded.Source: §B.3 · p. 10, Table 8 · p. 10
C.1 Per model and under the registered sensitivities
- Across six UniProt models with enough correct answers, the curated check flags more correct answers and catches more wrong ones than data-derived and masked LLM-generated ontologies.Time-out sensitivities leave registered decisions unchanged and move no estimate by more than 0.3 points; the data-derived ontology’s real-answer rates are identical at frequency thresholds 2, 5, and 20.Source: §C.1 · p. 10, Table 10 · p. 11
C.2 Comparators
- Combining curated and data-derived checks adds 3 catches at 28 more false alarms to the curated check, and 59 catches at 407 more false alarms to the data-derived check.On real answers, the LLM judge catches more wrong answers at about the data-derived ontology’s precision, but its flags corrupt more correct answers than they fix wrong ones when acted on.Source: §C.2 · p. 11, Table 11 · p. 11
C.3 Human-written questions
- On human-written UniProt questions, Sonnet’s curated check beats a random flag at its rate by 8.7 points (1.9 to 15.5), but on Rhea it does no better than random.False-alarm rates are not compared with generated-question rates because few correct answers remain.Source: §C.3 · p. 11, Table 12 · p. 11
C.4 The other graphs
On the exploratory graphs, curated checks flag many correct answers, while data-derived and LLM-generated checks often flag few. The context benefit of the data-derived ontology seen on UniProt does not consistently carry over.
C.4 The other graphs
- On Rhea, the curated check flags 23.2–63.0% of correct answers across six models, versus 15.1–19.2% on UniProt and more than any other ontology.The data-derived ontology and first two LLM-generated ontologies flag few; Rhea’s curated ontology declares no domain, range, or disjointness axioms, so only class and declaration checks apply.Source: §C.4 · p. 11, Table 14 · p. 12
- The data-derived ontology’s context advantage does not consistently transfer: on Rhea it yields higher accuracy only for Gemma and Qwen3-Coder, while the two are nearly equal for GLM.For Gemma, accuracy is 83.0% versus 40.6%; for Qwen3-Coder, 16.7% versus 9.4%.Source: §C.4 · p. 11
- On masked Rhea, LLM-generated ontologies stay within a few points of one another and the data-derived ontology, flagging few correct answers and catching few wrong ones; curated-check rates vary widely by model.Source: §C.4 · p. 11, Table 14 · p. 12
- On the corporate graph, curated checks flag 20.5–25.9% of correct answers, while data-derived and LLM-generated checks flag almost none.No model is less accurate with either ontology in the prompt.Source: §C.4 · p. 12, Table 14 · p. 12
- On the private graph, curated checks flag 56.3–72.8% of correct answers, while data-derived and LLM-generated checks flag almost none; among two models with enough wrong answers, only the curated check catches substantial shares.Aligning 115 curated terms to data identifiers took an expert three hours and raised the share of correct answers flagged to 69.7–85.1%.Source: §C.4 · p. 12
D Where false alarms come from
Layer-by-layer checks show that the data-derived ontology’s type-swap detection depends on a heuristic, while many of its false alarms come from co-occurrence checks. Audits identify causes of missed errors and false alarms, and closed-book probes show that agents’ query recall varies by graph.
D.1 The checks layer by layer
- Without the heuristic, data-derived class, domain, and range checks catch 37.2% of type swaps, versus 73.4% with it; most of that ontology’s false alarms arise from co-occurrence checks.On real answers, curated domain-and-range flags differ from random-flag precision by −1.2 points (95% CI −5.5 to 5.1), while class-membership and term-declaration flags differ by +8.0 points (1.8 to 15.3).Source: §D.1 · p. 12
D.2 The audit
- In the audited sample, every private-graph false alarm came from an undeclared term, and no missed private-graph answer could be flagged by a structural check.Two annotators coded 145 answers; agreement varied by coding dimension, with Cohen’s κ from 0.33 to 0.79 across the reported measures.Source: §D.2 · pp. 12–13
D.3 Recognising a graph’s vocabulary
- Closed-book answers are exact for at most 9.8% of questions on any public graph and 1.1% on the private graph, while query recall is substantial for some models on UniProt and Rhea but almost absent on masked Rhea.Four models’ low query scores do not by themselves show absent recall because many replies contained no usable query; all models’ accuracy falls on masked Rhea.Source: Table 15 · p. 12, §D.3 · p. 13