Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ resume: true # allo
# iteration related parameters
max_iter_num: 5
iter_targets:
- "grader_model_prompt_optimization.grades_evaluation.min_mse <= 0.26"
- "grader_model_prompt_optimization.grades_evaluation.min_mse <= 0.2"
iter_updater:
select_and_merge_data_pools.merge_single_prompt_data_pools.merged_top_prompt_dataset: grader_model_prompt_optimization.generate_new_prompts.dj_configs.dataset_path

Expand Down Expand Up @@ -53,11 +53,12 @@ pipelines:
type: 'api'
model: 'qwen2.5-32b-instruct'
max_retry_num: 5
build_messages_func: 'build_messages'
build_messages_func: 'build_messages_for_math_qa'
parse_output_func: 'parse_output'
func_kwargs:
system_key: "prompt"
query_key: "question"
response_key: "answer"
# data related
dataset_path: '<replaced_by_the_input>'
export_path: './outputs/auto-prompt-optimization-for-grader-model/infer_results/'
Expand Down
20 changes: 20 additions & 0 deletions data_juicer/core/sandbox/helper_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,23 @@ def parse_output(output: str, item: dict, **kwargs):
A simple implementation.
"""
return output


# Math QA grader
@ALL_FUNCS.register_module("build_messages_for_math_qa")
def build_messages_for_math_qa(item: dict, **kwargs):
"""
Build message for math QA grader.
"""
system_key = kwargs.get("system_key", "system")
query_key = kwargs.get("query_key", "query")
response_key = kwargs.get("response_key", "response")

system_prompt = item.get(system_key, "")
question = item[query_key]
answer = item[response_key]
messages = []
if system_prompt:
messages.append({"role": "system", "content": system_prompt})
messages.append({"role": "user", "content": f"Question: {question}\nAnswer: {answer}"})
return messages
3 changes: 3 additions & 0 deletions data_juicer/ops/filter/flagged_words_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Some code here has been modified from:
# https://huggingface.co/spaces/huggingface/text-data-filtering
#
# The flagged words list comes from https://huggingface.co/spaces/huggingface/text-data-filtering
# and https://github.com/LDNOOBW/List-of-Dirty-Naughty-Obscene-and-Otherwise-Bad-Words
# --------------------------------------------------------

from typing import List
Expand Down