用户摩擦评估器的分类机制与输入映射

该评估器判断最新用户消息是否对助手先前行为表达摩擦,可识别纠正、重试、不满及对未请求操作的质疑。它支持span级别,输入为对话文本,输出摩擦或无摩擦标签,也可改用决策模型直接给出标签与概率。

## 概览 那个... **用户缩写** 评估者将最新的用户信息是否表达与助手先前行为的摩擦进行分类。 它可以检测纠正,在回应失败后重复,挫折感,以及对无要求或无解释行动的挑战。 使用它来监测对话助理,确定值得审查的转折,并衡量产品变化是否减少了表达的用户摩擦。 `no_friction` 表示没有表示摩擦. 它不能证明用户是满意的; 用户经常放弃对话而不说明原因. ## 支持的级别 | 职等 | 获得支持 | 页:1 | | --- | --- | --- | | **宽度** | 对 | 当一个跨度包含前面的对讲和最新的用户消息时应用 。 | | **追踪** | 对 | 每次追踪都代表了一次对话的转折,很有用。 | | **会话** | 对 | 在第一个用户使用上一个会话历史后, 评估每个用户的转动 。 | **相关跨度类型:** AGENT,CHAIN,以及LLM的跨度,保存了多回合对话历史. ## 所需投入 | 外地 | 类型 | 说明 | | --- | --- | --- | | `conversation` | `string` | 目标用户消息前的人类可读对话. | | `user_message` / `userMessage` | `string` | 要分类的最新用户信息 。 | 保持目标消息与 `conversation`. 包含足够的以往历史,以区分复读和校正与普通后续。在评价前,精确地进行变形工具活动并清除非人类有效载荷。 ## 口译 | 财产 | 数值 | 说明 | | --- | --- | --- | | `label` | `"friction"` 或 时 间 `"no_friction"` | 分类结果 | | `score` | `1.0` 或 时 间 `0.0` | `1.0` 表示的摩擦 | | `explanation` | `string` | 法官推理。只有在评价员得到语文模型的支持时才到场(`LLM`;决定模型返回一个标签,带有概率,没有解释。 | | `direction` | `"minimize"` | 总分比较低 | ## 用法实例 - Python 键 - TypeScript ``` from phoenix.evals import LLM from phoenix.evals.metrics import UserFrictionEvaluator evaluator = UserFrictionEvaluator( llm=LLM(provider="openai", model="gpt-6-luna"), temperature=0.0, ) scores = evaluator.evaluate({ "conversation": ( "User: Show orders from this week.\n" "Assistant: Here are last month's orders." ), "user_message": "No, I asked for this week.", }) print(scores[0]) # Score(name='user_friction', score=1.0, label='friction', ...) ``` ``` import { createUserFrictionEvaluator } from "@arizeai/phoenix-evals"; import { openai } from "@ai-sdk/openai"; const evaluator = createUserFrictionEvaluator({ model: openai("gpt-6-luna"), }); const result = await evaluator.evaluate({ conversation: "User: Show orders from this week.\nAssistant: Here are last month's orders.", userMessage: "No, I asked for this week.", }); console.log(result); // { score: 1, label: "friction", explanation: "..." } ``` ## 使用决定模式 同一评价员可由一名评价员提供支持。 **决策模式** 而不是语言模型。决定模型直接选择标签并返回每个标签的概率(以及当提供者报告一个时的信任),但没有解释。 - Python 键 - TypeScript ``` from phoenix.evals import DecisionModel from phoenix.evals.metrics import UserFrictionEvaluator # Back the evaluator with a decision model instead of an LLM evaluator = UserFrictionEvaluator(llm=DecisionModel(provider="openai", model="gpt-6-luna")) scores = evaluator.evaluate({ "conversation": ( "User: Show orders from this week.\n" "Assistant: Here are last month's orders." ), "user_message": "No, I asked for this week.", }) print(scores[0]) ``` ``` import { createUserFrictionEvaluator } from "@arizeai/phoenix-evals"; import { openai } from "@ai-sdk/openai"; const evaluator = createUserFrictionEvaluator({ model: openai.decisionModel("gpt-6-luna"), }); ``` ## 使用输入映射 将您的跟踪或数据集字段映射到评估器的两字段合同中。对话应该在目标用户消息之前结束。 ``` input_mapping = { "conversation": lambda row: render_messages(row["messages"][:-1]), "user_message": lambda row: row["messages"][-1]["content"], } scores = evaluator.evaluate(dataset_row, input_mapping) ``` 见 [输入映射](<https://arize.com/docs/phoenix/evaluation/concepts-evals/input-mapping>) 用于额外的绘图选项。 ## 查看和修改提示 默认提示在 [分类评价员配置](<https://github.com/Arize-ai/phoenix/blob/main/prompts/classification_evaluator_configs/USER_FRICTION_CLASSIFICATION_EVALUATOR_CONFIG.yaml>)。当您的应用程序有特定域的对话常规时, 将它修改 。 ``` import { createUserFrictionEvaluator, } from "@arizeai/phoenix-evals"; const evaluator = createUserFrictionEvaluator({ model, promptTemplate: `Conversation: {{conversation}} Latest user message: {{userMessage}} Does the latest message express friction?`, choices: { friction: 1, no_friction: 0 }, }); ``` ## 配置 关于模型和提供者选项,见 [配置 LLM](<https://arize.com/docs/phoenix/evaluation/how-to-evals/configuring-the-llm>). ## 与凤凰一起使用 - [评估凤凰网追踪](<https://arize.com/docs/phoenix/tracing/how-to-tracing/feedback-and-annotations/evaluating-phoenix-traces>) - [记录 LLM 评价](<https://arize.com/docs/phoenix/tracing/how-to-tracing/feedback-and-annotations/llm-evaluations>) - [在实验中使用评价员](<https://arize.com/docs/phoenix/datasets-and-experiments/how-to-experiments/using-evaluators>) ## 基准 使用 40 - 模拟公共合成基准 `gpt-4o-mini`,默认提示实现0.97精度,0.98宏精度,0.97宏召回,以及0.97宏F1. See [user_friction .eval.ts (英语).](<https://github.com/Arize-ai/phoenix/blob/main/js/benchmarks/evals-benchmarks/src/user_friction.eval.ts>) 用于分类示例集。 ## API 参考文献 - **Python : (原始内容存档于2017-09-29).** [UserFrictionEvaluator](<https://arize-phoenix.readthedocs.io/projects/evals/api/evals.html#module-phoenix.evals.metrics>) - **TypeScript:** [createUserFrictionEvaluator](<https://arize-ai.github.io/phoenix/modules/_arizeai_phoenix-evals.llm.html>) ## 相关 - [拒绝评价者](<https://arize.com/docs/phoenix/evaluation/pre-built-metrics/refusal>) - [正确性评价员](<https://arize.com/docs/phoenix/evaluation/pre-built-metrics/correctness>) 这页有用吗? [建议编辑](<https://github.com/arize-ai/phoenix/edit/main/docs/phoenix/evaluation/pre-built-metrics/user-friction.mdx>)提出问题

查看原始来源