Papers
Topics
Authors
Recent
Search
2000 character limit reached

KG-Based RAGAS: Ontology-Driven Generation

Updated 4 February 2026
  • Knowledge-Graph-based RAGAS is an integrated architecture that combines ontology learning, KG population, and advanced LLM retrieval to achieve high accuracy (~90%) through chunk enrichment.
  • It leverages automated ontology extraction from both relational schemas and textual corpora to build maintainable and precise knowledge graphs.
  • Hybrid retrieval using PCST and vector approaches optimizes query handling, offering demonstrable improvements in precision, cost efficiency, and service scalability.

Knowledge-graph-based Retrieval-Augmented Generation As A Service (RAGAS) denotes a class of architectures unifying ontology learning, knowledge graph (KG) population, graph-centric retrieval, and LLM-based generation with explicit support for service-level deployment and efficiency tracking. The defining innovation is the systematic integration of ontology-driven, chunk-enriched KGs—built from structured (e.g., relational database schemas) or unstructured (text) sources—with advanced retrieval algorithms that exploit both semantic and topological signals. This yields demonstrable gains in answer accuracy, cost efficiency, and maintainability relative to vector-only or text-only RAG, as empirically established in recent comparative studies (Cruz et al., 8 Nov 2025).

1. Ontology Learning and KG Construction Paradigms

Ontology learning for RAGAS proceeds from either relational database (RDB) schemas or natural language corpora.

  • RDB-driven approach: Extraction begins with DDL, primary/foreign key analysis, and (optionally) schema alignment to domain ontologies (e.g., DINGO). An LLM, in deterministic (temperature=0) mode, receives schema definitions, naming conventions, and labeling guidelines to emit ontology fragments in TTL or OWL2 Manchester syntax. The “delta” ontologies (one per table or schema change) are merged iteratively using RDFLib, yielding a consistent domain ontology. This process is one-off for stable RDBs, amortizing cost and eliminating repeated LLM prompting.
  • Text-driven approach: The unstructured corpus is chunked (sentence- or paragraph-level). Each chunk is LLM-prompted for candidate classes, relations, and constraints in TTL form. Parsing errors trigger auto-repair and re-submission. Merging is done via lexical matching or light alignment ontologies, but must be repeated if the corpus evolves.
  • KG population and chunk enrichment: The extracted ontology is loaded as an RDF schema and instantiated with entities and relations identified from the corpus. Chunk-level context can be integrated into node attributes—either as plain text or as references. Empirical results show that enriching nodes with associated chunk text increases accuracy on factual QA from 20–30% to ~90% (out of 20) (Cruz et al., 8 Nov 2025).

2. Indexing, Retrieval Algorithms, and Mathematical Formulations

The RAGAS platform supports both baseline vector retrieval and advanced KG-based retrieval.

  • Vector RAG: Each text chunk is embedded with a SentenceTransformer or nomic-embed model; FAISS (or similar) provides cosine-similarity kNN search. Retrieval and generation proceed as in conventional RAG, with sim(u,v)=(uv)/(uv)(u, v) = (u\cdot v) / (\|u\|\|v\|).
  • KG Store: The KG is indexed as two tables (nodes with text/chunk attributes, labeled edges). Node embeddings are computed once for hybrid (semantic+graph) retrieval.
  • KG Retrieval via PCST:
    • Nodes: Each node vv is assigned a “prize” pvsim(query,v)p_v \propto \text{sim}(\text{query}, v).
    • Edges: All edges ee are undirected with uniform cost cec_e.
    • Subgraph selection: Solve the Prize-Collecting Steiner Tree (PCST) problem:

    maximizeTKG(vTpveTce)\text{maximize}_{T\subseteq KG} \left(\sum_{v\in T} p_v - \sum_{e\in T} c_e\right)

    TT must be connected. The selected subgraph is serialized (triples with chunk text) for LLM input.

  • GraphRAG alternative: Use community detection, local/global searches, and entity linking to dynamically select a context subgraph.

  • Retrieval metrics: Precision@k, Recall@k, and Mean Reciprocal Rank (MRR) are defined as standard.

  • Token/Cost Model: Total cost per query is

