Home/Lab/Enterprise Hybrid RAG/How It Works
How It Works

An LLM is not an enterprise system of record

Structured retrieval provides exact facts. Vector RAG retrieves relevant knowledge. Ontology defines what enterprise concepts mean. A knowledge graph connects those concepts. Graph RAG retrieves the relationships relevant to the question. Deterministic rules protect critical business decisions. The LLM brings all of this context together and turns it into a useful customer-service response.


1. What an LLM knows

A large language model contains broad, learned knowledge from its training data. It does not automatically know today’s enterprise transactions, a specific customer’s contract terms, the latest policy revisions, an invoice’s payment status, or anything sitting in an internal SAP or CRM system. Ask it about a real invoice and, left alone, it will either say it doesn’t know, or, worse, guess.


2. What is RAG?

Retrieval-Augmented Generation closes that gap: before the model answers, the system retrieves relevant knowledge and hands it to the model as context.

Question
Retrieve relevant enterprise knowledge
Give question + retrieved knowledge to the LLM
Generate a grounded response

3. Six retrieval patterns, one agent

Different knowledge should be retrieved differently

Vector RAG
Used in this lab: policy document retrieval, via a TF-IDF similarity index

Rank passages by similarity to the question rather than exact keyword match. A question about a return policy retrieves the passages of policy text closest in meaning, even if the exact words differ.

Metadata-Filtered RAG
Used in this lab: narrowing candidate chunks by tier, region, and policy type before ranking

Semantic retrieval filtered first by structured metadata: distributor tier, region, or policy type, so the search only ranks the chunks that could actually apply.

Hybrid Search RAG
Not used in this lab

Semantic retrieval plus a separate traditional keyword index, useful when exact terms (a SKU, a policy name) need to match as much as meaning does. This lab's single TF-IDF index already blends term overlap into its similarity score, but there is no separate keyword-index layer alongside it.

Structured RAG
Used in this lab: invoices, sales orders, returns, and credit memos, looked up by ID

Retrieve exact information from structured sources, like an invoice amount, a quantity, or a date, by lookup, not by similarity.

Graph RAG
Used in this lab: resolving which policy applies to a distributor's tier and contract, or a product's warranty

Retrieve knowledge through relationships between entities: a distributor connects to a contract, which connects to a policy.

Agentic RAG
Used in this lab: the router choosing which retrieval mechanisms a given question actually needs

The LLM chooses and combines multiple retrieval mechanisms depending on the question, rather than always running the same fixed retrieval step.


What breaks without each layer
Remove thisWhat goes wrong
Structured retrievalThe model invents invoice amounts, dates, and quantities instead of looking them up.
Knowledge graphThe wrong tier's policy gets applied. Similarity picks a plausible-sounding policy, not the contracted one.
Rules engineThe model can approve a return that fails the eligibility rules, or state a refund amount it never actually calculated.
Vector RAGThe model paraphrases policy from training-data memory instead of citing the actual, current policy text.

4. What is an ontology?

An ontology defines the important things in a business and how those things relate to one another. It gives business meaning to otherwise disconnected records.

DistributorHAS_CONTRACTContract
ContractUSES_POLICYPolicy
SalesOrderCONTAINSProduct

5. Ontology → Knowledge Graph → Graph RAG
Ontology
What kinds of things exist, and how can they relate?
Knowledge Graph
Here are the actual entities and relationships: Dallas Power Distributors, Contract C-004, Gold Tier.
Graph RAG
Retrieve the relationships relevant to this question, such as which policy applies to this distributor.
LLM
Reason over the retrieved context and explain the outcome.

In this lab: Dallas Power Distributors → Contract C-004 → Gold tier → Gold Distributor Return Policy, and AGM-100 → AGM Battery Warranty Policy. See it live on the Graph tab of the evidence panel.


6. Where this connects to SAP

This lab intentionally simplifies a real enterprise architecture. In production, the equivalent retrieval layer might reach into S/4HANA, Salesforce, SharePoint, a contracts repository, a data warehouse, and a real graph database.

Enterprise AI Agent
SAP Data
Vector RAG
Knowledge Graph
Transactions
Policies
Relationships
LLM
Customer Answer
ProductMaterial Master
DistributorCustomer Master
Sales OrderSAP Sales Order
InvoiceBilling Document
ReturnReturn Order
Credit MemoCredit Memo
SupplierVendor / Business Partner
Purchase OrderSAP PO

← Back to the interactive lab