Evaluations are a quantitative way to measure the performance of LLM applications. LLMs can behave unpredictably, even small changes to prompts, models, or inputs can significantly affect results. Evaluations provide a structured way to identify failures, compare versions, and build more reliable AI applications. Running an evaluation in LangSmith requires three key components:
  • Dataset: A set of test inputs (and optionally, expected outputs).
  • Target function: The part of your application you want to test—this might be a single LLM call with a new prompt, one module, or your entire workflow.
  • Evaluators: Functions that score your target function’s outputs.
This quickstart guides you through running a starter evaluation that checks the correctness of LLM responses, using either the LangSmith SDK or UI.

Prerequisites

Before you begin, make sure you have: Select the UI or SDK filter for instructions:

1. Set workspace secrets

在 LangSmith UI 中,确保你的 API 密钥已设置为工作区密钥。
  1. 导航至 设置,然后进入 密钥 选项卡。
  2. 选择 添加密钥,输入密钥环境变量(例如,OPENAI_API_KEY 或 ANTHROPIC_API_KEY),并将你的 API 密钥作为 值 填入。
  3. 选择 保存密钥。
在 LangSmith UI 中添加工作区密钥时,请确保密钥名称与你的模型提供商所要求的环境变量名称一致。
如果你的提供商使用 OAuth2 client_credentials 进行认证,请改为在模型配置中设置凭据。在这种情况下,无需使用工作区密钥。请参阅 OAuth 客户端凭据。

2. Create a prompt

The Playground makes it possible to run evaluations over different prompts, new models, or test different model configurations.
  1. In the LangSmith UI, click Playground in the sidebar.
  2. Under the Prompts panel, modify the system prompt to:
    Leave the Human message as is: {question}.

3. Create a dataset

  1. Click Set up Evaluation, which will open a New Experiment table at the bottom of the page.
  2. In the Select or create a new dataset dropdown, click the + New button to create a new dataset.
    Playground with the edited system prompt and new experiment with the dropdown for creating a new dataset.
  3. Add the following examples to the dataset:
  4. Click Save and enter a name to save your newly created dataset.

4. Add an evaluator

  1. Click + Evaluator and select Correctness from the Prebuilt Evaluator options.
  2. In the Correctness panel, click Save.

5. Run your evaluation

  1. Select Start on the top right to run your evaluation. This will create an experiment with a preview in the New Experiment table. You can view in full by clicking the experiment name.
    Full experiment view of the results that used the example dataset.

Next steps

To learn more about running experiments in LangSmith, read the evaluation conceptual guide.