deepeval README

The project's README from github.com/confident-ai/deepeval. As one markdown file: README.md.

DeepEval.

The LLM Evaluation Framework

confident-ai%2Fdeepeval | Trendshift

discord-invite reddit-community

Documentation | Metrics and Features | Getting Started | Integrations | Confident AI

GitHub release Try Quickstart in Colab License Twitter Follow

Deutsch | Español | français | 日本語 | 한국어 | Português | Русский | 中文

DeepEval is a simple-to-use, open-source LLM evaluation framework, for evaluating large-language model systems. It is similar to Pytest but specialized for unit testing LLM apps. DeepEval incorporates the latest research to run evals via metrics such as G-Eval, task completion, answer relevancy, hallucination, etc., which use LLM-as-a-judge and other NLP models that run locally on your machine.

Whether you're building AI agents, RAG pipelines, or chatbots, implemented via LangChain or OpenAI, DeepEval has you covered. With it, you can easily evaluate:

Use these evaluations to determine the optimal models, prompts, and architecture to improve your AI quality, prevent prompt drifting, or even transition from OpenAI to Claude with confidence.

[!IMPORTANT] Want to compare iterations, share evaluation reports, and monitor your AI in production? Sign up for Confident AI, the enterprise AI evals and observability platform.

Demo GIF

Want to talk LLM evaluation, need help picking metrics, or just to say hi? Come join our discord.


🔥 Metrics and Features


🔌 Integrations

DeepEval plugs into any LLM framework — OpenAI Agents, LangChain, CrewAI, and more. For enterprise teams standardizing evals and observability across the organization, Confident AI provides a native DeepEval integration.

Frameworks

☁️ Platform + Ecosystem

Confident AI is the enterprise AI evals and observability platform. It gives organizations one consistent standard across product teams, integrates natively with DeepEval, and remains model- and framework-agnostic.

Confident AI MCP Architecture


🤖 Vibe-Coder QuickStart

Want your coding agent to add evals and fix failures for you? Install the DeepEval skill, point it at your agent, RAG pipeline, or chatbot, and ask it to generate a dataset, write the eval suite, run deepeval test run, and iterate on the failing metrics.

Start with the 5-minute vibe-coder guide.


🚀 Human QuickStart

Let's pretend your LLM application is a RAG based customer support chatbot; here's how DeepEval can help test what you've built.

Installation

Deepeval works with Python>=3.9+.

pip install -U deepeval

Using the deepeval platform will allow you to generate sharable testing reports on the cloud. It is free, takes no additional code to setup, and we highly recommend giving it a try.

To login, run:

deepeval login

Follow the instructions in the CLI to create an account, copy your API key, and paste it into the CLI. All test cases will automatically be logged (find more information on data privacy here).

Write your first test case

Create a test file:

touch test_chatbot.py

Open test_chatbot.py and write your first test case to run an end-to-end evaluation using DeepEval, which treats your LLM app as a black-box:

import pytest
from deepeval import assert_test
from deepeval.metrics import GEval
from deepeval.test_case import LLMTestCase, SingleTurnParams

def test_case():
    correctness_metric = GEval(
        name="Correctness",
        criteria="Determine if the 'actual output' is correct based on the 'expected output'.",
        evaluation_params=[SingleTurnParams.ACTUAL_OUTPUT, SingleTurnParams.EXPECTED_OUTPUT],
        threshold=0.5
    )
    test_case = LLMTestCase(
        input="What if these shoes don't fit?",
        # Replace this with the actual output from your LLM application
        actual_output="You have 30 days to get a full refund at no extra cost.",
        expected_output="We offer a 30-day full refund at no extra costs.",
        retrieval_context=["All customers are eligible for a 30 day full refund at no extra costs."]
    )
    assert_test(test_case, [correctness_metric])

Set your OPENAI_API_KEY as an environment variable (you can also evaluate using your own custom model, for more details visit this part of our docs):

export OPENAI_API_KEY="..."

And finally, run test_chatbot.py in the CLI:

deepeval test run test_chatbot.py

Congratulations! Your test case should have passed ✅ Let's break down what happened.

Read our documentation for more information!


Evals With Full Traceability

Use evals_iterator() to run the same dataset through your app, whether you instrument it manually or through one of DeepEval's framework integrations. Because tracing captures the ordered sequence of model decisions, tool calls, and intermediate steps, you can run trajectory-based evaluations over the complete path your agent takes.

Here's an example of manual instrumentation:

from deepeval.tracing import observe, update_current_span
from deepeval.test_case import LLMTestCase
from deepeval.metrics import TaskCompletionMetric

@observe()
def inner_component(input: str):
    output = "result"
    update_current_span(test_case=LLMTestCase(input=input, actual_output=output))
    return output

