Agent Skills
› OpenDCAI/DataFlow-WebUI
› bench-dataset-evaluator
bench-dataset-evaluator
GitHub基准数据集评估算子,支持匹配和语义两种模式,用于对比预测答案与标准答案。
Trigger Scenarios
进行基准测试评估
对比预测结果与真实标签
Install
npx skills add OpenDCAI/DataFlow-WebUI --skill bench-dataset-evaluator -g -y
SKILL.md
Frontmatter
{
"name": "bench-dataset-evaluator",
"description": "Reference documentation for the BenchDatasetEvaluator operator. Covers the constructor, two comparison modes (match\/semantic), and pipeline usage.\nUse when: comparing predicted answers against ground truth answers in benchmark evaluation."
}
BenchDatasetEvaluator Operator Reference
BenchDatasetEvaluator compares predicted answers against ground truth using two modes: match (math verification) or semantic (LLM-based).
1. Import
from dataflow.operators.core_text import BenchDatasetEvaluator
2. Match Mode
Constructor
BenchDatasetEvaluator(
eval_result_path=None,
compare_method="match",
)
| Parameter | Required | Default | Description |
|---|---|---|---|
eval_result_path |
No | Auto-generated | Path to save evaluation statistics JSON file |
compare_method |
No | "match" |
Must be "match" |
system_prompt |
No | "You are a helpful assistant..." |
Not used in match mode |
llm_serving |
No | None |
Not used in match mode |
prompt_template |
No | AnswerJudgePrompt |
Not used in match mode |
run() Signature
op.run(
storage=self.storage.step(),
input_test_answer_key="generated_cot",
input_gt_answer_key="golden_answer",
)
# returns: [input_test_answer_key, input_gt_answer_key, 'answer_match_result']
| Parameter | Required | Default | Description |
|---|---|---|---|
storage |
Yes | None | DataFlowStorage step object |
input_test_answer_key |
No | "generated_cot" |
Column containing predicted answers |
input_gt_answer_key |
No | "golden_answer" |
Column containing ground truth answers |
Runtime Logic
- Read DataFrame from storage.
- Create
answer_match_resultcolumn initialized toFalse. - For each row, extract answer using
AnswerExtractorand compare with ground truth usingmath_verify_compare(). - Write results to
answer_match_resultcolumn. - Save statistics to
eval_result_path. - Return column list.
Usage Example
from dataflow.operators.core_text import BenchDatasetEvaluator
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.evaluator = BenchDatasetEvaluator(
compare_method="match",
eval_result_path="./results/match_eval.json"
)
def forward(self):
self.evaluator.run(
storage=self.storage.step(),
input_test_answer_key="predicted_answer",
input_gt_answer_key="ground_truth"
)
if __name__ == "__main__":
pipeline = MyPipeline()
pipeline.forward()
3. Semantic Mode
Constructor
BenchDatasetEvaluator(
eval_result_path=None,
compare_method="semantic",
system_prompt="You are a helpful assistant specialized in evaluating answer correctness.",
llm_serving=llm_serving,
prompt_template=None,
)
| Parameter | Required | Default | Description |
|---|---|---|---|
eval_result_path |
No | Auto-generated | Path to save evaluation statistics JSON file |
compare_method |
Yes | None | Must be "semantic" |
system_prompt |
No | "You are a helpful assistant..." |
System prompt for LLM |
llm_serving |
Yes | None | LLM service object |
prompt_template |
No | AnswerJudgePrompt |
Pass None to use built-in fallback |
run() Signature
op.run(
storage=self.storage.step(),
input_test_answer_key="generated_cot",
input_gt_answer_key="golden_answer",
)
# returns: [input_test_answer_key, input_gt_answer_key, 'answer_match_result']
| Parameter | Required | Default | Description |
|---|---|---|---|
storage |
Yes | None | DataFlowStorage step object |
input_test_answer_key |
No | "generated_cot" |
Column containing predicted answers |
input_gt_answer_key |
No | "golden_answer" |
Column containing ground truth answers |
Runtime Logic
- Read DataFrame from storage.
- Create
answer_match_resultcolumn initialized toFalse. - Skip rows where ground truth is empty/NaN.
- Build prompts using only
answerandreference_answerfields. - Call LLM to judge correctness.
- Parse LLM response for
"judgement_result": true/false. - Write results to
answer_match_resultcolumn. - Save statistics to
eval_result_path. - Return column list.
Usage Example
from dataflow.operators.core_text import BenchDatasetEvaluator
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 = BenchDatasetEvaluator(
compare_method="semantic",
llm_serving=self.llm_serving,
prompt_template=None,
eval_result_path="./results/semantic_eval.json"
)
def forward(self):
self.evaluator.run(
storage=self.storage.step(),
input_test_answer_key="predicted_answer",
input_gt_answer_key="ground_truth"
)
if __name__ == "__main__":
pipeline = MyPipeline()
pipeline.forward()
4. AnswerJudgePrompt
AnswerJudgePrompt is the default prompt template class for semantic mode.
Important Notes
- Default value issue: Constructor default is
prompt_template=AnswerJudgePrompt(class, not instance). - Recommended usage: Pass
prompt_template=Noneto use built-in fallback. - Custom template: Pass an instance if you need custom prompts.
Prompt Structure
The prompt template builds a JSON-formatted request:
answer: The predicted answer to evaluatereference_answer: The ground truth answer
LLM response must contain:
{
"judgement_result": true // or false
}
Custom Template Example
from dataflow.prompts.core_text import AnswerJudgePrompt
custom_prompt = AnswerJudgePrompt()
# Modify if needed
evaluator = BenchDatasetEvaluator(
compare_method="semantic",
llm_serving=llm_serving,
prompt_template=custom_prompt
)
Version History
- 2e95d40 Current 2026-08-27 09:03


