DeepEval LLM testing is an open-source framework that treats language model outputs like code: you write unit tests for them, run them automatically, and fail the build when an answer does not meet the bar. It is similar to Pytest, but specialised for testing large language model systems, with ready-made metrics for qualities such as hallucination, answer relevancy, faithfulness and summarisation. The central question is simple: how do you know an answer is good without reading every one? DeepEval answers it by scoring outputs against metrics you choose, with a threshold that decides pass or fail.
That matters because language model outputs are hard to test with exact matching. A correct answer can be phrased in many ways, and a fluent answer can be completely wrong. DeepEval LLM testing handles that gap by using metrics that judge meaning rather than wording, often with the help of another language model, and by running those metrics locally on your own machine.
Key takeaways
- DeepEval LLM testing is a pytest-style framework for unit testing language model outputs.
- It provides ready-made metrics for hallucination, faithfulness, answer relevancy and RAG quality.
- Metrics run with a threshold, so each test has a clear pass or fail result.
- Custom metrics can be built by extending its base metric class.
- It fits best for Python teams that want evaluation code next to application code.
What is DeepEval LLM testing?
DeepEval is a simple-to-use, open-source LLM evaluation framework, licensed under Apache 2.0. It was built for evaluating and testing large language model systems, from simple chatbots to retrieval-augmented generation pipelines and multi-turn agents. Its central idea is that an LLM test should look like any other unit test: an input, an expected behaviour, and an assertion that either passes or fails.
In practice, a DeepEval test defines a test case with an input, an actual output, and, where relevant, an expected output or a retrieval context. A metric then scores the output, and the test asserts that the score meets a threshold. That structure is familiar to any Python developer, which is part of its appeal: evaluation becomes part of the normal test suite, rather than a separate notebook or dashboard that nobody runs.
DeepEval can run its metrics locally, using a language model of your choice or statistical and natural language processing models that run on your own machine. It also offers a cloud platform, under the name Confident AI, for sharing test results and reports, but the framework itself does not require it. Teams can start locally and add the cloud reporting later if they need it.
The metrics that matter most
DeepEval provides a large set of ready-made metrics, grouped by the kind of system they test. General metrics cover hallucination, bias, toxicity, summarisation and G-Eval, a method that asks a language model to score an output against criteria you define. These are useful for any system where the quality of a single answer matters.
RAG metrics are a second group, and they are the reason many teams choose DeepEval. Answer relevancy checks whether the answer actually addresses the question. Faithfulness checks whether the answer stays grounded in the retrieved context, rather than inventing facts. Contextual recall and contextual precision check the retrieval step itself: whether the right documents were found, and whether the retrieved documents were relevant. Together, these metrics separate retrieval failures from generation failures, which is essential for fixing a RAG system. Our guide to RAG evaluation metrics explains these measures in more depth.
A third group covers agents and conversations. Agentic metrics check task completion and whether the agent used the right tools, while conversational metrics check knowledge retention, conversation completeness, relevance and role adherence across several turns. These matter for systems that do more than answer a single question, because a system can answer each turn well and still lose track of the conversation as a whole.
G-Eval and custom metrics
G-Eval is one of DeepEval’s most flexible metrics. Instead of a fixed formula, you define criteria in plain language, and a language model scores the output against them, with a written reasoning step. That makes it useful for qualities that are hard to define as a rule, such as helpfulness or tone, but it also means the score depends on the judge model and the criteria you wrote. Best for: open-ended qualities where no fixed formula exists, provided you spot-check the judge’s scores.
Custom metrics are the other escape hatch. You can build your own metric by extending DeepEval’s base metric class, and it integrates with the rest of the ecosystem automatically. That is useful when your system has a quality that no ready-made metric captures, such as compliance with a house style or a domain-specific rule about how numbers should be presented.
Benchmarks and red teaming
DeepEval can also benchmark a model on popular public benchmarks, including MMLU, HellaSwag, DROP, BIG-Bench Hard, TruthfulQA, HumanEval and GSM8K, in a small amount of code. Benchmarks are useful for comparing models in general, but they do not replace tests built around your own application, because a model that scores well on a public benchmark can still fail on your users’ questions. Best for: a quick, comparable check when choosing between models, before writing application-specific tests.
DeepEval also includes red teaming, which tests an application against safety vulnerabilities. That covers a range of attack types, and it fits the same pattern as the rest of the framework: a test case, a metric, and a pass or fail result. Red teaming is best run before release, when a successful attack can still change the design.
Writing your first DeepEval test
A first test is deliberately small. Pick one behaviour that matters, such as whether the system answers a factual question without hallucinating, and write a single test case for it. Define the input, run the system to get the actual output, choose a metric such as the hallucination metric or the faithfulness metric, and set a threshold. The test then asserts that the score meets that threshold.
The threshold deserves care. A threshold of 0.5 on a metric is a common starting point in examples, but the right value depends on the metric, the use case, and the cost of a false pass. A high-stakes system, such as one that answers medical or legal questions, needs a stricter threshold than a creative writing assistant. The honest way to set a threshold is to run the metric on examples you have already judged by hand, and choose a value that separates the good answers from the bad ones.
Once the first test passes, add more cases for the same behaviour, including edge cases. A hallucination test should include questions with no answer in the retrieved documents, because a system that invents an answer when none exists is more dangerous than one that hallucinates on a question it could have answered. Then add tests for other behaviours, one at a time, so each failure points to a specific problem.
DeepEval in a testing workflow
DeepEval fits naturally into a Python team’s existing workflow. Tests live in the repository, run with the same test runner as the rest of the code, and can run in continuous integration on every change. That is its main strength: evaluation is not a separate activity that happens once a quarter, but a routine check that runs whenever the prompt, the model, or the data changes.
It also fits the habit of adding a test for every failure. When a bad answer reaches a user, the team can write a test case that captures that failure, add it to the suite, and fix the system until the test passes. Over time, the suite becomes a record of every failure the team has learned from, which is far more useful than a dashboard of average scores. For a broader framework for building that habit, see building an LLM evaluation framework, which covers how to turn scores into decisions.
Comparing DeepEval with other tools
| Tool or approach | Main focus | Main strength | Main limitation |
|---|---|---|---|
| DeepEval | Python unit tests with ready-made LLM metrics | Rich metrics for RAG, agents and conversations | Python-first, so less natural for other stacks |
| Promptfoo | Config-file evals and red teaming from the command line | Fast setup, no code needed for basic evals | Fewer built-in metrics than DeepEval |
| Giskard | Scanning for bias, security and performance issues | Finds problems you did not think to test for | Needs review to sort real risks from noise |
| Opik | Tracing, evaluation and monitoring in one platform | Connects evals to production traces | More setup than a test library |
| LLM-as-a-judge alone | A model scores outputs against a rubric | Flexible for open-ended quality | The judge can share the model’s blind spots |

