RawthiL commited on
Commit
4b062d7
·
1 Parent(s): bc36b7c

updated lm-eval task

Browse files
lm-eval-task/_ds1000_base.yml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ dataset_path: PNYX/ds1000_pnyx
2
+ unsafe_code: true
3
+ output_type: generate_until
4
+ test_split: test
5
+ doc_to_text: "{{user_chat_prompt}}"
6
+ doc_to_target: "{{test_code}}"
7
+ process_results: !function utils.pass_at_k_process
8
+ metric_list:
9
+ - metric: pass@1
10
+ aggregation: mean
11
+ higher_is_better: true
12
+ generation_kwargs:
13
+ until: []
14
+ max_gen_toks: 30000
15
+ do_sample: false
16
+ repeats: 1
17
+ num_fewshot: 0
18
+ filter_list:
19
+ - name: "create_test"
20
+ filter:
21
+ - function: "custom"
22
+ filter_fn: !function utils.build_predictions_chat_ds1000
23
+ metadata:
24
+ version: 1.0
lm-eval-task/numpy_chat.yaml CHANGED
@@ -1,26 +1,5 @@
 
1
  task: ds1000_numpy_sandbox_chat
2
- dataset_path: PNYX/ds1000_pnyx
3
  dataset_name: Numpy
4
- unsafe_code: true
5
- output_type: generate_until
6
- test_split: test
7
- doc_to_text: "{{user_chat_prompt}}"
8
- doc_to_target: "{{test_code}}"
9
- metric_list:
10
- - metric: !function utils.pass_at_k
11
- aggregation: mean
12
- higher_is_better: true
13
- k: [1]
14
- generation_kwargs:
15
- until: []
16
- max_gen_toks: 8000
17
- do_sample: false
18
- repeats: 1
19
- num_fewshot: 0
20
- filter_list:
21
- - name: "create_test"
22
- filter:
23
- - function: "custom"
24
- filter_fn: !function utils.build_predictions_chat_ds1000
25
  metadata:
26
  version: 1.0
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_numpy_sandbox_chat
 
3
  dataset_name: Numpy
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  metadata:
5
  version: 1.0
lm-eval-task/pandas_chat.yaml CHANGED
@@ -1,3 +1,5 @@
1
- include: numpy_chat.yaml
2
  task: ds1000_pandas_sandbox_chat
3
- dataset_name: Pandas
 
 
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_pandas_sandbox_chat
3
+ dataset_name: Pandas
4
+ metadata:
5
+ version: 1.0
lm-eval-task/pytorch_chat.yaml CHANGED
@@ -1,3 +1,5 @@
1
- include: numpy_chat.yaml
2
  task: ds1000_pytorch_sandbox_chat
3
- dataset_name: Pytorch
 
 
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_pytorch_sandbox_chat
3
+ dataset_name: Pytorch
4
+ metadata:
5
+ version: 1.0
lm-eval-task/scipy_chat.yaml CHANGED
@@ -1,3 +1,5 @@
1
- include: numpy_chat.yaml
2
  task: ds1000_scipy_sandbox_chat
3
- dataset_name: Scipy
 
 
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_scipy_sandbox_chat
3
+ dataset_name: Scipy
4
+ metadata:
5
+ version: 1.0
lm-eval-task/sklearn_chat.yaml CHANGED
@@ -1,3 +1,5 @@
1
- include: numpy_chat.yaml
2
  task: ds1000_sklearn_sandbox_chat
3
- dataset_name: Sklearn
 
 
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_sklearn_sandbox_chat
3
+ dataset_name: Sklearn
4
+ metadata:
5
+ version: 1.0
lm-eval-task/tensorflow_chat.yaml CHANGED
@@ -1,3 +1,5 @@
1
- include: numpy_chat.yaml
2
  task: ds1000_tensorflow_sandbox_chat
3
- dataset_name: Tensorflow
 
 
 
1
+ include: _ds1000_base.yml
2
  task: ds1000_tensorflow_sandbox_chat
3
+ dataset_name: Tensorflow
4
+ metadata:
5
+ version: 1.0
lm-eval-task/utils.py CHANGED
@@ -11,18 +11,28 @@ except Exception as e:
11
  raise e
12
 
13
 
14
- def pass_at_k(references: list[str], predictions: list[list[str]], k: list[int] = None):
 
15
  global compute_
16
- assert k is not None
17
- if isinstance(k, int):
18
- k = [k]
 
 
 
 
 
 
 
 
19
  res = compute_.compute(
20
- references=references,
21
- predictions=predictions,
22
- k=k,
23
  )
24
- return res[0]
25
 
 
26
 
27
  def build_predictions_chat_ds1000(
28
  resps: list[list[str]], docs: list[dict]
 
11
  raise e
12
 
13
 
14
+
15
+ def pass_at_k_process(doc, results):
16
  global compute_
17
+
18
+ result = {"pass@1": 0}
19
+
20
+ # We support a single prediction currently
21
+ prediction = results[0][0]
22
+ if prediction.strip() == "" or prediction is None:
23
+ return result
24
+
25
+ assert doc["test_code"] is not None
26
+
27
+ # Compute
28
  res = compute_.compute(
29
+ references=[doc["test_code"]],
30
+ predictions=[[prediction]],
31
+ k=[1],
32
  )
33
+ result["pass@1"] = res[0]['pass@1']
34
 
35
+ return result
36
 
37
  def build_predictions_chat_ds1000(
38
  resps: list[list[str]], docs: list[dict]