XAI in LLM Knowledge Augmentation (RAG)

Retrieval-Augmented Generation adds a visible knowledge path: query, embedding, similarity search, retrieved documents, prompt, and answer.

Source grounding improves transparency because a user can inspect the material supplied to the model.

RAG Pipeline, Step by Step

Step 1 of 6

Build the vector database

Unstructured data — product descriptions, documents, images — is passed through an embedding model ahead of time. Each item's embedding (a vector) is stored alongside the original data it represents.

Vector database

VectorUnstructured data
2359498503803...SKU 4471, description, image
4858856983409...SKU 8820, description, image
5848954303490...SKU 1103, description, image
4596894586048...SKU 7742, description, image

User query → embedding model

🧑

User

"Do you have black leather boots?"

Embed

4573030205...

Similarity search

Compare the query vector against every vector in the database. Rank database items by closeness to the query.

Prompt assembly

query: "Do you have black leather boots?"

context: "SKU 4471 — Black leather boots, waterproof, sizes 6–12"

LLM generation → response

LLM

generating...

Embedding model

Top match

Response grounded in

Retrieval trace

A RAG explanation should expose the query transformation, retrieved items and scores, passages placed in context, citations attached to claims, and the answer generated from that context.

Citation is not proof of use. A model can cite a relevant document and generate a claim the document does not support. Retrieval can also fail before generation begins.

Evaluate retrieval recall, ranking, passage relevance, citation entailment, and answer faithfulness as separate steps.

Checkpoint

What does a correct citation establish, and what remains unknown?