变压器架构已成功用于学习源代码表示。图形表示像抽象语法树(AST)和源代码序列之间的融合使得使用电流接近计算地难以用于大输入序列长度。源代码可以有需要更大序列长度的远程依赖性,以有效地模拟模型。电流方法在序列长度方面具有计算和内存成本的二次生长。在实际情况下使用这些模型很难。在这项工作中,我们通过使用图形邻接矩阵作为稀疏自我关注机制的注意掩模以及使用图形扩散机制来模拟更长范围令牌依赖性的关注掩模来提出源代码片段的调节。我们的型号在Bleu,Meteor和Rouge-L指标中达到最先进的结果,用于代码摘要任务以及可变误用任务的最先进的准确性。与先前作品的二次生长相比,我们模型的内存使用和推理时间具有相对于输入序列长度的线性生长。
translated by 谷歌翻译
与自然语言相反,源代码理解受到令牌之间的语法关系的影响,无论其标识符名称如何。源代码的图表表示诸如抽象语法树(AST)可以从源代码中捕获不明显的令牌之间的关系。我们提出了一种新颖的方法,GN变压器在融合序列和图形模型上学习端到端我们调用语法代码图(SCG)。 GN变压器使用自我关注机制在图形网络(GN)框架上展开。 SCG是源代码片段和AST表示之间的早期融合的结果。我们对SCG的结构进行了实验,对模型设计的消融研究,以及结论性能优势来自融合表示的超参数。所提出的方法在两个代码摘要数据集中实现最先进的性能,并跨越三个自动编码摘要度量(BLEU,Meteor,Rouge-L)。我们进一步评估了我们模型的人类感知质量和以前的工作与专家用户学习。我们的模型以人类的质量和准确性高出现有技术。
translated by 谷歌翻译
代码摘要可帮助开发人员理解程序并减少在软件维护过程中推断程序功能的时间。最近的努力诉诸深度学习技术,例如序列到序列模型,以生成准确的代码摘要,其中基于变压器的方法已实现了有希望的性能。但是,在此任务域中,有效地将代码结构信息集成到变压器中的情况不足。在本文中,我们提出了一种名为SG-Trans的新方法,将代码结构属性纳入变压器。具体而言,我们将局部符号信息(例如,代码令牌和语句)和全局句法结构(例如,数据流程图)注入变压器的自我发项模块中。为了进一步捕获代码的层次结构特征,局部信息和全局结构旨在分布在下层和变压器高层的注意力头中。广泛的评估表明,SG-trans的表现优于最先进的方法。与表现最佳的基线相比,SG-Trans在流星评分方面仍然可以提高1.4%和2.0%,这是一个广泛用于测量发电质量的度量,分别在两个基准数据集上。
translated by 谷歌翻译
尽管不断努力提高代码搜索的有效性和效率,但仍未解决两个问题。首先,编程语言具有固有的牢固结构链接,并且代码的特征是文本表单将省略其中包含的结构信息。其次,代码和查询之间存在潜在的语义关系,跨序列对齐代码和文本是具有挑战性的,因此在相似性匹配期间,向量在空间上保持一致。为了解决这两个问题,在本文中,提出了一个名为CSSAM的代码搜索模型(代码语义和结构注意匹配)。通过引入语义和结构匹配机制,CSSAM有效提取并融合了多维代码功能。具体而言,开发了交叉和残留层,以促进代码和查询的高纬度空间比对。通过利用残差交互,匹配模块旨在保留更多的代码语义和描述性功能,从而增强了代码及其相应查询文本之间的附着力。此外,为了提高模型对代码固有结构的理解,提出了一个名为CSRG的代码表示结构(代码语义表示图),用于共同表示抽象语法树节点和代码的数据流。根据两个包含540K和330K代码段的公开可用数据集的实验结果,CSSAM在两个数据集中分别在获得最高的SR@1/5/10,MRR和NDCG@50方面大大优于基本线。此外,进行消融研究是为了定量衡量CSSAM每个关键组成部分对代码搜索效率和有效性的影响,这为改进高级代码搜索解决方案提供了见解。
translated by 谷歌翻译
代码搜索目标是根据自然语言查询检索相关的代码片段,以提高软件生产力和质量。但是,由于源代码和查询之间的语义间隙,自动代码搜索是具有挑战性的。大多数现有方法主要考虑嵌入的顺序信息,其中文本背后的结构信息不完全考虑。在本文中,我们设计了一个名为GraphsearchNet的新型神经网络框架,通过共同学习源代码和查询的富集语义来启用有效和准确的源代码搜索。具体地,我们建议将源代码和查询编码为两个图,其中双向GGNN以捕获图表的本地结构信息。此外,我们通过利用有效的多主题来增强BigGNN,以补充BigGNN错过的全球依赖。关于Java和Python数据集的广泛实验说明了GraphSearchNet优于当前最先进的工作原位。
translated by 谷歌翻译
变形金刚是文本理解的强大模型。然而,由于其二次复杂性对输入序列长度的二次复杂性效率低下。虽然有很多关于变压器加速的方法,但它们仍然效率低于长序列或不够有效。在本文中,我们提出了FastFormer,即基于添加剂关注的高效变压器模型。在FastFormer中,我们首先使用添加剂注意机制来模拟全局上下文,而不是在令牌之间建模的成对相互建模,而不是建模。然后,基于与全局上下文表示的交互,进一步转换每个令牌表示。以这种方式,FastFormer可以实现具有线性复杂性的有效上下文建模。关于五个数据集的广泛实验表明,FastFormer比许多现有的变压器模型更有效,同时可以实现可比或甚至更好的长文本建模性能。
translated by 谷歌翻译
当使用深度学习技术对程序语言进行建模时,广泛采用了带有树或图形结构的神经网络,以捕获程序抽象语法树(AST)中的丰富结构信息。但是,计划中广泛存在长期/全球依赖性,大多数这些神经体系结构无法捕获这些依赖性。在本文中,我们提出了Tree-Transformer,这是一种新型的递归树结构神经网络,旨在克服上述局限性。树转化器利用两个多头注意单元来建模兄弟姐妹和父子节点对之间的依赖关系。此外,我们提出了一个双向传播策略,以允许节点信息向两个方向传递:沿树木的自下而上和自上而下。通过结合自下而上和自上而下的传播,树转化器可以同时学习全局上下文和有意义的节点特征。广泛的实验结果表明,我们的树转换器在具有树级和节点级别的预测任务中,在与程序相关的任务中优于现有基于树或基于图的神经网络,这表明Tree-Transformer在学习两个树级时都表现良好和节点级表示。
translated by 谷歌翻译
从结构化数据中学习是一项核心机器学习任务。通常,此类数据表示为图,通常仅考虑(键入)节点对之间的二进制关系。对于具有高度结构化数据的许多域而言,这是一个实质性的限制。一个重要的域是源代码,基于超图的表示可以更好地捕获代码的语义丰富和结构化的性质。在这项工作中,我们提出了热量,这是一种能够代表键入和合格的超图的神经模型,在该模型中,每个Hyperede都明确地符合参与节点的贡献。它可以看作是传递神经网络和变压器的消息的概括。我们使用新型程序代表程序来评估知识库完成和错误检测和维修的热量。在这两种情况下,它都优于强大的基线,表明其力量和通用性。
translated by 谷歌翻译
As the complexity of modern software continues to escalate, software engineering has become an increasingly daunting and error-prone endeavor. In recent years, the field of Neural Code Intelligence (NCI) has emerged as a promising solution, leveraging the power of deep learning techniques to tackle analytical tasks on source code with the goal of improving programming efficiency and minimizing human errors within the software industry. Pretrained language models have become a dominant force in NCI research, consistently delivering state-of-the-art results across a wide range of tasks, including code summarization, generation, and translation. In this paper, we present a comprehensive survey of the NCI domain, including a thorough review of pretraining techniques, tasks, datasets, and model architectures. We hope this paper will serve as a bridge between the natural language and programming language communities, offering insights for future research in this rapidly evolving field.
translated by 谷歌翻译
Optimization of directed acyclic graph (DAG) structures has many applications, such as neural architecture search (NAS) and probabilistic graphical model learning. Encoding DAGs into real vectors is a dominant component in most neural-network-based DAG optimization frameworks. Currently, most DAG encoders use an asynchronous message passing scheme which sequentially processes nodes according to the dependency between nodes in a DAG. That is, a node must not be processed until all its predecessors are processed. As a result, they are inherently not parallelizable. In this work, we propose a Parallelizable Attention-based Computation structure Encoder (PACE) that processes nodes simultaneously and encodes DAGs in parallel. We demonstrate the superiority of PACE through encoder-dependent optimization subroutines that search the optimal DAG structure based on the learned DAG embeddings. Experiments show that PACE not only improves the effectiveness over previous sequential DAG encoders with a significantly boosted training and inference speed, but also generates smooth latent (DAG encoding) spaces that are beneficial to downstream optimization subroutines. Our source code is available at \url{https://github.com/zehao-dong/PACE}
translated by 谷歌翻译
在源代码处理的领域中,基于变压器的表示模型表现出强大的功能,并在许多任务中都实现了最先进的(SOTA)性能。尽管变压器模型处理了顺序源代码,但证据表明,它们也可以捕获结构信息(\ eg,在语法树,数据流,控制流,\等)。我们提出了汇总的注意力评分,这是一种研究变压器学到的结构信息的方法。我们还提出了汇总的注意图,这是一种从预训练模型中提取程序图的新方法。我们从多个角度测量我们的方法。此外,根据我们的经验发现,我们使用自动提取的图形来替换可变滥用任务中那些巧妙的手动设计图。实验结果表明,我们自动提取的语义图非常有意义且有效,这为我们提供了一个新的观点,可以理解和使用模型中包含的信息。
translated by 谷歌翻译
变压器架构最近在图表表示学习中引起了人们的注意,因为它自然地克服了图神经网络(GNN)的几个局限性,避免了它们严格的结构电感偏置,而仅通过位置编码来编码图形结构。在这里,我们表明,具有位置编码的变压器生成的节点表示不一定捕获它们之间的结构相似性。为了解决这个问题,我们提出了结构感知的变压器,这是一类简单而灵活的图形变压器,建立在新的自我发项机制的基础上。这一新的自我注意力通过在计算注意力之前提取植根于每个节点的子图表来结合结构信息。我们提出了几种自动生成子图表表示的方法,并从理论上说明结果表示至少与子图表一样表现力。从经验上讲,我们的方法在五个图预测基准上实现了最先进的性能。我们的结构感知框架可以利用任何现有的GNN提取子图表表示,我们表明它系统地改善了相对于基本GNN模型的性能,成功地结合了GNN和变形金刚的优势。我们的代码可在https://github.com/borgwardtlab/sat上找到。
translated by 谷歌翻译
变形金刚在杂项任务中取得了进展,但遭受了二次计算和记忆复杂性的困扰。最近的作品提出了稀疏的变压器,并注意稀疏图,以降低复杂性并保持强劲的性能。虽然有效,但并未充分探索图形如何进行良好表现的关键部分。在本文中,我们提出了标准化信息有效载荷(NIP),这是图表评分函数,该函数测量图上的信息传输,该函数为性能和复杂性之间的权衡提供了分析工具。在这一理论分析的指导下,我们提出了HyperCube Transformer,这是一种稀疏的变压器,它模拟了HyperCube中的标记相互作用,并与Vanilla Transformer显示出可比甚至更好的结果,同时产生$ O(N \ log n)$复杂性,具有序列长度$ n $。对我们的图形函数的各种序列长度进行验证的任务实验。
translated by 谷歌翻译
在本文中,我们试图通过引入深度学习模型的句法归纳偏见来建立两所学校之间的联系。我们提出了两个归纳偏见的家族,一个家庭用于选区结构,另一个用于依赖性结构。选区归纳偏见鼓励深度学习模型使用不同的单位(或神经元)分别处理长期和短期信息。这种分离为深度学习模型提供了一种方法,可以从顺序输入中构建潜在的层次表示形式,即更高级别的表示由高级表示形式组成,并且可以分解为一系列低级表示。例如,在不了解地面实际结构的情况下,我们提出的模型学会通过根据其句法结构组成变量和运算符的表示来处理逻辑表达。另一方面,依赖归纳偏置鼓励模型在输入序列中找到实体之间的潜在关系。对于自然语言,潜在关系通常被建模为一个定向依赖图,其中一个单词恰好具有一个父节点和零或几个孩子的节点。将此约束应用于类似变压器的模型之后,我们发现该模型能够诱导接近人类专家注释的有向图,并且在不同任务上也优于标准变压器模型。我们认为,这些实验结果为深度学习模型的未来发展展示了一个有趣的选择。
translated by 谷歌翻译
Transformers-based models, such as BERT, have been one of the most successful deep learning models for NLP. Unfortunately, one of their core limitations is the quadratic dependency (mainly in terms of memory) on the sequence length due to their full attention mechanism. To remedy this, we propose, BIGBIRD, a sparse attention mechanism that reduces this quadratic dependency to linear. We show that BIGBIRD is a universal approximator of sequence functions and is Turing complete, thereby preserving these properties of the quadratic, full attention model. Along the way, our theoretical analysis reveals some of the benefits of having O(1) global tokens (such as CLS), that attend to the entire sequence as part of the sparse attention mechanism. The proposed sparse attention can handle sequences of length up to 8x of what was previously possible using similar hardware. As a consequence of the capability to handle longer context, BIGBIRD drastically improves performance on various NLP tasks such as question answering and summarization. We also propose novel applications to genomics data.
translated by 谷歌翻译
Machine Learning for Source Code (ML4Code) is an active research field in which extensive experimentation is needed to discover how to best use source code's richly structured information. With this in mind, we introduce JEMMA, an Extensible Java Dataset for ML4Code Applications, which is a large-scale, diverse, and high-quality dataset targeted at ML4Code. Our goal with JEMMA is to lower the barrier to entry in ML4Code by providing the building blocks to experiment with source code models and tasks. JEMMA comes with a considerable amount of pre-processed information such as metadata, representations (e.g., code tokens, ASTs, graphs), and several properties (e.g., metrics, static analysis results) for 50,000 Java projects from the 50KC dataset, with over 1.2 million classes and over 8 million methods. JEMMA is also extensible allowing users to add new properties and representations to the dataset, and evaluate tasks on them. Thus, JEMMA becomes a workbench that researchers can use to experiment with novel representations and tasks operating on source code. To demonstrate the utility of the dataset, we also report results from two empirical studies on our data, ultimately showing that significant work lies ahead in the design of context-aware source code models that can reason over a broader network of source code entities in a software project, the very task that JEMMA is designed to help with.
translated by 谷歌翻译
最近,人们对使用深度学习自动化软件工程任务的兴趣激增。这项工作解决了代码生成问题的问题,该问题是在其中以不同的语言或自然语言描述生成目标代码的目标代码。代码生成的大多数最先进的深度学习模型都使用主要是为自然语言设计的培训策略。但是,理解和生成代码需要对代码语法和语义的更严格理解。通过这种动机,我们开发了一个编码器变压器模型,其中训练编码器和解码器分别识别源和目标代码中的语法和数据流。我们不仅通过利用源代码的语法树和数据流程图来使编码器结构感知,而且我们还确保我们的解码器通过引入两个辅助任务来保留目标代码的语法和数据流:路径预测和数据流预测。据我们所知,这是第一项引入结构感知的变压器解码器,以通过对目标语法和数据流进行建模来增强生成代码的质量。所提出的结构编码器模型在CodexGlue基准测试中实现了代码翻译和文本对代码生成任务的最新性能。
translated by 谷歌翻译
Transformer models have achieved superior performance in various natural language processing tasks. However, the quadratic computational cost of the attention mechanism limits its practicality for long sequences. There are existing attention variants that improve the computational efficiency, but they have limited ability to effectively compute global information. In parallel to Transformer models, state space models (SSMs) are tailored for long sequences, but they are not flexible enough to capture complicated local information. We propose SPADE, short for $\underline{\textbf{S}}$tate s$\underline{\textbf{P}}$ace $\underline{\textbf{A}}$ugmente$\underline{\textbf{D}}$ Transform$\underline{\textbf{E}}$r. Specifically, we augment a SSM into the bottom layer of SPADE, and we employ efficient local attention methods for the other layers. The SSM augments global information, which complements the lack of long-range dependency issue in local attention methods. Experimental results on the Long Range Arena benchmark and language modeling tasks demonstrate the effectiveness of the proposed method. To further demonstrate the scalability of SPADE, we pre-train large encoder-decoder models and present fine-tuning results on natural language understanding and natural language generation tasks.
translated by 谷歌翻译
图形神经网络已被证明可以为各种软件工程任务产生令人印象深刻的结果。但是,现有技术仍然有两个问题:(1)长期依赖性和(2)不同的代码组件在不应该的情况下被视为平等。为了解决这些问题,我们提出了一种表示代码为层次结构(代码层次结构)的方法,其中不同的代码组件在各个粒度级别分别表示。然后,为了处理每个表示级别的表示,我们设计了一个新颖的网络体系结构Echelon,它结合了异质图形变压器网络和基于树的卷积神经网络的优势,以学习具有代码依赖性信息丰富的抽象语法树。我们还提出了一个新颖的预处理目标,称为缺失子树预测以补充我们的代码层次结构。评估结果表明,我们的方法在三个任务中大大优于其他基准:任何代码完成,代码分类和代码克隆检测。
translated by 谷歌翻译
Graph Neural Networks (GNNs) have shown great potential in the field of graph representation learning. Standard GNNs define a local message-passing mechanism which propagates information over the whole graph domain by stacking multiple layers. This paradigm suffers from two major limitations, over-squashing and poor long-range dependencies, that can be solved using global attention but significantly increases the computational cost to quadratic complexity. In this work, we propose an alternative approach to overcome these structural limitations by leveraging the ViT/MLP-Mixer architectures introduced in computer vision. We introduce a new class of GNNs, called Graph MLP-Mixer, that holds three key properties. First, they capture long-range dependency and mitigate the issue of over-squashing as demonstrated on the Long Range Graph Benchmark (LRGB) and the TreeNeighbourMatch datasets. Second, they offer better speed and memory efficiency with a complexity linear to the number of nodes and edges, surpassing the related Graph Transformer and expressive GNN models. Third, they show high expressivity in terms of graph isomorphism as they can distinguish at least 3-WL non-isomorphic graphs. We test our architecture on 4 simulated datasets and 7 real-world benchmarks, and show highly competitive results on all of them.
translated by 谷歌翻译