SysArt
Book a briefing
SysArt

Private LLMs and RAG

Knowledge Graphs for On-Premises RAG: Structured Retrieval Beyond Vector Search

When to add a knowledge graph to on-premises RAG: relationship queries, hybrid graph and vector retrieval, building the graph from enterprise data and upkeep.

Last reviewed by SysArt AI Architecture Team6 min readHow we review

In short

A knowledge graph stores entities and their relationships explicitly, so retrieval can follow links that vector similarity cannot, such as which products depend on a given supplier. In on-premises RAG it works best alongside vector search: the graph answers structural questions and narrows the search, while vectors find relevant passages in unstructured text.

Key takeaways

  • Vector search finds passages similar to a question; a knowledge graph answers questions that depend on explicit relationships, hierarchies and constraints.
  • Hybrid retrieval combines graph queries, graph-guided vector search and plain vector search, then merges the ranked lists, for example with reciprocal rank fusion.
  • Build the graph from structured and semi-structured sources first; extraction from free text makes errors and needs confidence scores and review.
  • Treat model-generated graph queries as untrusted output: validate them, allow read operations only and run them under a read-only account.
  • Every edge needs a source and a timestamp, and graph traversal needs the same access rules as the documents it describes.
Abstract network visualization with connected nodes and lines representing structured data relationships

Where does vector-only retrieval fall short?

Vector search finds passages that are semantically similar to a question, but it cannot follow explicit relationships between things. Ask which products were affected by a supplier change announced in the third quarter, and a vector search may return passages that mention the products, the supplier and the quarter separately, without the chain that connects one supplier change to specific products.

Research on graph-based retrieval points to a second gap. Edge and colleagues, who described the GraphRAG approach in 2024, found that standard retrieval-augmented generation (RAG) fails on global questions about an entire corpus, such as the main themes in a dataset, because those are summarisation tasks rather than lookups.

In regulated settings both gaps matter, because an answer assembled from loosely related passages can sound right and still be wrong. If RAG is new to you, our explainer on retrieval-augmented generation covers the basics.

What does a knowledge graph add to RAG?

A knowledge graph represents information as entities, such as people, products, processes and documents, and as typed relationships between them, such as authored_by, depends_on, supersedes or applies_to. Meaning is stored as explicit structure that can be traversed, rather than as positions in a vector space.

In a RAG pipeline, that structure supports retrieval that similarity search cannot express:

  • Following relationship chains, such as all documents written by engineers who worked on a given project.
  • Applying constraints, such as requirements that apply to European operations but are not yet covered by a completed audit.
  • Providing provenance: each fact comes with the path that led to it, which makes the retrieval decision easier to audit.

Graphs and vectors are complementary. Sarmah and colleagues combined them in HybridRAG, retrieving context from both a vector database and a knowledge graph built from financial earnings call transcripts, and reported better retrieval and answers than either approach alone. Results from one domain do not transfer automatically, but the direction is consistent: use the graph for structure and vectors for unstructured text.

How does hybrid graph and vector retrieval work?

A practical hybrid design runs up to three retrieval paths and merges the results before the language model sees them.

  1. Vector retrieval: standard semantic search over document chunks, for broad or loosely phrased questions. Our post on vector database architecture covers the options.
  2. Graph retrieval: the question is translated into a graph query, in Cypher for a property graph or SPARQL for an RDF store, to answer questions about relationships, hierarchies and dependencies. A language model can draft the query from the schema, but its output must be treated as untrusted. The OWASP Top 10 for LLM Applications 2025 lists improper output handling (LLM05) and advises treating the model like any other user, validating its output and using parameterised queries. Check generated queries against the schema, allow read operations only and run them under a read-only account.
  3. Graph-guided vector retrieval: the graph expands or narrows the vector search. A question about a named project can be expanded with its sub-projects and team members, or restricted to documents linked to one department.

Merging the results. Reciprocal rank fusion (RRF) is a simple way to combine ranked lists from different retrievers: each document scores the sum of 1/(k + rank) across the lists it appears in. Cormack, Clarke and Büttcher introduced it in 2009 with k fixed at 60. In their TREC experiments it scored higher than Condorcet fusion in every case and than the best individual run in all but one, and because it combines ranks, the retrievers’ different scoring scales do not need to be comparable.

How do you build the graph from enterprise data?

