DAInfer+: 通过嵌入模型从文档中推断API规范的神经符号推理
DAInfer+: Neurosymbolic Inference of API Specifications from Documentation via Embedding Models
AI总结:
本文提出DAInfer+,利用NLP和嵌入模型从库文档推断API规范,通过神经符号优化提高数据流和别名关系推断的精度与效率。
摘要:
现代软件系统依赖各种库,需要在静态分析中理解API语义。然而,由于复杂的实现或不可用的库代码,总结API语义具有挑战性。本文提出了DAInfer+,一种从库文档推断API规范的新方法。我们利用自然语言处理(NLP)来解释文档中的非正式语义信息,将规范推断转化为优化问题。具体而言,我们研究了句子嵌入模型和大语言模型(LLMs)在从API描述中推导内存操作抽象中的有效性。这些抽象用于检索数据流和别名关系以生成全面的API规范。为高效解决优化问题,我们提出神经符号优化,产生精确的数据流和别名规范。对流行Java库的评估显示,零样本句子嵌入模型在鲁棒性上优于少样本提示的LLMs,能更有效捕捉细粒度语义。尽管我们的初步尝试使用两阶段LLM提示取得了有希望的结果,但发现基于嵌入的方法更优。具体而言,这些模型在数据流推断中达到82%的召回率和85%的精确率,在别名关系推断中达到88%的召回率和79%的精确率,均在几秒钟内完成。这些结果证明了DAInfer+在库感知静态分析中的实际价值。
英文摘要:
Modern software systems heavily rely on various libraries, which require understanding the API semantics in static analysis. However, summarizing API semantics remains challenging due to complex implementations or unavailable library code. This paper presents DAInfer+, a novel approach for inferring API specifications from library documentation. We employ Natural Language Processing (NLP) to interpret informal semantic information provided by the documentation, which enables us to reduce the specification inference to an optimization problem. Specifically, we investigate the effectiveness of sentence embedding models and Large Language Models (LLMs) in deriving memory operation abstractions from API descriptions. These abstractions are used to retrieve data-flow and aliasing relations to generate comprehensive API specifications. To solve the optimization problem efficiently, we propose neurosymbolic optimization, yielding precise data-flow and aliasing specifications. Our evaluation of popular Java libraries shows that zero-shot sentence embedding models outperform few-shot prompted LLMs in robustness, capturing fine-grained semantic nuances more effectively. While our initial attempts using two-stage LLM prompting yielded promising results, we found that the embedding-based approach proved superior. Specifically, these models achieve over 82% recall and 85% precision for data-flow inference and 88% recall and 79% precision for alias relations, all within seconds. These results demonstrate the practical value of DAInfer+ in library-aware static analysis.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。