Skip to content

Retrieval-Augmented Generation (RAG) is an AI approach that helps language models by integrating a retrieval mechanism that fetches relevant external information in real time. This information allows the model to generate more accurate, up-to-date, and context-aware responses beyond its pre-trained knowledge.

A registered RAG in GGX has two main parts:

  • Knowledge Source — a repository of external information: documents, vector databases, knowledge graphs like Neo4j, or other structured/unstructured data sources.
  • Retrieval Logic — code that fetches the most relevant information from the knowledge source based on the provided inputs.

RAG anatomy: a query flows into retrieval logic, which draws on a knowledge source — uploaded file, vector database, knowledge graph, or document store — and returns the retrieved information.

A query flows into retrieval logic, which draws on a knowledge source and returns the retrieved information.

A worked example: a card-policy knowledge base

Section titled “A worked example: a card-policy knowledge base”

To make this concrete, picture kb — a RAG over a bank’s card-servicing policy documents. It is the same kb that the card-replacement assistant calls whenever a customer asks to replace a lost card. On its own, kb does exactly one job: given a question, return the most relevant policy passages.

  1. A query arrives — e.g. “How long does a replacement card take?”
  2. The retrieval logic embeds the query and searches the knowledge source (a vector index built from the policy PDFs).
  3. It returns the top-K passages — the grounding a downstream pipeline feeds to its model.

Because kb is registered on its own, any pipeline can reuse it — the same knowledge base could ground a card-servicing chatbot, an email-triage tool, or an internal policy-search widget.

PartWhat it holdsRequired?
Retrieval LogicCode that fetches relevant information from the knowledge source based on the inputs.required
Knowledge SourceA repository of external information — documents, vector databases, knowledge graphs.Uploaded for Custom; configured via API for API-Based
Input ArgumentsTyped inputs the retrieval logic operates on. Each has an Alias, Type, optional flag, and default value.Optional
PropertiesDescription, Group, Permissible Purpose, Approval Workflow.Mostly required
AttributesOutput Type and Alias (the Python variable name pipelines call this RAG by).required

Every RAG registered in GGX is one of three types. The choice determines where the knowledge source lives and how the retrieval logic reaches it.

External store Communicates with external knowledge sources like Neo4j or vector databases using APIs to retrieve information from outside environments.

The RAG Registry is the central place where every registered RAG lives, organised into customisable groups. From here you can track, monitor, test, and create new RAGs.

Click Create on the RAG Registry page, then work through the form:

  1. Name, Properties, and Attributes. Give the RAG a clear name and description. Set the Group, Permissible Purpose, and Approval Workflow under Properties, and the Output Type and Alias under Attributes.

  2. Input Arguments. Define each argument with its Alias, Type, optional flag, and default value.

  3. Resources. Select any registered Models, Global Functions, or Prompts the retrieval logic should be able to call.

  4. Input Type. Pick API-Based, Python-Based, or Custom.

  5. Knowledge file and Retrieval Logic. Upload the custom knowledge file if required, then write the retrieval code in the Retrieval Logic section.

  6. Additional Information. Add notes or attach supporting documentation.

  7. Save. Click Save to register. The RAG is saved as a Draft until it goes through approval.

A complete example: the card-policy knowledge base

Section titled “A complete example: the card-policy knowledge base”

This fills in every field for kb, the Custom RAG introduced above. It uploads a vector index built from the card-servicing policy documents and returns the passages most relevant to a query.

Page fields for kb
FieldValue
Description”Retrieves the most relevant passages from the bank’s card-servicing policy documents. Use to ground card-servicing answers; not a source for fraud-dispute rules.”
Aliaskb
Input TypeCustom
Output Typelist[str]
Input Argumentsquery (str, required), top_k (int, default 3)
Resourcesembedder (an embedding Model)
Knowledge filecard_policy_index — a vector index built from the policy PDFs
kb — retrieval logic
# `query` and `top_k` are Input Arguments defined in Step 2.
# `embedder` is a Resource; `card_policy_index` is the uploaded knowledge file.
query_vector = embedder.embed(query) # (1)!
hits = card_policy_index.search(query_vector, top_k=top_k) # (2)!
# Return the passages most relevant to the query
return [hit.text for hit in hits] # (3)!
  1. embedder is a registered Model added under Resources; query is provided as an Input Argument.
  2. card_policy_index is the uploaded knowledge file; top_k defaults to 3 but the caller can override it.
  3. The return value matches the Output Type list[str] — exactly what a pipeline receives when it calls kb.search(...).

A RAG is testable on its own — you do not need to wire it into a pipeline first. Validate retrieval quality independently with a Quick Test and a Bulk Simulation, then exercise it end-to-end inside any pipeline that uses it.

Three escalating ways to test a RAG: a Quick Test on one query, a Bulk Simulation across a dataset of queries, and an end-to-end run inside a pipeline that uses the RAG.

From a single-query sanity check, to a full run over a dataset, to an end-to-end test inside a real pipeline.

Quick Test — independent, while writing the logic

Section titled “Quick Test — independent, while writing the logic”

A fast check on a single query without saving; it runs the retrieval logic against sample input so you can confirm it returns sensible passages.

  1. While creating or editing the RAG, scroll to the Retrieval Logic section.
  2. Click Test Code in the bottom-right corner of the editor.
  3. Enter a sample query (and any other Input Arguments, like top_k) and confirm the returned chunks are relevant.

A single query tells you the RAG runs; a bulk simulation tells you how its retrieval behaves across many real questions. It runs an entire dataset of queries through the RAG and records one set of results per query — no pipeline required. Use it to:

  • Spot queries that retrieve irrelevant or empty passages a single test would miss.
  • Measure retrieval quality across a representative set of questions before approval.
  • Attach the run as evidence in the RAG’s approval and risk review.

shared mechanism Bulk Simulation is the same at-scale evaluation used across all registered assets, so the run, its dataset, and its results are logged and comparable just like a pipeline simulation.

Once the RAG behaves on its own, test it in context. Any pipeline that lists the RAG as a Resource exercises it as part of a full request — so you can see how retrieval quality shapes the final generated output, not just the raw chunks. This is where you confirm kb actually grounds the assistant’s reply, rather than only returning plausible passages.

Registering a RAG — rather than calling a retriever from a loose script — is what turns it into a governed, reusable asset:

CapabilityWhat you get
Change trackingAutomatic recording of modifications with efficient version upgrades.
Purpose enforcementAutomatic detection of Permissible Purpose violations.
Testing & evaluationEvaluate against other RAGs using custom and standardised validation kits.
ReusabilityReuse across pipelines, with visibility through Lineage Tracking.
API fingerprintingExternal retrieval connectivity is fingerprinted so changes upstream are detectable.
Auditable path to productionA transparent, fully auditable journey from Draft through Approval to use in pipelines.
Executable artifactsExtract ready-to-productionise artifacts straight from the Registry.