Building and maintaining the graph is harder than querying it. Enterprise data sits in wikis, document management systems, ticketing tools, code repositories and databases, and most relationships are implicit. A pragmatic approach uses three extraction layers:

  • Structured sources. Databases, ERP and CRM systems already hold explicit relationships. Extract them with ordinary ETL pipelines; this is the most reliable graph data you will get.
  • Semi-structured sources. Ticketing systems, project tools and documents with rich metadata have fields that map cleanly to entities and relationships. Use the metadata rather than relying only on free text.
  • Unstructured sources. Documents, meeting notes and emails need named entity recognition and relation extraction, with open-source NLP libraries such as spaCy or with a language model, as GraphRAG does. Expect errors: keep a confidence score on extracted facts and send low-confidence extractions to human review rather than ingesting them silently. Language-model extraction also uses GPU capacity at ingestion time; estimate it with the LLM GPU sizing calculator.

Start with structured and semi-structured sources, and define a bounded domain, such as the product catalogue, a regulatory framework or the organisation structure. Depth in one domain is easier to keep accurate than breadth across the whole enterprise.

How do you keep the graph current and trustworthy?

A graph that drifts out of date gives wrong answers with convincing provenance, so freshness has to be engineered:

  • Change data capture from source databases feeds entity and relationship updates into the graph; for documents, detect new or changed files and re-run extraction.
  • Provenance on every edge: a source reference and a timestamp, so consumers can judge freshness and auditors can trace a fact back to its origin.
  • A conflict policy decided in advance: when a CRM and a ticketing system disagree, a deterministic rule decides which source wins, or both assertions are kept with their sources.
  • Validation jobs that look for orphaned nodes, contradictory edges and entities not updated within a staleness threshold. Send the findings to data stewards rather than deleting automatically, because deletions in a graph can cascade.
  • Access control. A graph can reveal relationships between documents a user is not allowed to read. Apply the same entitlements to graph traversal as to document retrieval, as described in our post on policy-enforced RAG boundaries.

Which graph database fits an on-premises stack?

Start with a property graph unless you need formal ontologies; for many engineering teams, Cypher-style queries over a property graph are the easier starting point. Two options fit common on-premises stacks:

  • Apache AGE adds graph functionality to PostgreSQL as an extension. It supports PostgreSQL 11 to 18, accepts queries in SQL and Cypher, and is licensed under Apache 2.0. If you already use PostgreSQL with pgvector, relational data, vectors and the graph can live in one database.
  • Neo4j Community Edition is a dedicated property graph database distributed under GPL v3. Check the licence implications with your legal team before building on it.

RDF triple stores queried with SPARQL suit teams that need formal ontologies or standard vocabularies shared with other organisations.

How do you know the graph is worth the extra system?

Measure it. Build a question set from real user queries, including questions that depend on relationships, and compare hybrid retrieval with vector-only retrieval on precision, recall and the rate of answers that sound plausible but are structurally wrong. If the graph does not improve the questions your users actually ask, it is not worth the extra infrastructure. Our post on on-premises RAG evaluation describes the evaluation set-up, and our enterprise RAG page describes how SysArt implements retrieval on infrastructure the client controls.

Featured image by A Chosen Soul on Unsplash.

Frequently asked questions

What is GraphRAG?

GraphRAG is an approach described by Edge and colleagues in 2024. A language model extracts an entity knowledge graph from source documents and pre-generates summaries for groups of closely related entities. Those summaries help answer global questions about a whole corpus, which standard RAG handles poorly. The authors reported more comprehensive and diverse answers than a conventional RAG baseline on datasets of around one million tokens.

Do knowledge graphs replace vector search in RAG?

No, they are complementary. Vector search is good at fuzzy matching across unstructured text; a graph is good at precise questions over defined relationships. Research that combines them, such as HybridRAG on financial earnings call transcripts, reported better retrieval and answers than either vector or graph retrieval alone. Test the combination on your own questions before adding another system to run.

Which graph database fits an on-premises RAG stack?

If you already run PostgreSQL, Apache AGE adds graph functionality as an extension, supports PostgreSQL 11 to 18, accepts SQL and Cypher queries, and is licensed under Apache 2.0. Neo4j Community Edition is a dedicated property graph database distributed under GPL v3, so check the licence implications. RDF triple stores queried with SPARQL suit teams that need formal ontologies.

Is it safe to let a language model write graph queries?

Only with controls. The OWASP Top 10 for LLM Applications lists improper output handling as a risk and advises treating the model like any other user: validate its output and use parameterised queries for database operations. Check generated queries against the schema, allow read operations only, run them under a read-only account, and apply the same access rules as for document retrieval.

How do you keep a knowledge graph current?

Feed changes from source databases into the graph through change data capture, re-extract documents when they change, and store a source reference and timestamp on every edge. Decide in advance which source wins when two disagree. Run regular validation jobs for orphaned nodes, contradictory edges and stale entities, and send the findings to data stewards rather than deleting automatically.

Related insights

Plan your private AI with people who build it

Book a briefing. We look at your use case, data and constraints, and you leave with the deployment options and governance steps that fit.