Glean 拾遗
Daily /2026-08-10 / Your App Is Only As Good As Its Evals

Your App Is Only As Good As Its Evals

Source www.aihero.dev Glean’d 2026-08-10 06:00 Read 9 min
AI summary

In LLM apps, inputs no longer map to deterministic outputs—any small change can remake the entire behavior. This post argues that evals are the AI engineer's unit tests, the primary way to impose predictability on a probabilistic system. It walks through three evaluation types: deterministic assertions, human review, and LLM-as-a-judge, noting the cost trade-offs and recommending split cadences (fast local set vs. daily full set). It then explains the data flywheel: converting user downvotes into new eval cases and feeding them back into the system. Tooling compares Braintrust, a cloud eval platform, with Evalite, the author's Vitest-based local runner. Useful for engineers moving LLM prototypes to production.

Original · 9 min
www.aihero.dev ↗
§ 1

As we discussed in our previous article, building with LLMs requires a fundamental shift in how you think about software development. You're no longer designing deterministic systems where inputs map to predictable outputs. Instead, you're working with probabilistic systems which are inherently unpredictable.

The key tool for managing this uncertainty is evals. Evals are the AI engineer's unit tests. They are how you wrangle predictability from a probabilistic system. They are an indispensable part of productionizing any AI app.

Let's break down what evals are, and why AI apps need them so badly.

正如我们在上一篇文章中讨论的,用 LLM 构建应用需要你对软件开发的方式进行根本性转变。你不再设计那种输入映射到可预测输出的确定性系统;相反,你面对的是本质不可预测的概率性系统。

管理这种不确定性的关键工具就是 eval。Eval 是 AI 工程师的单元测试。它是你从概率系统中逼出可预测性的手段,也是任何 AI 应用走向生产环境时不可或缺的一环。

下面我们来拆解 eval 到底是什么,以及为什么 AI 应用如此需要它。

§ 2

Traditional software testing relies on deterministic relationships between inputs and outputs. Each component has a clear domain of responsibility:

But LLM-powered systems are different. Every input goes through a complex transformation process that's hard to predict:

In AI systems, no change is small. Their attention and transformation mechanisms are inscrutable. Whether the butterfly "flaps" or "Flaps" its wings may change the output. To put it mildly, building robust systems with them requires care.

传统软件测试依赖输入和输出之间的确定性关系。每个组件都有明确的职责边界:

但由 LLM 驱动的系统不同。每一个输入都要经过一个难以预测的复杂变换过程:

在 AI 系统里,没有小改动。注意力和变换机制难以捉摸。蝴蝶的翅膀是 "flaps" 还是 "Flaps",都可能改变输出。说得客气一点,要用它们构建健壮的系统,必须非常小心。

§ 3

It's easy to get an impressive AI demo working quickly. But getting that AI system to production is not easy.

Specifically, it's hard to know whether the things you're changing about your app are getting better or worse. You make a change, try a few favourite prompts and see if it "feels" better. But this is a dangerous way to work.

A "Manual QA-only" approach in deterministic software is usually doable. You say "I added a new page" and the QA team can rigorously test the new page, and smoke test the previous pages.

But in probabilistic systems, it is a killer. When any change can affect the entire system, you need a way to know if your system is getting better or worse.

This is especially true for large changes, like which model you use, or the design of your prompt.

The key is automation. We need to evaluate our app every time we make a change, or every time the underlying model changes.

让一个惊艳的 AI demo 跑起来很容易,但把 AI 系统送上生产环境并不容易。

具体来说,你很难知道你正在做的改动到底让应用变好了还是变坏了。你改了一处,试几个喜欢的 prompt,看看是否“感觉”更好了。但这样工作非常危险。

“只靠人工 QA”的做法在确定性软件里通常可行。你说“我加了新页面”,QA 团队就能严格测试新页面,并对旧页面做冒烟测试。

但在概率性系统中,这足以致命。既然任何改动都可能影响整个系统,你需要一种方法来判断系统是在变好还是变坏。

对于大改动尤其如此,比如更换模型,或重新设计 prompt。

关键在于自动化。我们需要在每次改动代码、或底层模型变化时,都评估一次应用。

§ 4

Traditional, Deterministic Systems

In deterministic systems, automating testing is relatively straightforward. You can feed some inputs in and check the outputs.

const output = myNormalSystem(input);

// Will fail if the output doesn't match

assert(output === "my-desired-output");

These assertions are 'pass' or 'fail'. And usually, an app has to pass every test to be considered production-ready.

传统的确定性系统

在确定性系统中,自动化测试相对直接。你可以喂入一些输入,然后检查输出。

const output = myNormalSystem(input);

// Will fail if the output doesn't match

assert(output === "my-desired-output");

这些断言只有“通过”或“不通过”。通常,一个应用必须通过所有测试,才能被认为达到生产就绪状态。

§ 5

Probabilistic Systems

But writing these tests for AI isn't as straightforward.

