OpenCompass/opencompass/datasets/PMMEval/mifeval_utils/combination_checker.py
wanyu2018umac 90efcf2216
[Feature] Add P-MMEval (#1714)
* Update with PMMEval

* Update

* Update __init__.py

* Fix Bugs

* Delete .pre-commit-config.yaml

* Pull merge

---------

Co-authored-by: liushz <qq1791167085@163.com>
2024-11-27 21:26:18 +08:00

33 lines
985 B
Python
Executable File

def repeat_prompt_checker(input_string: str, prompt_to_repeat: str, **kwargs):
if input_string.strip().lower().startswith(
prompt_to_repeat.strip().lower()):
return True
return False
def two_responses_checker(input_string: str, **kwargs):
valid_responses = list()
responses = input_string.split('******')
for index, response in enumerate(responses):
if not response.strip():
if index != 0 and index != len(responses) - 1:
return False
else:
valid_responses.append(response)
return (len(valid_responses) == 2
and valid_responses[0].strip() != valid_responses[1].strip())
combination_checker = {
'repeat_prompt': {
'function': repeat_prompt_checker,
'required_lang_code': False,
'num_of_params': 2
},
'two_responses': {
'function': two_responses_checker,
'required_lang_code': False,
'num_of_params': 1
}
}