Use this advanced n8n workflow to calculate AI agent correctness based on the RAGAS methodology. The n8n template combines LLM classification (TP/FP/FN) and semantic similarity using OpenAI's embedding service for comprehensive quality scoring.
Download this n8n workflow template and start using it instantly.
AI Developers and ML Engineers needing automated performance testing.
Users building Retrieval-Augmented Generation (RAG) systems.
Technical professionals requiring quantifiable quality metrics for their n8n workflow outputs.
Anyone seeking advanced LLM evaluation features within n8n templates.
Evaluating the output of AI agents and large language models (LLMs) is crucial but often complex. This advanced n8n workflow solves this by implementing the 'Correctness' metric, adapted from the RAGAS evaluation methodology. This n8n template provides a structured and quantifiable scoring mechanism by addressing two primary dimensions: factuality and semantic overlap. The logic of this n8n workflow uses an LLM (OpenAI) to classify response statements against the ground truth (True Positives, False Positives, False Negatives) to derive an F1 score, while simultaneously calculating the cosine similarity of the embeddings. The final correctness score, calculated within the n8n node, is a weighted average of these two metrics, giving you objective feedback on your AI agent's performance. Utilizing this powerful n8n workflow ensures your AI applications maintain accuracy and reliability.
This comprehensive n8n workflow starts with the dedicated When fetching a dataset row n8n trigger, designed specifically for evaluation runs. This n8n trigger pulls test data (question and ground truth) from a configured Google Sheet.
AI Agent n8n node, which uses an OpenAI Chat Model to generate the test answer.Set Input Fields n8n node structures the question, answer, and groundTruth into a format suitable for two concurrent evaluation paths.Correctness Classifier n8n node uses a system prompt and the OpenAI model to classify individual statements in the answer against the ground truth (TP, FP, FN). The Calculate F1 Score n8n node then computes the F1 metric based on these counts, providing a precision-recall measure of correctness.HTTP Request n8n node to interact with the OpenAI Embeddings API. It generates embeddings for both the agent's answer and each individual groundTruth statement. The Calculate Similarity Score n8n node then executes a custom JavaScript function to find the average cosine similarity between the answer and all ground truth vectors.Correctness Score n8n node applies weighted averaging (75% F1 Score, 25% Similarity) to produce the final score for the evaluated item. Finally, the Update Outputs n8n node reports this definitive score back to the Google Sheets dataset, completing the robust evaluation cycle of this n8n workflow.To deploy and utilize this powerful n8n workflow, follow these steps:
OpenAI Chat Model, OpenAI Chat Model1, Get Embeddings, and Get Embeddings1 n8n node components.When fetching a dataset row and Update Outputs n8n node components. The sheet must contain columns for 'input' (question), 'answer' (to be generated by the agent), and 'ground truth'.When fetching a dataset row n8n trigger node, select your Google Sheet and the relevant tab where your evaluation data resides. When fetching a dataset row (n8n trigger): A specialized n8n trigger that initiates the evaluation process by pulling input (question and ground truth) data from a configured Google Sheet.
AI Agent (Langchain Agent n8n node): Represents the system under test. It takes the input and generates the response (the 'answer') that will be evaluated for correctness.
Correctness Classifier (ChainLlm n8n node): This crucial n8n node uses a detailed prompt and the OpenAI model to analyze the agent's response against the ground truth, classifying statements as True Positive (TP), False Positive (FP), or False Negative (FN).
OpenAI Chat Model (LLM n8n node): Provides the large language model necessary for the classification task within the n8n workflow, ensuring accurate factuality assessment.
Get Embeddings/Get Embeddings1 (HTTP Request n8n node): Calls the OpenAI Embeddings API to generate vector representations of the agent's answer and the ground truth statements, required for the semantic similarity metric.
Calculate F1 Score (Code n8n node): Executes custom JavaScript code to calculate the F1 score based on the TP, FP, and FN counts provided by the classifier n8n node.
Calculate Similarity Score (Code n8n node): Executes custom JavaScript code to compute the average cosine similarity between the answer embedding and the ground truth embeddings.
Correctness Score (Code n8n node): Calculates the final weighted average score, combining the F1 score and the similarity score into a single, comprehensive correctness metric for the n8n workflow evaluation.
A powerful n8n workflow for construction cost estimation using BIM/IFC/Revit data. This automation features AI classification, multi-standard material analysis, and detailed Excel and HTML report generation.

Automate robust error handling in n8n. Get instant Gmail notifications for execution and trigger-level failures using this essential n8n workflow template, complete with debugging data.

Automate server log monitoring using an n8n workflow. Connect SSH, parse critical errors with a custom n8n node, send Slack alerts, and auto-create Jira bug tickets to streamline DevOps incident response.

Use this n8n workflow to automatically evaluate the relevance and noncommittal nature of your AI agent's responses against test data. This n8n template uses OpenAI embeddings and cosine similarity.

This reusable n8n workflow scores animal advocacy text for performance and preference using deployed Hugging Face Open Paws AI models. A powerful n8n template for parallel AI text analysis.

Use this powerful n8n workflow to automate candidate screening. It utilizes an n8n trigger on new Google Sheets submissions, evaluates answers using Azure GPT-4o-mini, and updates final combined scores in your candidate database.


Freelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at [email protected] LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk







































