mirror of
https://github.com/open-compass/opencompass.git
synced 2025-05-30 16:03:24 +08:00
fix lint
This commit is contained in:
parent
26adccc20c
commit
862cf61f64
@ -3,6 +3,7 @@ from opencompass.openicl.icl_inferencer import GenInferencer
|
|||||||
from opencompass.openicl.icl_prompt_template import PromptTemplate
|
from opencompass.openicl.icl_prompt_template import PromptTemplate
|
||||||
from opencompass.openicl.icl_retriever import ZeroRetriever
|
from opencompass.openicl.icl_retriever import ZeroRetriever
|
||||||
|
|
||||||
|
|
||||||
ZERO_SHOT_PROMPT = '{q4}'
|
ZERO_SHOT_PROMPT = '{q4}'
|
||||||
|
|
||||||
# Reader configuration
|
# Reader configuration
|
||||||
|
@ -6,6 +6,7 @@ from opencompass.openicl.icl_retriever import ZeroRetriever
|
|||||||
from opencompass.evaluator import GenericLLMEvaluator
|
from opencompass.evaluator import GenericLLMEvaluator
|
||||||
ZERO_SHOT_PROMPT = '{q4}'
|
ZERO_SHOT_PROMPT = '{q4}'
|
||||||
|
|
||||||
|
|
||||||
GRADER_TEMPLATE = """
|
GRADER_TEMPLATE = """
|
||||||
Please as a grading expert, judge whether the final answers given by the candidates below are consistent with the standard answers, that is, whether the candidates answered correctly.
|
Please as a grading expert, judge whether the final answers given by the candidates below are consistent with the standard answers, that is, whether the candidates answered correctly.
|
||||||
|
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
from datasets import Dataset, load_dataset
|
from datasets import load_dataset
|
||||||
|
|
||||||
from opencompass.openicl import BaseEvaluator
|
from opencompass.openicl import BaseEvaluator
|
||||||
from opencompass.registry import LOAD_DATASET, TEXT_POSTPROCESSORS
|
from opencompass.registry import LOAD_DATASET, TEXT_POSTPROCESSORS
|
||||||
from opencompass.utils import get_logger
|
|
||||||
|
|
||||||
from .base import BaseDataset
|
from .base import BaseDataset
|
||||||
|
|
||||||
|
|
||||||
def _parse(item, prompt_mode, discipline):
|
def _parse(item, prompt_mode, discipline):
|
||||||
choices = item['choices']
|
choices = item['choices']
|
||||||
item['q4'] = f'You are an expert in {discipline}.\n' + item['prompt'][
|
|
||||||
'default'] + '\n' + item['question'] + '\n' + '\n'.join([
|
item['q4'] = f'You are an expert in {discipline}.\n'
|
||||||
f'{l}. {t}' for l, t in zip(choices['label'], choices['text'])
|
item['q4'] += item['prompt']['default'] + '\n' + item['question'] + '\n'
|
||||||
]) # noqa: E501, E741, E741
|
label_texts = []
|
||||||
item['start'] = chr(65)
|
for label_meta, text_meta in zip(choices['label'], choices['text']):
|
||||||
item['end'] = chr(65 + len(item.get('choices', {'label': []})['label']) -
|
label_texts.append(f'{label_meta}. {text_meta}')
|
||||||
1)
|
item['q4'] += '\n'.join(label_texts) # noqa: E501, E741, E741
|
||||||
item['prompt_mode'] = prompt_mode
|
item['prompt_mode'] = prompt_mode
|
||||||
return item
|
return item
|
||||||
|
|
||||||
@ -34,10 +33,10 @@ class SciKnowEvalDataset(BaseDataset):
|
|||||||
return s[0].upper() + s[1:]
|
return s[0].upper() + s[1:]
|
||||||
|
|
||||||
subset = kwargs['subset']
|
subset = kwargs['subset']
|
||||||
data_files = {
|
data_files = {}
|
||||||
'test':
|
test_file = f'data/{capitalize_first_letter(subset)}/'
|
||||||
f'data/{capitalize_first_letter(subset)}/sciknoweval_{subset}_test.jsonl'
|
test_file += f'sciknoweval_{subset}_test.jsonl'
|
||||||
}
|
data_files['test'] = test_file
|
||||||
dataset = load_dataset(path, data_files=data_files, split='test')
|
dataset = load_dataset(path, data_files=data_files, split='test')
|
||||||
# dataset = dataset.select(range(20))
|
# dataset = dataset.select(range(20))
|
||||||
if prompt_mode == 'zero-shot':
|
if prompt_mode == 'zero-shot':
|
||||||
|
Loading…
Reference in New Issue
Block a user