[论文解读] Learning Blended, Precise Semantic Program Embeddings
本文提出 LiGer,一种深度神经网络,通过融合符号执行轨迹与实际执行轨迹来学习精确的程序嵌入表示,显著提升了语义分类准确率,并降低了执行开销,相较于最先进的静态与动态模型表现更优。LiGer 在程序语义分类与方法名预测任务中达到最先进性能,优于门控图神经网络、code2vec 与 code2seq,且所需执行次数仅为 DYPRO 的十分之一。
Learning neural program embeddings is key to utilizing deep neural networks in program languages research --- precise and efficient program representations enable the application of deep models to a wide range of program analysis tasks. Existing approaches predominately learn to embed programs from their source code, and, as a result, they do not capture deep, precise program semantics. On the other hand, models learned from runtime information critically depend on the quality of program executions, thus leading to trained models with highly variant quality. This paper tackles these inherent weaknesses of prior approaches by introducing a new deep neural network, \liger, which learns program representations from a mixture of symbolic and concrete execution traces. We have evaluated \liger on \coset, a recently proposed benchmark suite for evaluating neural program embeddings. Results show \liger (1) is significantly more accurate than the state-of-the-art syntax-based models Gated Graph Neural Network and code2vec in classifying program semantics, and (2) requires on average 10x fewer executions covering 74\% fewer paths than the state-of-the-art dynamic model \dypro. Furthermore, we extend \liger to predict the name for a method from its body's vector representation. Learning on the same set of functions (more than 170K in total), \liger significantly outperforms code2seq, the previous state-of-the-art for method name prediction.
研究动机与目标
- 为解决仅依赖源代码的静态模型无法捕捉深层语义的局限性。
- 克服依赖实际程序执行的动态模型所存在的高方差与高执行开销问题。
- 开发一种结合符号与实际执行轨迹的混合方法,以实现更精确且高效的程序嵌入表示。
- 通过统一的神经网络架构,提升程序语义分类与方法名预测的准确性。
提出的方法
- LiGer 采用双分支神经网络,分别处理符号执行轨迹与实际执行轨迹。
- 利用注意力机制动态加权并融合来自符号与实际执行轨迹的特征,生成统一的程序嵌入表示。
- 通过对比学习进行端到端训练,使语义等价程序的嵌入对齐,不同语义程序的嵌入分离。
- 在方法名预测任务中,LiGer 使用自回归解码器,基于融合后的嵌入表示逐词生成方法名。
- 符号轨迹通过控制流与数据流信息的静态分析生成,实际轨迹则通过使用多样化输入的实际程序运行收集。
- 该架构通过可学习的融合模块,基于相关性与上下文自适应地结合两类轨迹的表示。
实验结果
研究问题
- RQ1结合符号与实际执行轨迹的融合方法是否能提升程序嵌入的精度,相比纯静态或动态方法?
- RQ2符号与实际执行轨迹的融合如何影响模型在程序语义分类任务中的准确性?
- RQ3LiGer 在保持或提升嵌入质量的前提下,能否显著减少所需程序执行次数,相比动态模型?
- RQ4融合后的嵌入表示是否能在下游任务(如方法名预测)中具有良好泛化能力?
- RQ5LiGer 在语义分类与方法名预测任务中,与 code2vec、code2seq 及门控图神经网络等最先进模型相比表现如何?
主要发现
- 在 COSET 基准测试中,LiGer 在程序语义分类任务上的准确率显著高于门控图神经网络与 code2vec。
- LiGer 平均仅需 DYPRO 所需执行次数的十分之一,且覆盖路径数减少 74%。
- 通过引入符号轨迹,模型降低了训练质量的方差,稳定了学习过程,减少了对执行质量的依赖。
- 在方法名预测任务中,LiGer 在超过 17 万个函数的数据集上优于 code2seq。
- 融合方法使 LiGer 能够捕捉到静态模型所忽略的深层语义相似性(例如,冒泡排序的不同实现之间)。
- 注意力机制有效协调了符号与实际执行轨迹之间的特征融合,生成了更鲁棒、更精确的嵌入表示。
更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。