Despite the continuous efforts in improving both the effectiveness and efficiency of code search, two issues remained unsolved. First, programming languages have inherent strong structural linkages, and feature mining of code as text form would omit the structural information contained inside it. Second, there is a potential semantic relationship between code and query, it is challenging to align code and text across sequences so that vectors are spatially consistent during similarity matching. To tackle both issues, in this paper, a code search model named CSSAM (Code Semantics and Structures Attention Matching) is proposed. By introducing semantic and structural matching mechanisms, CSSAM effectively extracts and fuses multidimensional code features. Specifically, the cross and residual layer was developed to facilitate high-latitude spatial alignment of code and query at the token level. By leveraging the residual interaction, a matching module is designed to preserve more code semantics and descriptive features, that enhances the adhesion between the code and its corresponding query text. Besides, to improve the model's comprehension of the code's inherent structure, a code representation structure named CSRG (Code Semantic Representation Graph) is proposed for jointly representing abstract syntax tree nodes and the data flow of the codes. According to the experimental results on two publicly available datasets containing 540k and 330k code segments, CSSAM significantly outperforms the baselines in terms of achieving the highest SR@1/5/10, MRR, and NDCG@50 on both datasets respectively. Moreover, the ablation study is conducted to quantitatively measure the impact of each key component of CSSAM on the efficiency and effectiveness of code search, which offers the insights into the improvement of advanced code search solutions.
翻译:尽管在提高代码搜索的效能和效率方面不断努力,但有两个问题仍未解决。首先,编程语言具有内在的牢固结构联系,并具有代码的挖掘特征,因为文本格式会省略其中所含的结构信息。第二,代码和查询之间可能存在语义关系,因此很难在顺序上对代码和文字进行对齐,使矢量在相近时保持空间一致性。为了解决这两个问题,本文件提出了名为 CCAM(Code NSAM 语义和结构关注匹配)的代码搜索模型。首先,通过引入语义和结构匹配机制,CSSM(CSSM)有效地提取代码和引信,因为文本格式格式将删除。具体地说,交叉和剩余层是为了促进代码和查询之间的高纬度空间协调。通过利用剩余互动,一个匹配模块旨在保存更多的代码语义和描述性特征,从而增强代码与对应的查询文本之间的粘合。此外,为了改进代码的内在结构,CSRG(Code Semantical) 提取代码,MSAR5号中的每一关键部分的搜索段的计算结果。