TruLens RAG evaluation is the practice of measuring a retrieval-augmented generation system with TruLens, an open-source library that instruments LLM applications and scores them with feedback functions, most famously the RAG Triad: context relevance, groundedness and answer relevance. The question it answers is whether your RAG system is free from hallucination, and it answers it where the failure happens: if the retrieved context is irrelevant, if the answer drifts from the context, or if the answer ignores the question, each shows up as a different score. TruLens differs from batch-only evaluation tools because it also traces live requests, so the same scores can run in production as well as in testing.
That combination matters because RAG failures are often intermittent. A system can pass a test set and still hallucinate on a Tuesday afternoon when a new document enters the index or a user phrases a question in an unexpected way. Batch evaluation catches regressions between releases; TruLens adds the ability to watch quality as it happens and to act on it, for example by filtering bad context before it reaches the model.
Key takeaways
- TruLens is an open-source library for evaluating and tracing LLM applications, including RAG systems.
- Its core RAG evaluation is the RAG Triad: context relevance, groundedness and answer relevance.
- Feedback functions are the mechanism: small evaluators attached to parts of your application.
- TruLens combines evaluation with OpenTelemetry-based tracing, so scores attach to individual request spans.
- Feedback functions can also run as guardrails at runtime, filtering retrieved context before generation.
What TruLens is
TruLens is a library for tracking and evaluating generative AI applications. It provides feedback functions that systematically measure the quality of LLM-based applications, traces the internal steps of an application, and lets you run feedback functions on any internal step. Results can be examined in a TruLens dashboard, or used at runtime as guardrails. It is open source, MIT-licensed and self-hostable, and it integrates with platforms including Snowflake Cortex, where its feedback functions can run with Cortex as the provider. Snowflake’s guide to LLMOps with Cortex and TruLens walks through that setup.
The key idea is instrumentation. TruLens records what your application does, call by call, using OpenTelemetry tracing, and then evaluates those records. That means evaluation is not a separate harness bolted on afterwards; it observes the real application, in development or in production, and scores what actually happened. For teams that already care about observability, this is the natural way to add evaluation to a system they already run.
The RAG Triad, explained
The RAG Triad is TruLens’s structured evaluation for RAG, and it covers the three edges of the RAG architecture. Each leg of the triad is a feedback function, and satisfactory scores on all three give reasonable confidence that the application is free from hallucination. A failure on any one leg points at a specific part of the pipeline.
Context relevance: was the retrieved context relevant?
Context relevance asks whether the chunks retrieved for a question are relevant to that question. TruLens measures it by scoring question-to-statement relevance between the input and each retrieved chunk, typically aggregating with a mean or a max across chunks. If this score is low, retrieval is fetching the wrong material, and no amount of prompt engineering will fix the answers, because the model is reasoning over irrelevant evidence.
Groundedness: is the answer supported by the context?
Groundedness is the hallucination check. TruLens splits the response into separate statements and searches for evidence supporting each one within the retrieved context, then aggregates, usually by taking the maximum groundedness per statement and averaging across statements. A low groundedness score means the model is adding claims the sources do not support, and the fix is to tighten the prompt, lower the temperature or improve retrieval so the model has better evidence to work with.
Answer relevance: does the answer address the question?
Answer relevance is the simplest of the three to set up, because it only needs the input and the output. It measures the relevance of the final response to the user input, penalising answers that are technically grounded but off-topic or evasive. If groundedness is high and answer relevance is low, the system is faithfully answering the wrong question, which is usually a prompting or instruction problem.