total=(Tincin+Toutcout)/1000\text{total} = (T_\text{in} \cdot c_\text{in} + T_\text{out} \cdot c_\text{out}) / 1000

with TinT_\text{in} and ToutT_\text{out} denoting input and output token counts and cc indicating per-1K-token prices.

3. Comparative Empirical Results

Comprehensive evaluation on a 20-question set (Cruz et al., 8 Nov 2025) demonstrates the following:

Method Correct Incomplete Wrong "I don't know"
Vector RAG (FAISS+chunks) 12 4 3 1
GraphRAG (comm. & search) 18 1 1 0
Text-Ontology KG (no chunks) 3 6 7 4
RDB-Ontology KG (no chunks) 4 5 2 9
Text-Ontology KG (with chunks) 18 1 1 0
RDB-Ontology KG (with chunks) 18 1 1 0
  • KGs lacking chunk enrichment answer only 15–20% correctly.

  • Chunk integration elevates KG-based methods to 90% accuracy, matching or exceeding GraphRAG, with vector RAG lagging at 60%.

  • RDB ontology learning incurs a one-time LLM cost (8K tokens → $0.24) versus text-ontology learning ($12 per 50 new documents).

4. Practical Recommendations and Service Design

For robust, service-oriented RAGAS deployments, the following best practices are recommended (Cruz et al., 8 Nov 2025):

  • Chunking: Employ overlapping sliding windows (e.g., 200 words, 50-word overlap). Attach metadata (source, paragraph index, page no.) to each chunk and store it in node attributes for provenance.

  • Incremental updates: RDB-derived ontologies usually remain static, but for text-based, monitor for novel or changed concepts, automate merging and conflict detection, and flag below-threshold alignments for human review.

  • Query handling: Select KG+chunk retrieval for high-value or hallucination-sensitive queries (legal, finance); use vector RAG for ad-hoc low-value queries. Adjust kk dynamically based on cost constraints and required precision.

  • Ontology building: RDB-driven KGs require less frequent LLM usage and avoid complex ontology merging inherent to text-based corpora.

  • Maintenance: Automate TTL merging and alignment. For scaling, explore hybrid vector+KG indexing or approximate PCST heuristics.

5. Limitations, Trade-offs, and Open Directions

Key limitations and open problems identified include:

  • Scalability: PCST is polynomial but becomes slow for large V,E|V|,|E|, motivating studies on approximate algorithms.

  • Dynamic corpora: Text-based ontologies need robust, automated merging pipelines as underlying content changes.

  • Retriever sophistication: While heuristic PCST suffices for controlled isolation of KG quality, GNN-based retrievers may further improve multi-hop reasoning performance.

  • Future research:

    • Automated ontology alignment for heterogeneous and multilingual domains.
    • Adaptive retrieval strategies blending vector, graph, and textual signals.
    • Cost-aware query planners that optimize for precision, recall, and resource usage per query and domain.
    • Extension to multimodal KGs (integration of visual, temporal, or code elements).

These advances would further increase both the factual faithfulness and the deployment scalability of RAGAS architectures.

6. Broader Impact and Generalization

The RAGAS paradigm, as formalized in (Cruz et al., 8 Nov 2025), enables practitioners to construct cost-efficient, maintainable, and highly accurate retrieval-augmented generation systems by leveraging ontology-driven KG construction—especially from stable relational schemas—and enriching node representations with chunk-level context. This approach generalizes across domains where high precision and provenance are critical, providing a blueprint for scalable knowledge-intensive LLM applications in enterprise or scientific settings. The methodology underscores the importance of ontology learning, fine-grained node design, and directly tying graph structure to both retrieval logic and prompt assembly for LLMs.

Definition Search Book Streamline Icon: https://streamlinehq.com
References (1)

Topic to Video (Beta)

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Knowledge-Graph-based RAGAS.