多模型评审团加权投票的评估机制

该资料介绍一种让多个不同提供商的模型独立评审同一输出并汇总结论的评估方式,支持加权平均连续分数与按权重计票两种模式,并区分有无参考答案的评估场景。

一个 **LLM陪审团** 通过若干个LLM(通常来自不同的提供方)来进行同样的判断,并合并其判决。 每个陪审员都有信任权重,最终得分是每个陪审员得分的加权平均值,以及每个陪审员的标签(加上任何错误)在 `explanation` 因此,你可以审计谁投票什么。 **reference-free**: 陪审员只根据问题来评分答案,没有可以比较的地面真实标签。 这是在您没有标签数据时的正确模式 — — 生产痕迹、无限制的一代,或者任何“正确”答案不是固定的字符串,您可以在数据集中存储。 **无参考文献 vs. 参考文献.** 评估员是: *reference-based* 当它将输出比作一个存储在示例旁的已知好答案时——这个标签就是使数据集成为一个 **黄金数据集**,以及诸如 [JSON 远程](<https://arize.com/docs/phoenix/evaluation/server-evals/code-evaluators/json-distance>) 或 [对等评价员](<https://arize.com/docs/phoenix/evaluation/server-evals/code-evaluators/pairwise>) 依赖它。 *无参考文献* 评估者跳过该比较并对照输入单独(或对照数字标准)判断输出,这是在没有黄金答案的情况下你必须做的。要将这个示例转换成基于引用的,请更改快捷键以进行比较 `output` 反对 `reference` 并绑定 `reference` 参数在输入映射面板中。 联系LLM陪审团,如果: - 一个法官的偏见或自我偏爱正在扭曲你的得分,你想要一个更强有力的判决。 - 输出量高,N型呼叫的额外费用值更可靠分数. - 你们将判断模型相互比对基准 — — 每张表格显示他们对数据集的同意率。 实施用途 `arize-phoenix-evals` / `@arizeai/phoenix-evals` 把每个供应商都放在制服后面 `ClassificationEvaluator` 界面,所以添加陪审员是一线人。每个陪审员都看到同样的提示;他们的判断和权重结合到一个分数中,并且每个Juor的标签(加上任何错误)在解释中着陆。 ## 代码 - Python 键 - TypeScript ``` from phoenix.evals import LLM, ClassificationEvaluator _PROMPT = ( "Does the answer correctly and completely address the question?\n\n" "Question: {input}\n\nAnswer: {output}" ) _CHOICES = {"correct": 1.0, "partially_correct": 0.5, "incorrect": 0.0} # Each juror: (LLM, weight). Weights reflect how much you trust each model. _JURORS = [ (LLM(provider="openai", model="gpt-6-luna"), 1.0), (LLM(provider="anthropic", model="claude-haiku-4-5"), 1.0), (LLM(provider="google", model="gemini-2.5-flash"), 0.8), ] _EVALUATORS = [ ( ClassificationEvaluator( name=f"jury_{llm.provider}", llm=llm, prompt_template=_PROMPT, choices=_CHOICES, ), weight, ) for llm, weight in _JURORS ] def evaluate(output, input): if not output or not input: return { "label": "missing", "score": 0.0, "explanation": "Missing input or output.", } inputs = {"input": str(input), "output": str(output)} weighted_sum = 0.0 weight_total = 0.0 parts = [] for evaluator, weight in _EVALUATORS: try: result = evaluator.evaluate(inputs)[0] except Exception as exc: parts.append(f"{evaluator.name}=error:{exc.__class__.__name__}") continue score = result.score if result.score is not None else 0.0 weighted_sum += weight * score weight_total += weight parts.append( f"{evaluator.name}({result.label or '?'})={score:.2f}×{weight:.1f}" ) if weight_total == 0.0: return { "label": "invalid", "score": 0.0, "explanation": "All jurors errored. " + "; ".join(parts), } final_score = weighted_sum / weight_total return { "score": final_score, "explanation": f"Jury={final_score:.4f}; " + ", ".join(parts), } ``` **沙盒依赖性** ——粘贴到沙盒配置的依赖字段,每行一个包: ``` arize-phoenix-evals openai anthropic google-genai ``` ``` import { anthropic } from "@ai-sdk/anthropic"; import { google } from "@ai-sdk/google"; import { openai } from "@ai-sdk/openai"; import { ClassificationEvaluator, createClassificationEvaluator, } from "@arizeai/phoenix-evals"; const PROMPT = "Does the answer correctly and completely address the question?\n\n" + "Question: {{ input }}\n\nAnswer: {{ output }}"; const CHOICES = { correct: 1, partially_correct: 0.5, incorrect: 0 }; // Each juror: an evaluator + a trust weight. const JURORS: Array<{ evaluator: ClassificationEvaluator<{ input: string; output: string }>; weight: number; name: string; }> = [ { name: "openai", weight: 1.0, evaluator: createClassificationEvaluator({ name: "jury_openai", model: openai("gpt-6-luna"), promptTemplate: PROMPT, choices: CHOICES, }), }, { name: "anthropic", weight: 1.0, evaluator: createClassificationEvaluator({ name: "jury_anthropic", model: anthropic("claude-haiku-4-5"), promptTemplate: PROMPT, choices: CHOICES, }), }, { name: "google", weight: 0.8, evaluator: createClassificationEvaluator({ name: "jury_google", model: google("gemini-2.5-flash"), promptTemplate: PROMPT, choices: CHOICES, }), }, ]; async function evaluate({ output, input }: EvaluatorParams) { if (!output || !input) { return { label: "missing", score: 0, explanation: "Missing input or output.", }; } const inputs = { input: String(input), output: String(output) }; // Fan out to all jurors in parallel — independent API calls. const settled = await Promise.allSettled( JURORS.map(({ evaluator }) => evaluator.evaluate(inputs)) ); let weightedSum = 0; let weightTotal = 0; const parts: string[] = []; settled.forEach((res, i) => { const { name, weight } = JURORS[i]; if (res.status === "rejected") { parts.push(`${name}=error:${(res.reason as Error).name}`); return; } const score = res.value.score ?? 0; weightedSum += weight * score; weightTotal += weight; parts.push( `${name}(${res.value.label ?? "?"})=${score.toFixed(2)}×${weight.toFixed(1)}` ); }); if (weightTotal === 0) { return { label: "invalid", score: 0, explanation: `All jurors errored. ${parts.join("; ")}`, }; } const finalScore = weightedSum / weightTotal; return { score: finalScore, explanation: `Jury=${finalScore.toFixed(4)}; ${parts.join(", ")}`, }; } ``` TypeScript版本的粉丝们与所有陪审员同时出场 `Promise.allSettled`,所以"墙钟"(wall-hour-lattency)是大约最慢的单个陪审员的电话,而不是总和. Python版本按顺序发送;如果"空档"(lattency)很重要,请各提交. `evaluator.evaluate(...)` 呼叫一个 `concurrent.futures.ThreadPoolExecutor` 并收集结果。**沙盒依赖性** ——粘贴到沙盒配置的依赖字段,每行一个包: ``` @arizeai/phoenix-evals ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/google ``` ## 输入映射 | 参数 | 绑定到 | | --- | --- | | `input` | 问(或即时/任务) 模型被问到答案,通常 `input`. | | `output` | 模型输出到级别, 通常 `output`. | 没有 `reference` 需要 —— 这是一个无引用的判断。 如果您确实有标签数据并想要使用, 请添加一个 `reference` 参数到函数签名,更新提示将其包含,并将其绑定在输入映射面板中。 ## 输出配置 在幅度内持续得分 `0.0` 改为: `1.0` (匹配所配置的选择分数的加权平均值). 优化方向 : **最大化**. ## 运行时间要求 | 设置 | 数值 | | --- | --- | | 沙盒 | A **主办单位** 匹配语言的后端。 Python : **E2B**, **代托纳-蟒蛇**, **Vercel 沙盒- Python**,或 **模式**. TypeScript: **代托纳-TypeScript** 或 时 间 **Vercel Sandbox — TypeScript (英语).** (当地德诺沙盒是: `--no-npm` 并且不能安装 npm 包。 | | 依赖关系 | Python : (原始内容存档于2017-09-29). `arize-phoenix-evals`, `openai`, `anthropic`, `google-genai`. TypeScript: `@arizeai/phoenix-evals`, `ai`, `@ai-sdk/openai`, `@ai-sdk/anthropic`, `@ai-sdk/google`. | | 互联网接入 | **要求数** - 沙盒必须到达 `api.openai.com`, `api.anthropic.com`,以及 `generativelanguage.googleapis.com`. | | 环境变量 | `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GOOGLE_GENERATIVE_AI_API_KEY` ——各设为a. **秘密引用** 键入 [设置 – 保密](<https://arize.com/docs/phoenix/settings/secrets>)。如果您不想提供提供方的钥匙,则完全放弃陪审员。 | 陪审团认为 **N API 按例调用** ——每名陪审员1人,在冷开机时支付每个提供商SDK的全部安装费用. `arize-phoenix-evals` 单枪匹马 `pydantic`; 每位供应商 SDK 添加了另一个 10 – 40 MB 的沙盒配置 . **超时** 以舒适的方式覆盖 N 的圆路加安装,再利用相同的配置横跨,以便提供者可以温暖地切换它. 上面的型号ID(英语:Model ID).`gpt-6-luna`, `claude-haiku-4-5`, `gemini-2.5-flash`)是撰写文件时的合理缺省——从提供者的文档中交换最新的稳定身份证。 ## 备选案文 ### 加权多数投票(分类陪审团) 下游消费者需要独立判断时使用这个方法(如果下游消费者需要独立判断,则使用这个方法(如果下游消费者需要,则使用这个方法),而不是平均数分,而是按标签计票,然后按重量计票。`correct` / `incorrect`)而不是连续的分数。下面的草图将替换分数的积分区块;每焦耳的收集循环保持不变: ``` votes: dict[str, float] = {} for label, weight in juror_results: # collected the same way as above votes[label] = votes.get(label, 0.0) + weight winner = max(votes, key=votes.get) if votes else "invalid" return { "label": winner, "score": _CHOICES.get(winner, 0.0), "explanation": f"Votes: {votes}", } ``` ### 协议过滤器( 高度信任子集) 对于培训数据过滤,仅在下列时间返回非零分: **全部( E)** 陪审员同意——否则就放弃这个例子。 `0` 或 时 间 `1`; 标签变为 `agreement` / `disagreement`. ## 相关 - [对等评价员](<https://arize.com/docs/phoenix/evaluation/server-evals/code-evaluators/pairwise>) - 单人LLM 判断 `output` head-to-head 反对: `reference` 基线(为避免位置偏差而忽略)。 - [综合评价员](<https://arize.com/docs/phoenix/evaluation/server-evals/code-evaluators/composite>) ——结合不同. *轴* 判决(从可能不同的法官)改为一个分数。 ## 进一步阅读 - [比较评估的LLM-as-a-jury](<https://arxiv.org/abs/2602.16610>) - Qian等人提议BT-sigma,共同推断项目排名 *财务报告和财务报告* 从对等的比较中判断可靠性,这样,具有不同信任水平的陪审员就可以在不进行同等加权的情况下进行汇总。在调整上述例子中的每个法官的权重时,有有用的背景。 - [12 愤怒 AI 代理:评价多代理 LLM 通过电影评委评议决策](<https://arxiv.org/abs/2605.01986>) ——Ersoz. Finds 锚定是模拟陪审团评议中LLMs的主要失败模式——支持本页面中运行陪审员的设计选择. **独立平行** 而不是让他们看到彼此的判决。 这页有用吗? [建议编辑](<https://github.com/arize-ai/phoenix/edit/main/docs/phoenix/evaluation/server-evals/code-evaluators/llm-jury.mdx>)提出问题

查看原始来源