Evaluate RAG response accuracy with OpenAI: document groundedness metric
Ready for 3.0What this workflow does
This AI workflow has 21 nodes and runs manually, when you click “Execute workflow” (plus 2 other triggers). Along the way it connects Embeddings OpenAI, OpenAI Chat Model and Evaluation. It also calls bitcoin.org over HTTP.
How it runs
Trigger: Manually, when you click “Execute workflow” (plus 2 other triggers).
- Get Datasheet (HTTP Request): calls bitcoin.org
- Remap Input (Edit Fields (Set)): sets 1 field: chatInput
- AI Agent: runs an AI agent, with model: OpenAI Chat Model; 1 tool (Simple Vector Store)
- Simple Vector Store: stores documents in the Simple vector store, with embeddings: Embeddings OpenAI; document loader: Default Data Loader
- Evaluation: check if evaluating
- Get Documents (Edit Fields (Set)): sets 2 fields: output, documents
- Document Grounding (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI Chat Model; output parser: Structured Output Parser
- Set Outputs (Evaluation): uses Evaluation
- Set Metrics (Evaluation): set metrics
Services it uses
HTTP calls to: bitcoin.org
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
Nodes used (15)
- Manual Trigger
n8n-nodes-base.manualTrigger - HTTP Request
n8n-nodes-base.httpRequest - Simple Vector Store
@n8n/n8n-nodes-langchain.vectorStoreInMemory - Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi - Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - AI Agent
@n8n/n8n-nodes-langchain.agent - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Evaluation
n8n-nodes-base.evaluation - No Operation, do nothing
n8n-nodes-base.noOp - Edit Fields (Set)
n8n-nodes-base.set - Evaluation Trigger
n8n-nodes-base.evaluationTrigger - Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
From the author
This n8n template demonstrates how to calculate the evaluation metric "RAG document groundedness" which in this scenario, measures the ability to provide or reference information included only in retrieved vector store documents. The scoring approach is…