--- license: apache-2.0 task_categories: - text-classification pretty_name: CuBERT ETH Py150 Benchmarks arxiv: 2001.00059 dataset_info: - config_name: default features: - name: function dtype: string - name: docstring dtype: string - name: label dtype: string - name: info dtype: string splits: - name: train num_bytes: 261700491 num_examples: 340846 - name: dev num_bytes: 28498757 num_examples: 37592 - name: test num_bytes: 141660242 num_examples: 186698 download_size: 121724722 dataset_size: 431859490 - config_name: exception_datasets features: - name: function dtype: string - name: label dtype: string - name: info dtype: string splits: - name: train num_bytes: 25423003 num_examples: 18480 - name: dev num_bytes: 2845822 num_examples: 2088 - name: test num_bytes: 14064500 num_examples: 10348 download_size: 16935273 dataset_size: 42333325 - config_name: function_docstring_datasets features: - name: function dtype: string - name: docstring dtype: string - name: label dtype: string - name: info dtype: string splits: - name: train num_bytes: 261700491 num_examples: 340846 - name: dev num_bytes: 28498757 num_examples: 37592 - name: test num_bytes: 141660242 num_examples: 186698 download_size: 121724722 dataset_size: 431859490 - config_name: swapped_operands_datasets features: - name: function dtype: string - name: label dtype: string - name: info dtype: string splits: - name: train num_bytes: 271097336 num_examples: 236246 - name: dev num_bytes: 29986397 num_examples: 26118 - name: test num_bytes: 148544957 num_examples: 130972 download_size: 105243573 dataset_size: 449628690 configs: - config_name: default data_files: - split: train path: data/train-* - split: dev path: data/dev-* - split: test path: data/test-* - config_name: exception_datasets data_files: - split: train path: exception_datasets/train-* - split: dev path: exception_datasets/dev-* - split: test path: exception_datasets/test-* - config_name: function_docstring_datasets data_files: - split: train path: function_docstring_datasets/train-* - split: dev path: function_docstring_datasets/dev-* - split: test path: function_docstring_datasets/test-* - config_name: swapped_operands_datasets data_files: - split: train path: swapped_operands_datasets/train-* - split: dev path: swapped_operands_datasets/dev-* - split: test path: swapped_operands_datasets/test-* tags: - code --- # CuBERT ETH150 Open Benchmarks This is an unofficial HuggingFace upload of the [CuBERT ETH150 Open Benchmarks](https://github.com/google-research/google-research/tree/master/cubert). This dataset was released along with [Learning and Evaluating Contextual Embedding of Source Code](https://arxiv.org/abs/2001.00059). --- ## Benchmarks and Fine-Tuned Models Here we describe the 6 Python benchmarks we created. All 6 benchmarks were derived from [ETH Py150 Open](https://github.com/google-research-datasets/eth_py150_open). All examples are stored as sharded text files. Each text line corresponds to a separate example encoded as a JSON object. For each dataset, we release separate training/validation/testing splits along the same boundaries that ETH Py150 Open splits its files to the corresponding splits. The fine-tuned models are the checkpoints of each model with the highest validation accuracy. 1. **Function-docstring classification**. Combinations of functions with their correct or incorrect documentation string, used to train a classifier that can tell which pairs go together. The JSON fields are: * `function`: string, the source code of a function as text * `docstring`: string, the documentation string for that function. Note that the string is unquoted. To be able to properly tokenize it with the CuBERT tokenizers, you have to wrap it in quotes first. For example, in Python, use `string_to_tokenize = f'"""{docstring}"""'`. * `label`: string, one of (“Incorrect”, “Correct”), the label of the example. * `info`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, the function name and, for “Incorrect” examples, the function whose docstring was substituted. 1. **Exception classification**. Combinations of functions where one exception type has been masked, along with a label indicating the masked exception type. The JSON fields are: * `function`: string, the source code of a function as text, in which one exception type has been replaced with the special token “__HOLE__” * `label`: string, one of (`ValueError`, `KeyError`, `AttributeError`, `TypeError`, `OSError`, `IOError`, `ImportError`, `IndexError`, `DoesNotExist`, `KeyboardInterrupt`, `StopIteration`, `AssertionError`, `SystemExit`, `RuntimeError`, `HTTPError`, `UnicodeDecodeError`, `NotImplementedError`, `ValidationError`, `ObjectDoesNotExist`, `NameError`, `None`), the masked exception type. Note that `None` never occurs in the data and will be removed in a future release. * `info`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, and the fully-qualified function name. 1. **Variable-misuse classification**. Combinations of functions where one use of a variable may have been replaced with another variable defined in the same context, along with a label indicating if this bug-injection has occurred. The JSON fields are: * `function`: string, the source code of a function as text. * `label`: string, one of (“Correct”, “Variable misuse”) indicating if this is a buggy or bug-free example. * `info`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, the function, and whether the example is bugfree (marked “original”) or the variable substitution that has occurred (e.g., “correct_variable” → “incorrect_variable”). 1. **Swapped-operand classification**. Combinations of functions where one use binary operator’s arguments have been swapped, to create a buggy example, or left undisturbed, along with a label indicating if this bug-injection has occurred. The JSON fields are: * `function`: string, the source code of a function as text. * `label`: string, one of (“Correct”, “Swapped operands”) indicating if this is a buggy or bug-free example. * `info`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, the function, and whether the example is bugfree (marked “original”) or the operand swap has occurred (e.g., “swapped operands of `not in`”). 1. **Wrong-binary-operator classification**. Combinations of functions where one binary operator has been swapped with another, to create a buggy example, or left undisturbed, along with a label indicating if this bug-injection has occurred. The JSON fields are: * `function`: string, the source code of a function as text. * `label`: string, one of (“Correct”, “Wrong binary operator”) indicating if this is a buggy or bug-free example. * `info`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, the function, and whether the example is bugfree (marked “original”) or the operator replacement has occurred (e.g., “`==`-> `!=`”). 1. **Variable-misuse localization and repair**. Combinations of functions where one use of a variable may have been replaced with another variable defined in the same context, along with information that can be used to localize and repair the bug, as well as the location of the bug if such a bug exists. The JSON fields are: * `function`: a list of strings, the source code of a function, tokenized with the vocabulary from item b. Note that, unlike other task datasets, this dataset gives a tokenized function, rather than the code as a single string. * `target_mask`: a list of integers (0 or 1). If the integer at some position is 1, then the token at the corresponding position of the function token list is a correct repair for the introduced bug. If a variable has been split into multiple tokens, only the first subtoken is marked in this mask. If the example is bug-free, all integers are 0. * `error_location_mask`: a list of integers (0 or 1). If the integer at some position is 1, then there is a variable-misuse bug at the corresponding location of the tokenized function. In a bug-free example, the first integer is 1. There is exactly one integer set to 1 for all examples. If a variable has been split into multiple tokens, only the first subtoken is marked in this mask. * `candidate_mask`: a list of integers (0 or 1). If the integer at some position is 1, then the variable starting at that position in the tokenized function is a candidate to consider when repairing a bug. Candidates are all variables defined in the function parameters or via variable declarations in the function. If a variable has been split into multiple tokens, only the first subtoken is marked in this mask, for each candidate. * `provenance`: string, an unformatted description of how the example was constructed, including the source dataset (always “ETHPy150Open”), the repository and filepath, the function, and whether the example is bugfree (marked “original”) or the buggy/repair token positions and variables (e.g., “16/18 `kwargs` → `self`”). 16 is the position of the introduced error, 18 is the location of the repair. ## Citation ```bibtex @inproceedings{cubert, author = {Aditya Kanade and Petros Maniatis and Gogul Balakrishnan and Kensen Shi}, title = {Learning and evaluating contextual embedding of source code}, booktitle = {Proceedings of the 37th International Conference on Machine Learning, {ICML} 2020, 12-18 July 2020}, series = {Proceedings of Machine Learning Research}, publisher = {{PMLR}}, year = {2020}, } ```