Common mistakes with DeepEval
The most common mistake is trusting a single metric. A system can score well on answer relevancy while failing on faithfulness, which means it gave a relevant answer that was not grounded in the source. Running several metrics on the same test case, and reading the failures, gives a truer picture than any one score.
The second mistake is setting thresholds without calibration. A threshold copied from an example may be too lenient or too strict for your data, and a test that always passes is no test at all. Calibrate thresholds against examples you have judged by hand, and revisit them when the model or the data changes.
DeepEval LLM testing checklist
- Start with one behaviour and one metric, and get a single test passing.
- Calibrate each threshold against examples you have judged by hand.
- Run several metrics on the same case, not just one.
- Separate retrieval failures from generation failures with RAG metrics.
- Add a test case for every failure found in production.
- Include edge cases: unanswerable questions, multi-turn conversations, and synthesis across documents.
- Spot-check judge-based scores by reading a sample of outputs yourself.
- Run the suite in continuous integration on every prompt or model change.
- Revisit thresholds when the model, prompt, or data changes.
Frequently asked questions
What is DeepEval LLM testing?
It is the practice of testing language model systems with DeepEval, an open-source framework that works like Pytest for LLM outputs. You write test cases, score them with ready-made metrics, and assert that the score meets a threshold.
Is DeepEval open source?
Yes. DeepEval is open source under the Apache 2.0 licence. It can run locally, and it offers a cloud platform for sharing test results, but the framework itself does not require a cloud account.
Which metrics does DeepEval provide?
It provides general metrics such as G-Eval, hallucination, summarisation, bias and toxicity, RAG metrics such as answer relevancy, faithfulness, contextual recall and contextual precision, agentic metrics such as task completion and tool correctness, and conversational metrics such as knowledge retention and role adherence.
Do I need to write Python to use DeepEval?
Yes, in practice. DeepEval is a Python framework, and its tests are written in Python, in the same style as Pytest. Teams that do not work in Python may prefer a config-driven tool, while Python teams will find DeepEval fits their existing workflow.
Can DeepEval test RAG systems?
Yes, and RAG is one of its strengths. Its RAG metrics score both the retrieval step and the generation step, so a wrong answer can be traced to bad retrieval, bad generation, or both. That makes it easier to fix the right part of the system.
How is DeepEval different from Promptfoo?
DeepEval is a Python library with a rich set of metrics, while Promptfoo is a command-line tool driven by a configuration file. DeepEval suits Python teams that want evaluation code next to application code; Promptfoo suits teams that want fast, config-driven evals without writing code.







