zkcpku commited on
Commit
eb131c2
1 Parent(s): 6f53234

Upload 3 files

Browse files
Files changed (3) hide show
  1. codesymbols_dataset.jsonl +0 -0
  2. dataset_details.md +109 -0
  3. eval.py +59 -0
codesymbols_dataset.jsonl ADDED
The diff for this file is too large to render. See raw diff
 
dataset_details.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # HiRoPE: Length Extrapolation for Code Models
2
+
3
+ ## Code Symbol Understanding
4
+
5
+ Note that we use the public repo to construct the evaluation dataset.
6
+
7
+ > ddbourgin/numpy-ml
8
+ >
9
+ > gradio-app/gradio
10
+ >
11
+ > huggingface/accelerate
12
+ >
13
+ > huggingface/diffusers
14
+ >
15
+ > huggingface/optimum
16
+ >
17
+ > huggingface/peft
18
+ >
19
+ > huggingface/transformers
20
+ >
21
+ > langchain-ai/langchain/
22
+ >
23
+ > numpy/numpy
24
+ >
25
+ > tensorflow/tensorflow
26
+
27
+ **During the experiment we fully complied with the license requirements of these projects.**
28
+
29
+ Before conducting experiments, please confirm the license requirements in each project and mark them appropriately. We respect the efforts of every developer. If there is any possible violation, please contact us in time!
30
+
31
+
32
+
33
+
34
+
35
+ ## Metadata
36
+
37
+ We list the file name in codesymbols_dataset.jsonl
38
+
39
+ Here we list the file paths of each metadata. (The file path is simplified to only show the last two levels).
40
+
41
+
42
+
43
+ | peft-main | | | |
44
+ | ----------------- | ---------------------------------------------------------- | ---- | ---- |
45
+ | | .../stable_diffusion/train_dreambooth.py | | |
46
+ | langchain-master | | | |
47
+ | | .../llms/openai.py | | |
48
+ | | .../agents/agent.py | | |
49
+ | numpy-main | | | |
50
+ | | .../tests/test_defchararray.py | | |
51
+ | | .../fcompiler/__init__.py | | |
52
+ | | .../f2py/capi_maps.py | | |
53
+ | | .../lib/_index_tricks_impl.py | | |
54
+ | | .../tests/test_smoke.py | | |
55
+ | | .../tools/refguide_check.py | | |
56
+ | numpyml-master | | | |
57
+ | | .../preprocessing/nlp.py | | |
58
+ | | .../preprocessing/nlp.py | | |
59
+ | gradio-main | | | |
60
+ | | .../gradio/helpers.py | | |
61
+ | tensorflow-master | | | |
62
+ | | .../python/convert.py | | |
63
+ | | .../ops/data_service_ops.py | | |
64
+ | | .../cli/debugger_cli_common.py | | |
65
+ | | .../cli/debugger_cli_common_test.py | | |
66
+ | | .../lib/debug_events_reader.py | | |
67
+ | | .../wrappers/framework.py | | |
68
+ | | .../eager/forwardprop_test.py | | |
69
+ | | .../framework/func_graph.py | | |
70
+ | | .../framework/type_spec_test.py | | |
71
+ | | .../initializers/initializers_v2.py | | |
72
+ | | .../layers/merge.py | | |
73
+ | | .../optimizer_v2/learning_rate_schedule.py | | |
74
+ | | .../ops/init_ops_v2.py | | |
75
+ | | .../ops/stateful_random_ops.py | | |
76
+ | | .../trackable/data_structures.py | | |
77
+ | | .../util/deprecation_test.py | | |
78
+ | | .../compatibility/ast_edits.py | | |
79
+ | accelerate-main | | | |
80
+ | | .../commands/launch.py | | |
81
+ | | .../accelerate/data_loader.py | | |
82
+ | | .../accelerate/tracking.py | | |
83
+ | | .../tests/test_big_modeling.py | | |
84
+ | diffusers-main | | | |
85
+ | | .../community/stable_diffusion_tensorrt_img2img.py | | |
86
+ | | .../community/stable_diffusion_tensorrt_inpaint.py | | |
87
+ | | .../community/stable_diffusion_tensorrt_txt2img.py | | |
88
+ | | .../text_to_video_synthesis/pipeline_text_to_video_zero.py | | |
89
+ | transformers-main | | | |
90
+ | | .../bertabs/modeling_bertabs.py | | |
91
+ | | .../emmental/modeling_bert_masked.py | | |
92
+ | | .../benchmark/benchmark_utils.py | | |
93
+ | | .../ctrl/modeling_tf_ctrl.py | | |
94
+ | | .../mctct/modeling_mctct.py | | |
95
+ | | .../ernie_m/modeling_ernie_m.py | | |
96
+ | | .../openfold_utils/rigid_utils.py | | |
97
+ | | .../gptj/modeling_gptj.py | | |
98
+ | | .../gptj/modeling_tf_gptj.py | | |
99
+ | | .../graphormer/modeling_graphormer.py | | |
100
+ | | .../lilt/modeling_lilt.py | | |
101
+ | | .../persimmon/modeling_persimmon.py | | |
102
+ | | .../rwkv/modeling_rwkv.py | | |
103
+ | | .../timesformer/modeling_timesformer.py | | |
104
+ | | .../vit/modeling_vit.py | | |
105
+ | | .../xglm/modeling_tf_xglm.py | | |
106
+ | | .../blip_2/test_modeling_blip_2.py | | |
107
+ | | .../bnb/test_mixed_int8.py | | |
108
+ | optimum-main | | | |
109
+ | | .../onnxruntime/configuration.py | | |
eval.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ # inp_path = "/Users/zkcpku/Documents/seke/mywork/分块ROPE/openai_src/gen_out/openai_default_codesymbols_outputless100.jsonl.renew"
3
+ # inp_path is the parameter for script
4
+ import sys
5
+ # /Users/zkcpku/Documents/seke/pretrain/envAnalysis/
6
+ # python extract_funcs.py
7
+ # test_renew_dataset
8
+ def eval_codesymbols(inp_path):
9
+ with open(inp_path,'r') as f:
10
+ lines = f.readlines()
11
+ lines = [json.loads(x) for x in lines]
12
+ print("len(lines):",len(lines))
13
+
14
+ rst = {}
15
+ for i,l in enumerate(lines):
16
+ this_rst = {"true": [], "false": [], "acc": 0.0}
17
+ ground_output = l['output']
18
+ preds = l["out_str"]
19
+ metadata = l['metadata']
20
+ symbol_dict = metadata['symbol_dict']
21
+ symbol2location = {e['symbol']: e['location'] for e in symbol_dict}
22
+ for e in ground_output:
23
+ if e in preds:
24
+ this_rst["true"].append((e, symbol2location[e]))
25
+ else:
26
+ this_rst["false"].append((e, symbol2location[e]))
27
+ acc = len(this_rst["true"]) / (len(this_rst["true"]) + len(this_rst["false"]))
28
+ this_rst["acc"] = acc
29
+ rst[i] = this_rst
30
+ total_acc = sum([rst[i]["acc"] for i in rst]) / len(rst)
31
+ print(f"total acc: {total_acc}")
32
+ all_true = [rst[i]['true'] for i in range(len(rst))]
33
+ all_true = [e for ee in all_true for e in ee]
34
+ all_true_location = [e[1] for e in all_true]
35
+
36
+ all_false = [rst[i]['false'] for i in range(len(rst))]
37
+ all_false = [e for ee in all_false for e in ee]
38
+ all_false_location = [e[1] for e in all_false]
39
+ # print([len(rst[i]['false']) for i in range(len(rst))])
40
+ # import ipdb; ipdb.set_trace()
41
+
42
+ print(max(all_true_location), min(all_true_location), max(all_false_location), min(all_false_location))
43
+
44
+ # each 1000 is a range, count acc
45
+ # 0-1000 1000-2000 2000-3000 3000-4000 4000-5000 5000-6000 6000-7000 7000-8000 8000-9000 9000-10000
46
+ for i in range(20):
47
+ this_true = [e for e in all_true_location if e >= i*1000 and e < (i+1)*1000]
48
+ this_false = [e for e in all_false_location if e >= i*1000 and e < (i+1)*1000]
49
+ if len(this_true) + len(this_false) == 0:
50
+ this_acc = 0
51
+ else:
52
+ this_acc = len(this_true) / (len(this_true) + len(this_false))
53
+ print(f"range {i*1000}-{(i+1)*1000} acc: {this_acc} true: {len(this_true)} false: {len(this_false)}")
54
+
55
+
56
+ if __name__ == "__main__":
57
+ args = sys.argv
58
+ inp_path = args[1]
59
+ eval_codesymbols(inp_path)