数据集:
CodeQueries 是一个用于评估神经网络处理代码语义查询能力的数据集。给定一个查询和代码,模型需要识别出代码中与查询相关的答案和支持事实片段。这是对代码进行抽取式问答,针对具有大范围(整个文件)和复杂性(包括单跳和多跳推理)的问题。
代码抽取式问答,代码的语义理解。
数据集包含来自 Python 文件的代码上下文。
可以直接使用huggingface的数据集包来使用该数据集。您可以使用以下两行代码加载并迭代处理该数据集的五个预设设置:
import datasets
# in addition to `twostep`, the other supported settings are <ideal/file_ideal/prefix>.
ds = datasets.load_dataset("thepurpleowl/codequeries", "twostep", split=datasets.Split.TEST)
print(next(iter(ds)))
#OUTPUT:
{'query_name': 'Unused import',
'code_file_path': 'rcbops/glance-buildpackage/glance/tests/unit/test_db.py',
'context_block': {'content': '# vim: tabstop=4 shiftwidth=4 softtabstop=4\n\n# Copyright 2010-2011 OpenStack, LLC\ ...',
'metadata': 'root',
'header': "['module', '___EOS___']",
'index': 0},
'answer_spans': [{'span': 'from glance.common import context',
'start_line': 19,
'start_column': 0,
'end_line': 19,
'end_column': 33}
],
'supporting_fact_spans': [],
'example_type': 1,
'single_hop': False,
'subtokenized_input_sequence': ['[CLS]_', 'Un', 'used_', 'import_', '[SEP]_', 'module_', '\\u\\u\\uEOS\\u\\u\\u_', '#', ' ', 'vim', ':', ...],
'label_sequence': [4, 4, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ...],
'relevance_label': 1
}
有关预设设置中数据拆分的详细信息可在论文中找到。
一般而言,所有预设设置中的数据拆分都包含以下字段的示例:
- query_name (query name to uniquely identify the query) - code_file_path (relative source file path w.r.t. ETH Py150 corpus) - context_blocks (code blocks as context with metadata) [`prefix` setting doesn't have this field and `twostep` has `context_block`] - answer_spans (answer spans with metadata) - supporting_fact_spans (supporting-fact spans with metadata) - example_type (1(positive)) or 0(negative)) example type) - single_hop (True or False - for query type) - subtokenized_input_sequence (example subtokens) [`prefix` setting has the corresponding token ids] - label_sequence (example subtoken labels) - relevance_label (0 (not relevant) or 1 (relevant) - relevance label of a block) [only `twostep` setting has this field]
数据集是使用 ETH Py150 Open dataset 作为代码上下文来源创建的。为了获取 ETH Py150 开放语料库文件中的语义查询和相应的答案/支持事实片段,使用了 CodeQL。
用于准备 CodeQueries 的源代码存储库基于 ETH Py150 Open dataset ,并且可根据各自的许可证进行重新分发。ETH Py150开放数据集的Huggingface数据集可在 here 找到。由我们准备和提供的 CodeQueries 标注在 Apache-2.0 许可下发布。