"megatron/legacy/model/transformer.py" did not exist on "f47aa770fbdfa16c5155ccc0fd930333845b875c"
ds1000_gen_5c4bec.py 2.29 KB
Newer Older
Hubert's avatar
Hubert committed
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
36
37
38
39
40
41
from opencompass.openicl.icl_prompt_template import PromptTemplate
from opencompass.openicl.icl_retriever import ZeroRetriever
from opencompass.openicl.icl_inferencer import AgentInferencer
from opencompass.datasets import DS1000Dataset_Interperter, DS1000InterpreterEvaluator

ds1000_example = """
In the following task, you should generate code with one assertion to testify the correctness of your code.

Example:

<HUMAN>Problem:
How do I get the dimensions of an array? For instance, this is (2, 2):
a = np.array([[1,2],[3,4]])
<ASSISTANT>{thought} In Python, Numpy provides a method called `shape` which helps to get the dimensions of an array.
{action} PythonInterpreter
{action_input}
```python
import numpy as np
def solution(x):
    # Convert to np.ndarray
    x = np.array(x)
    # Getting the dimensions of the array
    dimensions = x.shape
    return dimensions
assert solution([[1,2],[3,4]]) == (2, 2)
```
<SYSTEM>{response}True
<ASSISTANT> {thought} By running this code, you can get the dimensions of an array.
{finish}
```python
import numpy as np
def solution(x):
    # Convert to np.ndarray
    x = np.array(x)
    # Getting the dimensions of the array
    dimensions = x.shape
    return dimensions
```
"""

ds1000_reader_cfg = dict(
42
43
44
45
    input_columns=['prompt'],
    output_column='test_column',
    train_split='test',
    test_split='test',
Hubert's avatar
Hubert committed
46
47
48
49
50
51
52
53
54
55
56
57
58
)

ds1000_infer_cfg = dict(
    prompt_template=dict(
        type=PromptTemplate,
        template="""{prompt}""",
    ),
    retriever=dict(type=ZeroRetriever),
    inferencer=dict(type=AgentInferencer, example=ds1000_example),
)

ds1000_eval_cfg = dict(
    evaluator=dict(type=DS1000InterpreterEvaluator),
59
    pred_role='BOT',
Hubert's avatar
Hubert committed
60
61
62
63
64
65
66
67
)

# The DS-1000 dataset can be downloaded from
# https://github.com/HKUNLP/DS-1000/blob/main/ds1000_data.zip

# Matplotlib cannot fit this setting
ds1000_datasets = [
    dict(
68
        abbr=f'ds1000_{lib}',
Hubert's avatar
Hubert committed
69
        type=DS1000Dataset_Interperter,  # bustm share the same format with AFQMC
70
71
        path='./data/ds1000_data/',
        libs=f'{lib}',
Hubert's avatar
Hubert committed
72
73
74
75
76
        reader_cfg=ds1000_reader_cfg,
        infer_cfg=ds1000_infer_cfg,
        eval_cfg=ds1000_eval_cfg,
    )
    for lib in [
77
78
        'Pandas',
        'Numpy',
Hubert's avatar
Hubert committed
79
        # 'Tensorflow',  # error using tensorflow, skipped temporarily
80
81
82
        'Scipy',
        'Sklearn',
        'Pytorch',
Hubert's avatar
Hubert committed
83
84
    ]
]