Let's say your app generates written articles. You want to check that the output is good enough for production. You might need to write assertions for:

Factuality: checking if all statements in the output are factually correct

Writing style: ensuring that the text is elegant and well-written

Prompt fidelity: ensuring that the output actually corresponds to what the user asked.

These are qualitative metrics. Instead of a pass/fail, they need to be represented by a score. Each time you change your app, you need to know if it made the system 5% better, or 50% worse.

This is what evals do - they give you a score you can use to see how well your AI system is performing.

概率性系统

但要为 AI 写这类测试就没那么简单了。

假设你的应用生成文章。你想检查输出是否达到可上线的质量。你可能需要为以下方面写断言:

事实性:检查输出中的所有陈述是否事实正确

写作风格:确保文本优雅、文笔好

指令遵循:确保输出确实对应用户的要求

这些都是定性指标。它们不能简单地用“通过/不通过”表示,而是需要用一个分数来体现。每次改动应用,你都需要知道它是让系统好了 5%,还是糟了 50%。

这正是 eval 做的事——它给你一个分数,让你看清 AI 系统的表现。

§ 6

There are three main types of evals you can run on your AI system.

Deterministic Evals

There are deterministic evals, which can be written as simple assertions.

const article = writeArticleWithLLM(prompt);

// Article should be more than 300 words long

assert(article.length >= 300);

// Article should be less than 2,000 words long

assert(article.length <= 2000);

These are traditional pass/fail checks. You would pass a wide variety of prompts into your system, and check each time if they pass these tests.

They're simple to write, but only cover a subset of what you want to evaluate.

你可以在 AI 系统上运行三种主要类型的 eval。

确定性 eval

确定性 eval 可以写成简单断言。

const article = writeArticleWithLLM(prompt);

// Article should be more than 300 words long

assert(article.length >= 300);

// Article should be less than 2,000 words long

assert(article.length <= 2000);

这些都是传统的“通过/不通过”检查。你可以向系统传入各种各样的 prompt,每次都检查它们是否通过这些测试。

它们写起来简单,但只能覆盖你想评估的一部分内容。

§ 7

For more probabilistic metrics, you have two choices.

Human Evaluation

You can use human evaluation to check whether your system is performing correctly. This is often your only choice early on, when you don't have a lot of data.

This is expensive, and time consuming - but all AI systems will rely on human input to some extent.

对于更偏概率性的指标,你有两个选择。

人工评估

你可以用人工评估来检查系统是否表现正确。在早期数据不多时,这往往是你唯一的选择。

人工评估既贵又耗时——但所有 AI 系统在某种程度上都要依赖人的判断。

§ 8

LLM As A Judge

Another technique is to pass the results of your prompts into another LLM, and use that LLM as a judge. This is currently a very fashionable way to evaluate AI systems.

Let's imagine you may want to make sure your app is telling the truth. You can do that by passing your system's output into a LLM, along with some ground truth.

An example of this in action can be found on the Evalite docs.

LLM-as-a-judge makes certain evaluations possible - but at a cost. Running LLMs is expensive, so you need to think carefully about what cadence you run them at. Running your evals every time your files change, for example, would be prohibitively expensive.

Common strategies include splitting your evals into two sets - a smaller group for local testing, and a larger group to be run daily.

LLM 当裁判

另一种技术是把 prompt 的结果传给另一个 LLM,让这个 LLM 当裁判。这是目前评估 AI 系统非常时髦的做法。

假设你想确保应用不说谎。你可以把系统输出连同一些事实依据(ground truth)一起传给一个 LLM。

具体示例可以看 Evalite 的文档。

LLM 当裁判让某些评估成为可能——但这是有代价的。运行 LLM 很贵,所以你需要仔细考虑以什么频率运行它们。比如每次文件变更都跑 eval,成本会高到无法承受。

常见的策略是把 eval 分成两套:一小套用于本地测试,一大套每天运行。

§ 9

Your evals are the method by which you monitor and improve your AI system. This also means that the dataset you use to evaluate your system is crucial.

You need to make sure that your evals are representative of the data your system will see in production. If you're building a classifier, you need to make sure your evals cover all the edge cases your system will see.

This means it's crucial to build in observability and feedback systems into your application. Once your app is deployed, your users will be the judge of whether your system is working or not. Simple feedback buttons, like upvotes and downvotes, can give you extremely valuable insights into how your system is performing.

The Data Flywheel

Vercel, creators of v0, have written about the AI Native Flywheel. They describe the importance of evals in the AI development process.

The best data for your evals comes from your users. By carefully monitoring how users are using your app, you can build a feedback loop that will help you improve your system over time. Let's take an example:

A user asks your app "build me a classy React application"

Your app generates some React code. But instead of making the UI look "classy", it uses classes in the code.

The user downvotes the response. Perhaps they even leave a comment explaining why.

You take the prompt "build me a classy React application", and create a new eval for it. You add it to your eval suite.

You improve the system until it passes the eval.

