LangSmith 评估。您需要首先定义一个评估器函数来判断智能体的结果,例如最终输出或轨迹。根据您的评估技术,这可能涉及也可能不涉及参考输出:
AgentEvals 包中的预构建评估器:
创建评估器
评估智能体性能的常见方法是将其轨迹(调用工具的顺序)与参考轨迹进行比较:- Specify how the trajectories will be compared.
supersetwill accept output trajectory as valid if it’s a superset of the reference one. Other options include: strict, unordered and subset
LLM-as-a-judge
您可以使用 LLM-as-a-judge 评估器,它使用 LLM 将轨迹与参考输出进行比较并输出分数:运行评估器
要运行评估器,您首先需要创建一个 LangSmith 数据集。要使用预构建的 AgentEvals 评估器,您需要一个具有以下模式的数据集:- input:
{"messages": [...]}input messages to call the agent with. - output:
{"messages": [...]}expected message history in the agent output. For trajectory evaluation, you can choose to keep only assistant messages.