Feedback functions: how TruLens evaluates
A feedback function is a small evaluator that takes selected pieces of a recorded application run and returns a score. You define one by choosing a provider, such as OpenAI, Anthropic or a Hugging Face model, picking an evaluation method, and selecting which text it receives: the input, the output, or the retrieved context. TruLens serialises your application and indexes it with a JSON-like structure, so selectors can point at exactly the values a function needs.
Chain-of-thought variants of the standard functions return reasons alongside scores, which makes failures much easier to diagnose: instead of a bare 0.4, you see why the judge thought a statement was unsupported. That reasoning is worth the extra tokens in development, and it is one of the most useful features for teams debugging a new pipeline. Our guide to RAG evaluation tools compares TruLens with the alternatives on this dimension.
Best for: teams that want evaluation wired into a live application, with traces and scores they can inspect per request, rather than a standalone batch scorer.
TruLens vs batch evaluation tools
| Aspect | Batch evaluation (e.g. Ragas) | TruLens RAG evaluation |
|---|---|---|
| Core metrics | Faithfulness, relevancy, precision, recall | RAG Triad: context relevance, groundedness, answer relevance |
| Ground truth needed | Mostly no | No, reference-free by default |
| Live tracing | No | Yes, OpenTelemetry-based |
| Runtime guardrails | No | Yes, feedback functions can filter context |
| Setup effort | Low | Higher, needs instrumentation |
| Custom metrics | Limited | Feedback functions, fully customisable |
The two approaches are complementary rather than competing. Ragas gives you a clean batch score over a fixed dataset, which is ideal for regression testing. TruLens gives you evaluation of the live system, with per-request traces that show exactly where a failure occurred. Many teams run both: Ragas in continuous integration, TruLens in production. For the observability side, see our guide to LLM observability and seeing inside non-deterministic applications.
Guardrails: evaluation that acts
The most distinctive TruLens feature is using feedback functions as guardrails. Because evaluation is wired into the application, a feedback function can run during a request and its result can change what happens next. The common pattern is filtering retrieved context: if a chunk scores low on context relevance, it is dropped before generation, which reduces hallucination by removing the evidence the model would otherwise misuse.
Guardrails need care. A threshold set too high starves the model of context and produces empty or evasive answers; a threshold set too low lets bad context through and the guardrail becomes decoration. Tune thresholds on real traffic, log every guardrail decision, and review the filtered cases regularly, because the cases your guardrail catches are often the most informative failures in your system.
Costs and honest limitations
TruLens requires more initial setup than a batch evaluator, particularly for teams new to OpenTelemetry instrumentation. The feedback function API is expressive, but it carries a steeper learning curve: selectors, aggregations and provider configuration all have to be understood before the first useful score appears. Budget a day or two of setup rather than an afternoon.
There is also the cost of the judge. Every feedback function call is a model call, and in production that means evaluation can cost as much as generation itself. Use cheaper judge models where you can, sample production traffic rather than scoring every request, and reserve the strongest judge for the cases that matter most. Like all LLM-as-a-judge methods, TruLens scores inherit the judge’s biases, so calibrate against human judgement before trusting the numbers.
Getting started checklist
- Instrument your RAG application with TruLens before adding any evaluations.
- Start with the RAG Triad only: context relevance, groundedness and answer relevance.
- Use chain-of-thought variants while debugging so failures come with reasons.
- Pick a cheap judge model for routine scoring and a stronger one for audits.
- Record a baseline on real traffic before changing prompts or retrieval.
- Review low-scoring traces by hand every week until the patterns are familiar.
- Add guardrails only after the scores are stable, and log every guardrail decision.
- Pair TruLens with batch regression tests so releases are checked before they ship.
Frequently asked questions
What is the RAG Triad?
The RAG Triad is TruLens’s three-part evaluation for RAG systems: context relevance, groundedness and answer relevance. Together they check retrieval quality, whether the answer is supported by the retrieved context, and whether the answer addresses the original question.
Does TruLens need ground-truth answers?
No. The RAG Triad is reference-free by default, which means it scores the question, retrieved context and answer without needing human-written correct answers. Ground-truth-based metrics can be added as custom feedback functions if you have labelled data.
How is TruLens different from Ragas?
Ragas is a batch evaluation framework that scores a dataset, while TruLens instruments the live application, traces individual requests and can run evaluations as runtime guardrails. They are complementary: many teams use Ragas for regression testing and TruLens for production observability.
Can TruLens work with Snowflake?
Yes. TruLens integrates with Snowflake Cortex, which can serve as the feedback provider, and traces and evaluation results can be logged to Snowflake tables for analysis alongside the rest of your data.
What are feedback functions?
Feedback functions are evaluators attached to parts of your application. Each one selects input, output or retrieved context from a recorded run, scores it with a provider model or a custom function, and returns a number, optionally with a reason.
Should I score every production request?
Usually not. Scoring every request doubles your model spend and adds latency, so most teams sample traffic, score everything only for a short audit window, or score only requests that trip another signal, such as a user complaint or a low confidence marker.







