arXiv:2610.36335cs.AIOct 2026

Manuscript Offprint

arXiv:2610.36335

OA-RAG: Ontology-based Agentic RAG for Faithful LLM Reasoning

Hui Yang, Jiaoyan Chen, Yongsheng Gao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Large language models (LLMs) perform well across many real-world tasks but remain prone to hallucination, limiting their reliability in domains such as biomedicine and healthcare, where answers must be grounded in established knowledge. Retrieval-augmented generation (RAG) mitigates this problem by incorporating external information, but often overlooks logical relationships and relies heavily on the LLM's own reasoning, which can compromise answer faithfulness. We propose OA-RAG, an agentic framework that integrates formal reasoning with LLM reasoning, drawing on both the logical structure and informal annotations of domain ontologies. For each answer, OA-RAG reports the ontology observations used as evidence and a grounding level (entailed, supported, related, or unrelated) that characterises the evidence's faithfulness. Across benchmarks derived from three large-scale ontologies and six real-world medical question-answering tasks, OA-RAG achieves the best overall performance among the evaluated ontology-finetuned and popular RAG methods, with particularly strong results on reasoning-intensive tasks. The reported grounding levels also offer a useful indication of answer reliability, with stronger grounding generally associated with higher accuracy. Finally, our results demonstrate the value of ontologies as knowledge sources: OA-RAG is competitive with, and sometimes outperforms, domain-specific RAG systems that draw on sources such as textbooks.

1 Introduction

Large language models (LLMs) have demonstrated strong capabilities across a wide range of knowledge-intensive tasks. However, their answers remain constrained by the knowledge encoded in their parameters and may contain hallucinations, that is, plausible but factually incorrect statements [19,20][19, 20]. Their reliability is further limited by the lack of transparent reasoning and by gaps in domain- or organization-specific knowledge.

Retrieval-augmented generation (RAG) augments LLMs by prompting with external evidence extracted from documents [9], tables [52], and knowledge graphs [31], while tool-using agents enable more adaptive, dynamic and autonomous access to such sources [32, 44, 49, 60]. However, existing methods mainly leverage textual and structured knowledge, leaving explicit logical knowledge under-utilised. Consequently, logical inference still relies heavily on the LLM's internal reasoning, which can make its conclusions less faithful to the given knowledge.

Meanwhile, many scientific and biomedical domains already provide rich shared, explicit and formal knowledge through ontologies in Semantic Web standards like Description Logic underpinned OWL (Web Ontology Language) [18, 46]. These ontologies on the Web, such as the Gene Ontology (GO) [1], FoodOn [8], and

Figure

Figure 1: Three ontology-augmented LLM reasoning patterns, ordered from greatest to least faithfulness to the ontology: (a) the answer is can be inferred from the ontology’s formal axioms; (b) an LLM can infer the answer based on the ontology’s formal axioms and informal annotations; and (c) an LLM generates the answer freely, with optional grounding in relevant ontology content (classic RAG).

SNOMED CT [7], encode domain concepts and relations using Description Logic axioms, allowing dedicated reasoners to derive implicit relations soundly and efficiently [3]. Moreover, ontologies can contain rich textual annotations, including definitions and comments, providing informal but relatively important and complementary domain knowledge. This combination of formal semantics and textual annotations motivates our central question:

Can ontologies bridge formal reasoning and LLM reasoning to produce more faithful answers to domain-specific questions?

According to the knowledge used, answering domain-specific questions utilising LLM and ontology may include the following three reasoning patterns, as illustrated in Figure 1:

• Formal reasoning: the answer is faithful to the ontology’s formal axioms and can be derived by a symbolic ontology reasoner.

• Ontology-grounded LLM reasoning: the answer is faithful to the ontology’s formal axioms and informal annotations (e.g., natural language labels and definitions), and requires an LLM for inference based on these ontology’s information.

• Ontology-assisted LLM reasoning: the answer is not faithful to the ontology, and the LLM reasoning relies on the LLM’s parametric knowledge as well.

Importantly, the appropriate reasoning pattern is not known in advance and may vary across questions, requiring the system to adaptively select among the three reasoning strategies.

To address this question, we propose OA-RAG, an agentic framework that combines ontology reasoning with LLM reasoning in three stages (§4): (1) pre-tool reasoning using the LLM's parametric knowledge; (2) ReAct-based querying, where logical inference results and textual annotations are accessed via SPARQL; and (3) answer generation, which consolidates the evidence, and reports the ontology evidence supporting the answer with a grounding level (§4.1.3). Rather than treating the retrieved evidence as equally informative, the four levels distinguish evidence that logically entails the answer (entailed), supports the answer without strictly entailing it (supported), is merely relevant (related) to the answer, or is irrelevant (unrelated) to the answer. This reflects the answer's faithfulness to the ontology, where entailed, supported and related correspond to formal reasoning, ontology-grounded LLM reasoning and ontology-assisted LLM reasoning in Figure 1, respectively.

We developed an automatic procedure for constructing evaluation datasets for the first two patterns—formal reasoning and ontology-grounded LLM reasoning—using three large-scale, real-world ontologies: GO, FoodOn, and SNOMED CT. For the third pattern, we evaluated OA-RAG on six real-world medical question-answering tasks following the experimental setup of OntoTune [29]. Our main contributions are as follows:

  • We propose trustful LLM reasoning based on ontology’s both formal and informal knowledge, and develop an ontology-based agentic RAG framework OA-RAG, which answers a domain-specific question with evidence and their grounding levels.

  • We formulate ontology-based faithful LLM reasoning in terms of three patterns with ranging faithfulness, and construct a QA benchmark with corresponding datasets for comprehensive evaluation.

  • OA-RAG achieves strong performance across all three reasoning patterns. On the first two patterns, it outperforms the strongest baseline by 10–15 percentage points on average (44.3% vs. 28.9% with Llama-3-8B-Instruct; 59.7% vs. 49.7% with Qwen3.5-9B). On the third pattern, it remains competitive with specialized medical QA methods while using 10× fewer tokens than the strongest baseline with Qwen3.5-9B (9.7k vs. 96.7k per question).

References (24)