本操作指南将演示如何设置和运行一种评估器类型(LLM 作为评判者)。有关包含使用示例的预构建评估器的完整列表,请参阅 openevals 和 agentevals 仓库。
设置
您需要安装openevals 包才能使用预构建的 LLM 作为评判者评估器。
openevals 也与 evaluate 方法无缝集成。有关设置说明,请参阅相应的指南。
运行评估器
一般流程很简单:从openevals 导入评估器或工厂函数,然后在测试文件中使用输入、输出和参考输出运行它。LangSmith 将自动将评估器的结果记录为反馈。
请注意,并非所有评估器都需要每个参数(例如,完全匹配评估器仅需要输出和参考输出)。此外,如果您的 LLM 作为评判者提示需要其他变量,将它们作为 kwargs 传入将把它们格式化到提示中。
像这样设置您的测试文件:
feedback_key/feedbackKey parameter will be used as the name of the feedback in your experiment.
Running the eval in your terminal will result in something like the following:
You can also pass prebuilt evaluators directly into the evaluate method if you have already created a dataset in LangSmith. If using Python, this requires langsmith>=0.3.11: