humanevalx_gen_0af626.py 2.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import GenInferencer
from opencompass.datasets import HumanevalXDataset, HumanevalXEvaluator

humanevalx_reader_cfg = dict(
    input_columns=['prompt'], output_column='task_id', train_split='test')

# This prompt is used for WizardLMCode series
# You can use 620cfa for basic generation
humanevalx_infer_cfg = {
    lang: dict(
        prompt_template=dict(
            type=PromptTemplate,
            template=dict(round=[
                dict(
                    role='HUMAN',
                    prompt=
                    f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.


### Instruction:
Create a {lang} script for this problem:
{{prompt}}

### Response:"""),
            ])),
        retriever=dict(type=ZeroRetriever),
        inferencer=dict(type=GenInferencer, max_out_len=1024))
    for lang in ['python', 'cpp', 'go', 'java', 'js']
}

humanevalx_eval_cfg_dict = {
    lang: dict(
        evaluator=dict(
36
            type=HumanevalXEvaluator,
37
38
            language=lang,
            ip_address=
39
            'localhost',  # replace to your code_eval_server ip_address, port
40
41
            port=5001
        ),  # refer to https://opencompass.readthedocs.io/en/latest/advanced_guides/code_eval_service.html to launch a server
42
43
44
45
46
        pred_role='BOT')
    for lang in ['python', 'cpp', 'go', 'java', 'js'
                 ]  # do not support rust now
}

47
48
49
# Please download the needed `xx.jsonl.gz` from
# https://github.com/THUDM/CodeGeeX2/tree/main/benchmark/humanevalx
# and move them into `data/humanevalx/` folder
50
51
52
53
54
humanevalx_datasets = [
    dict(
        type=HumanevalXDataset,
        abbr=f'humanevalx-{lang}',
        language=lang,
55
        path='./data/humanevalx',
56
57
58
59
        reader_cfg=humanevalx_reader_cfg,
        infer_cfg=humanevalx_infer_cfg[lang],
        eval_cfg=humanevalx_eval_cfg_dict[lang])
    for lang in ['python', 'cpp', 'go', 'java', 'js']
60
]