一键导入
unified-bench-dataset-evaluator
Reference documentation for the UnifiedBenchDatasetEvaluator operator. Use when: evaluating model answers on benchmark datasets.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Reference documentation for the UnifiedBenchDatasetEvaluator operator. Use when: evaluating model answers on benchmark datasets.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | unified-bench-dataset-evaluator |
| description | Reference documentation for the UnifiedBenchDatasetEvaluator operator. Use when: evaluating model answers on benchmark datasets. |
| trigger_keywords | ["UnifiedBenchDatasetEvaluator","unified-bench-dataset-evaluator","unified bench evaluation"] |
| version | 1.0.0 |
UnifiedBenchDatasetEvaluator supports 6 evaluation types (eval_type), scores generated answers, and writes 4 output columns.
from dataflow.operators.core_text import UnifiedBenchDatasetEvaluator
UnifiedBenchDatasetEvaluator(
eval_type="key2_qa",
llm_serving=None,
prompt_template=None,
eval_result_path=None,
metric_type=None,
use_semantic_judge=False,
system_prompt="You are a helpful assistant specialized in evaluating answer correctness.",
)
IMPORTANT: Always pass prompt_template=None explicitly. The default value is AnswerJudgePrompt (the class itself), which triggers a TypeError.
| Parameter | Required | Default | Description |
|---|---|---|---|
eval_type | No | "key2_qa" | Evaluation type |
llm_serving | Conditional | None | Required when use_semantic_judge=True |
prompt_template | No | AnswerJudgePrompt | Pass None to use built-in fallback |
eval_result_path | No | Auto-generated | Statistics JSON file path |
metric_type | No | None | Evaluation metric, auto-selected if not provided |
use_semantic_judge | No | False | Use LLM for semantic judgment |
system_prompt | No | "You are a helpful assistant..." | System prompt for LLM (used when use_semantic_judge=True) |
| eval_type | Required input_xxx_key |
|---|---|
key1_text_score | input_text_key |
key2_qa | input_question_key, input_target_key |
key2_q_ma | input_question_key, input_targets_key |
key3_q_choices_a | input_question_key, input_choices_key, input_label_key |
key3_q_choices_as | input_question_key, input_choices_key, input_labels_key |
key3_q_a_rejected | input_question_key, input_better_key, input_rejected_key |
op.run(
storage=self.storage.step(),
input_question_key="question",
input_target_key="golden_answer",
input_pred_key="generated_ans",
)
# returns: list of column names
| Parameter | Required | Default | Description |
|---|---|---|---|
storage | Yes | None | Storage step object |
input_pred_key | No | "generated_ans" | Model generated answer column |
input_question_key | Conditional | None | Question column |
input_target_key | Conditional | None | Single target answer column |
input_targets_key | Conditional | None | Multiple target answers column |
input_choices_key | Conditional | None | Choices column |
input_label_key | Conditional | None | Single label column |
input_labels_key | Conditional | None | Multiple labels column |
input_better_key | Conditional | None | Preferred answer column |
input_rejected_key | Conditional | None | Rejected answer column |
input_context_key | No | None | Optional context column for additional information |
eval_valid: Boolean column indicating if evaluation is valideval_error: Error message columneval_pred: Parsed prediction columneval_score: Numeric score columnfrom dataflow.operators.core_text import UnifiedBenchDatasetEvaluator
from dataflow.serving import APILLMServing_request
from dataflow.utils.storage import FileStorage
class MyPipeline:
def __init__(self):
self.storage = FileStorage(
first_entry_file_name="./data/bench.jsonl",
cache_path="./cache",
file_name_prefix="step",
cache_type="jsonl"
)
self.llm_serving = APILLMServing_request(
api_url="https://api.openai.com/v1/chat/completions",
key_name_of_api_key="DF_API_KEY",
model_name="gpt-4o",
max_workers=10
)
self.evaluator = UnifiedBenchDatasetEvaluator(
eval_type="key2_qa",
llm_serving=self.llm_serving,
prompt_template=None,
use_semantic_judge=True
)
def forward(self):
self.evaluator.run(
storage=self.storage.step(),
input_question_key="question",
input_target_key="golden_answer",
input_pred_key="generated_ans"
)
if __name__ == "__main__":
pipeline = MyPipeline()
pipeline.forward()
eval_type must match BenchAnswerGenerator's eval_typeeval_result_path JSON fileuse_semantic_judge=True requires llm_servinginput_xxx_key columns exist based on eval_type.eval_valid, eval_error, eval_pred, eval_score.input_pred_keyeval_typeuse_semantic_judge=True: call LLM to judge correctnessuse_semantic_judge=False: use rule-based comparisoneval_result_path JSON file.AnswerJudgePrompt (class, not instance) → causes TypeErrorprompt_template=None to use built-in fallbackuse_semantic_judge=True# Recommended: pass None
evaluator = UnifiedBenchDatasetEvaluator(
eval_type="key2_qa",
llm_serving=llm_serving,
prompt_template=None,
use_semantic_judge=True
)
from dataflow.prompts.core_text import AnswerJudgePrompt
# Pass an instance for custom prompts
custom_prompt = AnswerJudgePrompt()
evaluator = UnifiedBenchDatasetEvaluator(
eval_type="key2_qa",
llm_serving=llm_serving,
prompt_template=custom_prompt,
use_semantic_judge=True
)
build_prompt(...)When using custom AnswerJudgePrompt instance, the operator passes:
answer: The predicted answerreference_answer: The ground truth answerLLM response must contain:
{
"judgement_result": true // or false
}
DataFlow 开发专家上下文加载器。当用户在 DataFlow 仓库中进行开发时触发, 涵盖:新建算子/Pipeline/Prompt、诊断报错、规范审查、 以及感知仓库变更并建议更新知识库。 Trigger: user is developing in DataFlow repo, asks to create operator/pipeline/prompt, encounters errors, wants code review, or asks about operators.
Reasoning-guided pipeline planner that generates standard DataFlow pipeline code
Reference documentation for the BenchDatasetEvaluatorQuestion operator. Extended version of BenchDatasetEvaluator with question and subquestion support. Use when: evaluating answers with question context or multiple subquestions.
Reference documentation for the BenchDatasetEvaluator operator. Covers the constructor, two comparison modes (match/semantic), and pipeline usage. Use when: comparing predicted answers against ground truth answers in benchmark evaluation.
Reference documentation for the PromptedEvaluator operator. Use when: scoring text quality with LLM without filtering rows.
Reference documentation for the Text2QASampleEvaluator operator. Use when: evaluating QA pair quality across multiple dimensions.