tianyang commited on
Commit
b99e47f
·
verified ·
1 Parent(s): b4501fd

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +171 -2
README.md CHANGED
@@ -51,6 +51,175 @@ dataset_info:
51
  download_size: 472994299
52
  dataset_size: 1460769986
53
  ---
54
- # Dataset Card for "repobench_python_v1.1"
55
 
56
- [More Information needed](https://github.com/huggingface/datasets/blob/main/CONTRIBUTING.md#how-to-contribute-to-the-dataset-cards)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  download_size: 472994299
52
  dataset_size: 1460769986
53
  ---
54
+ # RepoBench v1.1 (Python)
55
 
56
+ ## Introduction
57
+
58
+ This dataset presents the **Python** portion of [RepoBench](https://arxiv.org/abs/2306.03091) v1.1 (ICLR 2024). The data encompasses a collection from GitHub, spanning the period from **October 6th to November 31st, 2023**. With a commitment to data integrity, we've implemented a deduplication process based on file content against the Stack v2 dataset (coming soon), aiming to mitigate data leakage and memorization concerns.
59
+
60
+ ## Resources and Links
61
+
62
+ - [Paper](https://arxiv.org/abs/2306.03091)
63
+ - [GitHub](https://github.com/Leolty/repobench)
64
+ - [Dataset Introduction](https://github.com/Leolty/repobench/blob/main/data/README.md)
65
+
66
+ ## FAQs
67
+
68
+ - **Q:** What do the features in the dataset mean?
69
+
70
+ **A:** Imagine you're coding in Python and you want to write the next line of your code. The dataset provides you the following information:
71
+ - `repo_name` (string): the name of the repository
72
+ - `file_path` (string): the path of the current file
73
+ - `context` (list): the cross-file code snippets that might be helpful for writing the next line:
74
+ - `identifier` (string): the identifier of the code snippet
75
+ - `path` (string): the path of the code snippet
76
+ - `snippet` (string): the code snippet
77
+ - `import_statement` (string): the import statement of the current file
78
+ - `cropped_code` (string): the cropped code of the current file (up to previous 120 lines)
79
+ - `all_code` (string): the entire code of the current file (not cropped)
80
+ - `next_line` (string): the next line of the code (this serves as the target)
81
+ - `gold_snippet_index` (int): the index of the gold snippet in the context (which will be used in next line, just for reference, you should not use this for next line prediction)
82
+ - `created_at` (string): the creation time of the repository
83
+ - `level` (string): the level of next line completion, which is measured by the number of tokens for the whole prompt (including all the context, import statement, cropped code and some neccessary separator tokens)
84
+
85
+ - **Q:** How does the level be defined?
86
+
87
+ **A:** The level is determined by the number of tokens for the whole prompt (including all the context, import statement, cropped code and some neccessary separator tokens). The token number is calculated by the tokenizer of GPT-4 by using [tiktoken](https://github.com/openai/tiktoken). The following table shows the level definition:
88
+
89
+ | Level | Prompt Length (Number of Tokens) |
90
+ |-------|------------------------|
91
+ | 2k | 640 - 1,600 |
92
+ | 4k | 1,600 - 3,600 |
93
+ | 8k | 3,600 - 7,200 |
94
+ | 12k | 7,200 - 10,800 |
95
+ | 16k | 10,800 - 14,400 |
96
+ | 24k | 14,400 - 21,600 |
97
+ | 32k | 21,600 - 28,800 |
98
+ | 64k | 28,800 - 57,600 |
99
+ | 128k | 57,600 - 100,000 |
100
+
101
+ - **Q:** What does the different splits mean?
102
+
103
+ **A:** The dataset is split into three parts:
104
+ - `cross_file_first`: the next line of code utilizes content from a cross-file code snippet and it is its first usage within current file.
105
+ - `cross_file_random`: the next line of code utilizes content from a cross-file code snippet and it is NOT its first usage within current file.
106
+ - `in_file`: the next line of code does not utilize content from a cross-file code snippet.
107
+
108
+ - **Q:** How to construct the prompt for next line prediction?
109
+
110
+ **A:** We hereby provide the official implementation for constructing prompts. Please note that the methods described below are not necessarily the optimal way of construction. Reordering, retrieval argumentation, or employing different cropping/construction techniques could potentially lead to varying degrees of improvement. Ensure that your model evaluations are conducted in a fair manner.
111
+
112
+ ```python
113
+ import re
114
+
115
+ def construct_prompt(
116
+ data: dict,
117
+ language: str = "python",
118
+ tokenizer= None,
119
+ max_token_nums: int = 15800
120
+ ) -> str:
121
+ """
122
+ Construct the prompt for next line prediction.
123
+
124
+ :param data: data point from the dataset
125
+ :param language: the language of the code
126
+ :param tokenizer: the tokenizer of the evaluation model
127
+ :param max_token_nums: the maximum number of tokens constraint for the prompt
128
+
129
+ :return: the constructed prompt
130
+ """
131
+
132
+ # comment symbol for different languages
133
+ comment_symbol = "#" if language == "python" else "//"
134
+
135
+ # construct the cross-file prompt and in-file prompt separately
136
+ # cross-file prompt
137
+ cross_file_prompt = f"{comment_symbol} Repo Name: {data['repo_name']}\n"
138
+
139
+ for snippet in data['context']:
140
+ cross_file_prompt += f"{comment_symbol} Path: {snippet['path']}\n{snippet['snippet']}" + "\n\n"
141
+
142
+ # in-file prompt
143
+ in_file_prompt = f"{comment_symbol} Path: {data['file_path']}\n{data['import_statement']}\n{data['cropped_code']}\n"
144
+
145
+ # if we assign the tokenizer and the max_token_nums, we will truncate the cross-file prompt to meet the constraint
146
+ if tokenizer is not None and max_token_nums is not None:
147
+
148
+ cross_file_prompt_token_nums = len(tokenizer.encode(cross_file_prompt))
149
+ in_file_prompt_token_nums = len(tokenizer.encode(in_file_prompt))
150
+
151
+ exceed_token_nums = cross_file_prompt_token_nums + in_file_prompt_token_nums - max_token_nums
152
+
153
+ if exceed_token_nums > 0:
154
+ # split the cross-file prompt into lines
155
+ cross_file_prompt_lines = cross_file_prompt.split("\n")
156
+ # drop lines from end until the extra token number is less than 0
157
+ for i in range(len(repo_prompt_lines)-1, -1, -1):
158
+ extra_token_num -= len(tokenizer.encode(cross_file_prompt_lines[i]))
159
+ if extra_token_num < 0:
160
+ break
161
+
162
+ # join the lines back
163
+ cross_file_prompt = "\n".join(cross_file_prompt_lines[:i+1]) + "\n\n"
164
+
165
+ # combine the cross-file prompt and in-file prompt
166
+ prompt = cross_file_prompt + in_file_prompt
167
+
168
+ # normalize some empty lines
169
+ prompt = re.sub(r'\n{4,}', '\n\n', prompt)
170
+
171
+ return prompt
172
+ ```
173
+
174
+ - **Q:** How to load the dataset?
175
+
176
+ **A:** You can simply use the following code to load the dataset:
177
+
178
+ ```python
179
+ from datasets import load_dataset
180
+
181
+ dataset = load_dataset("tianyang/repobench_python_v1.1")
182
+ ```
183
+
184
+ To construct the prompt for next line prediction, you can refer to the official implementation provided in the previous question and use the `construct_prompt` function to construct the prompt, for example:
185
+
186
+ ```python
187
+ from transformers import AutoTokenizer, AutoModelForCausalLM
188
+
189
+ tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/deepseek-coder-1.3b-base")
190
+ model = AutoModelForCausalLM.from_pretrained("deepseek-ai/deepseek-coder-1.3b-base")
191
+
192
+ prompt = construct_prompt(dataset['cross_file_first'][0], tokenizer=tokenizer, max_token_nums=15800)
193
+ ```
194
+
195
+ - **Q:** How often will the dataset be updated?
196
+
197
+ **A:** We plan to update the dataset every three months, but there might be slight delays considering the time required for data crawling and our own schedules. If you require updated data, please feel free to contact us, and we can coordinate the timing and expedite the process.
198
+
199
+ - **Q:** What models should I use to evaluate the dataset?
200
+
201
+ **A:** RepoBench is designed to evaluate base models, not those that have been instruction fine-tuned. Please use base models for evaluation.
202
+
203
+ - **Q:** I am training a new model but the knowledge cutoff date is after the dataset's. Can you provide me with the latest data?
204
+
205
+ **A:** Sure! We are happy to provide you with the latest data (even customized data with specific requirements). Please feel free to contact us.
206
+
207
+ - **Q:** Can I opt-out?
208
+
209
+ **A:** Yes, you can opt-out your repository from the dataset. Please check [Am I in RepoBench?](https://huggingface.co/spaces/tianyang/in-the-repobench), we will upload the raw data of the repository information we crawled at least 15 days before the dataset creation and release. We will respect your decision and remove your repository from the dataset if you opt-out.
210
+
211
+ ## Citation
212
+
213
+ If you find RepoBench useful in your research, please consider citing the paper using the following BibTeX entry:
214
+
215
+ ```bibtex
216
+ @misc{liu2023repobench,
217
+ title={RepoBench: Benchmarking Repository-Level Code Auto-Completion Systems},
218
+ author={Tianyang Liu and Canwen Xu and Julian McAuley},
219
+ year={2024},
220
+ url={https://arxiv.org/abs/2306.03091},
221
+ booktitle={International Conference on Learning Representations}
222
+ }
223
+ ```
224
+
225
+ Your interest and contributions to RepoBench are immensely valued. Happy coding! 🚀