You re-deploy. The next time a user hits this prompt, they get a better response.

This is the data flywheel in action. By carefully monitoring your system, and building in feedback loops, you can ensure your system is always improving.

Eval 是你监控和改进 AI 系统的方法。这也意味着,用来评估系统的数据集至关重要。

你需要确保 eval 能代表系统在生产环境中会看到的数据。如果你在构建分类器,就要保证 eval 覆盖系统会遇到的所有边界情况。

因此,在应用里构建可观测性和反馈机制至关重要。应用上线后,你的用户才是判断系统是否好用的裁判。简单的反馈按钮,比如顶和踩,能给你极有价值的系统表现洞察。

数据飞轮

v0 的缔造者 Vercel 写过关于 AI Native Flywheel(AI 原生飞轮)的文章。他们描述了 eval 在 AI 开发过程中的重要性。

eval 最好的数据来自你的用户。通过仔细监控用户如何使用你的应用,你可以构建一个反馈回路,帮助系统持续改进。举个例子:

用户问你的应用“给我建一个 classy 的 React 应用”

你的应用生成了一些 React 代码,但并没有让 UI 看起来“classy”(优雅),反而在代码里用了 class(类)。

用户踩了这个回复。也许还留下评论解释原因。

你拿起“给我建一个 classy 的 React 应用”这个 prompt,为它创建了一个新 eval,加入 eval 套件。

你不断改进系统,直到它通过这个 eval。

你重新部署。下一次用户输入这个 prompt 时,会得到更好的回复。

这就是数据飞轮的实际运作。通过仔细监控系统、构建反馈回路,你可以确保系统一直在改进。

§ 10

There are many methods for running evals. A large number of startups have entered the space, offering tools to run your evals and view them online.

Braintrust is a popular choice. They provide a cloud platform for running evals and sharing the results with your team, along with many other features. You can write your evals in TypeScript using their SDK. However, they use rate limits on your evals - which can be frustrating when you're trying to iterate quickly.

I maintain a library called Evalite, which is a lightweight eval runner based on the TypeScript test runner Vitest.

Evalite is designed to allow you to run your evals locally. There's no cloud platform attached, so you can run your evals as often as you like. It's a good choice if you're just starting out.

运行 eval 的方法有很多。大量创业公司涌入这个领域,提供在线运行 eval 并查看结果的工具。

Braintrust 是一个热门选择。他们提供云端平台来运行 eval、与团队分享结果,还有许多其他功能。你可以用他们的 SDK 用 TypeScript 编写 eval。不过,他们对 eval 有速率限制——当你想要快速迭代时,这可能会让人沮丧。

我维护了一个叫 Evalite 的库,它是一个基于 TypeScript 测试运行器 Vitest 的轻量级 eval 运行器。

Evalite 的设计让你可以在本地运行 eval。它不绑云端平台,所以你想跑多少次就跑多少次。如果你刚开始接触 eval,这会是一个不错的选择。

§ 11

Imagine an eval kind of like a function:

// 1. The prompts we'll test with

"Fish species in the Mediterranean",

"Story of the first Moon landing",

// 2. A function to generate outputs based

return generateArticle(topic);

// 3. The scorers we'll use to generate

// Checks if output is long enough

// Uses an LLM to check if it's accurate

// Uses an LLM to check writing style

// 4. A score between 0-100%

We pass in a set of prompts (1), then the task to run (2), then the methods we're using to score our output (3).

Finally, we get back a score on how well our function performed (4).

This, at its heart, is what an eval is. This API is loosely inspired by Braintrust's autoevals library.

把 eval 想象成一种函数:

// 1. The prompts we'll test with

"Fish species in the Mediterranean",

"Story of the first Moon landing",

// 2. A function to generate outputs based

return generateArticle(topic);

// 3. The scorers we'll use to generate

// Checks if output is long enough

// Uses an LLM to check if it's accurate

// Uses an LLM to check writing style

// 4. A score between 0-100%

我们传入一组 prompt(1),然后是要运行的任务(2),再传入我们用来给输出打分的方法(3)。

最后,我们会得到一个分数,显示函数表现得如何(4)。

这本质上就是一个 eval。这个 API 大致受到了 Braintrust 的 autoevals 库的启发。

§ 12

This image, based on Vercel's AI Native Flywheel, captures the impact evals have on your application.

They should be the center of your feedback loop. As more users use your app (distribution), they'll give you more data (usage). You can use this data to improve your app (data), and then run your evals again (evals).

These evals let you respond to new techniques and models, and put you on a constant path of improvement.

这张图基于 Vercel 的 AI Native Flywheel,捕捉了 eval 对你应用的影响。

它们应该成为你反馈回路的中心。随着更多用户使用你的应用(distribution),他们会给你更多数据(usage)。你可以用这些数据改进应用(data),然后再次运行 eval(evals)。

这些 eval 让你能响应新技术和新模型,并把你放在一条持续改进的道路上。

Open source ↗