@observe()
def app(input: str):
    return inner_component(input)

# This metric evaluates the complete trajectory captured for this run.
for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
    app(golden.input)
OpenAI
from deepeval.openai import OpenAI
from deepeval.tracing import trace
from deepeval.metrics import TaskCompletionMetric

client = OpenAI()

# This metric evaluates the complete trajectory captured for this run.
for golden in dataset.evals_iterator():
    with trace(metrics=[TaskCompletionMetric()]):
        client.chat.completions.create(
            model="gpt-4o",
            messages=[{"role": "user", "content": golden.input}],
        )
OpenAI Agents
from agents import Runner
from deepeval.metrics import TaskCompletionMetric

# This metric evaluates the complete trajectory captured for this run.
for golden in dataset.evals_iterator(metrics=[TaskCompletionMetric()]):
    Runner.run_sync(agent, golden.input)
AI SDK (TypeScript)
import { generateText } from "ai";
import { configureAiSdkTracing } from "deepeval/integrations/ai-sdk";
import { TaskCompletionMetric } from "deepeval/metrics";

const tracer = configureAiSdkTracing({ name: "my-agent" });

const ask = (input: string) =>
  generateText({
    model,
    prompt: input,
    experimental_telemetry: { isEnabled: true, tracer },
  });

// This metric evaluates the complete trajectory captured for this run.
for await (const golden of dataset.evalsIterator({
  metrics: [new TaskCompletionMetric()],
})) {
  await ask(golden.input);
}
`

deepeval (confident-ai/deepeval)

Searching Database…

18.9K ·GitHub
这是干什么的?DeepEval 是一个开源的大模型评估框架:用起来很简单,可以用 G-Eval、答案相关性、幻觉检查这类有研究依据的指标来评估大语言模型系统。
它和直接用 pytest 有什么不一样?它沿用了 pytest 那套单元测试的写法,但专门为大模型应用设计——测试用例是 Python 对象,把输入、输出和评估指标组合在一起,而不是通用的断言,并且要用 DeepEval 自带的命令行工具来运行。
我怎么开始测试自己的应用?先用 pip 安装这个包(需要 Python 3.9+),然后写一个测试文件,里面放一个输入、你的应用返回的 actual_output,以及一个像 GEval 这样的指标并设一个阈值,最后在命令行里运行 'deepeval test run'。分数范围是 0 到 1,高于还是低于阈值决定通过还是失败。
运行评估需要 OpenAI 的 API 密钥吗?快速上手教程里会设置 OPENAI_API_KEY 环境变量,但你并不是非用它不可:指标可以由你选的任何大模型来驱动,也可以用本地运行的 NLP 模型,你还可以接入自己的自定义模型来做评估。
我必须注册 Confident AI 云平台吗?不用——这个框架是开源的,本地就能独立运行。Confident AI 平台是可选的免费注册项,注册后可以在你的测试结果之上获得可分享的云端测试报告。
它是给谁用的——智能体、RAG 应用还是聊天机器人?面向开发 AI 智能体、RAG 流水线或聊天机器人的开发者——它可以把应用当作黑盒做端到端评估,也可以深入到组件级别,细到工具调用、检索、子智能体任务交接这类单个智能体步骤。
它在 Windows 上能用吗,还是只支持 Mac 和 Linux?它是一个可以用 pip 安装的 Python 包,带命令行工具,所以只要能跑 Python 3.9+ 的地方都能用——Windows、macOS 和 Linux 都支持。
它会把我的测试数据发到别的地方吗?只有你主动开启才会:一旦你登录 Confident AI 平台,你所有的测试用例都会自动记录到云端,数据隐私方面另有专门文档说明。
它能帮我生成评估数据集吗?可以——它能生成单轮和多轮的合成数据集,不用你手写每一条测试输入。
G-Eval 是什么?一种有研究依据的“大模型当裁判”指标,可以按你自定义的任何标准给输出打分,准确度接近人类——快速上手教程就用它来对照预期答案检查输出的正确性。
它能评测原始大模型吗,还是只能测我的应用?可以——它能用不到 10 行代码,在 MMLU、HellaSwag、DROP、BIG-Bench Hard、TruthfulQA、HumanEval、GSM8K 这些热门基准上评测任何大模型。
它能帮我改进应用,还是只能打分?它会根据评估结果自动优化提示词,所以除了给出通过与否的结论,还能帮你一步步迭代出更好的输出。
What are similar projects?promptfoo, jevals, mlflow, ragas, Tracely-ai, opik, phoenix, ParseBench
Size
211.3 MB
Stars
18.9K
Age
3y
Commits · 90 Days