CodeGraph: Open-Taxonomy Knowledge Graph for Source Code with Wikidata Grounding
作者: Federico Pennino, Andrea Gurioli, Stefano Zacchiroli, Maurizio Gabbrielli, Paolo Ferragina
分类: cs.SE, cs.CL, cs.IR
发布日期: 2026-09-24
备注: Accepted at CIKM 2026
💡 一句话要点
提出CodeGraph以解决源代码知识提取问题
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 知识图谱 源代码分析 大型语言模型 Wikidata 软件工程 语义注释 开放分类
📋 核心要点
- 现有方法在提取源代码中的隐含知识时,主要受限于语法和标记级分析,难以深入理解代码的语义。
- 论文提出了一种基于大型语言模型的三阶段链接程序,能够有效地将源代码中的实体与Wikidata进行关联,形成知识图谱。
- 通过对167百万个文件的处理,创建了首个大规模开放分类知识图谱CodeGraph,包含约158百万个节点和近1亿个类型化边。
📝 摘要(中文)
公共软件库如GitHub和Software Heritage Archive存储了数十亿个文件,但提取其隐含的工程知识(如实现的算法、遵循的范式、实例化的模式及应用领域)仍然具有挑战性,因为现有工具仅限于语法和标记级分析。本文提出了一种使用专门针对代码的大型语言模型构建源代码开放分类语义注释的流程。通过三阶段链接程序将提取的实体与Wikidata关联,最终形成一个源代码特定的开放分类知识图谱CodeGraph。该图谱包含约1.58亿个节点,涵盖14种编程语言,展示了其在知识提取领域的创新应用。
🔬 方法详解
问题定义:本文旨在解决从公共软件库中提取隐含工程知识的难题,现有工具无法深入理解代码的语义,导致知识提取效果不佳。
核心思路:通过使用专门针对代码的大型语言模型,结合三阶段链接程序,将源代码中的实体与Wikidata进行有效关联,从而构建开放分类知识图谱。
技术框架:整体流程包括三个主要阶段:第一阶段使用确定性SPARQL处理明确实体,第二阶段通过深度研究代理解决残余的长尾问题,第三阶段导入每个解析的Wikidata标识符的父类闭包。
关键创新:最重要的创新在于引入了一个经过校准的质量保证协议,结合小规模人工金标准与大型语言模型的判别能力,量化注释的精确度。
关键设计:在设计中,采用了多种参数设置和损失函数,以确保模型在处理复杂代码时的准确性和鲁棒性,具体细节包括对不同编程语言的适配和实体的多层次分类。
🖼️ 关键图片
📊 实验亮点
实验结果表明,CodeGraph成功处理了167百万个文件,创建了首个大规模开放分类知识图谱,包含约158百万个节点和近1亿个类型化边,显著提升了源代码知识提取的效率和准确性。
🎯 应用场景
该研究的潜在应用领域包括软件工程、代码分析、自动化文档生成等。通过构建开放分类知识图谱,开发者可以更高效地理解和利用源代码中的知识,推动软件开发的智能化进程。未来,该技术有望在代码搜索、推荐系统和智能辅助编程等方面发挥重要作用。
📄 摘要(原文)
Public software repositories, like GitHub and Software Heritage Archive, store billions of files, yet extracting their implicit engineering knowledge ---i.e., the algorithms they implement, the paradigms they follow, the patterns they instantiate, and the application domains they serve--- remains challenging, as current tools are constrained to syntactic and token-level analysis. We present a pipeline for building an open-taxonomy semantic annotation of source code using a code-specialised Large Language Model. The extracted entities are grounded in Wikidata through a three-stage linking procedure: a deterministic SPARQL stage handles unambiguous entities, a Deep Research Agent resolves the residual long tail, and a hierarchy-rollup stage imports the parent-of closure of each resolved Wikidata identifier. The resulting annotations are materialised as a source-code-specific open-taxonomy knowledge graph. We further introduce a calibrated quality-assurance protocol that quantifies annotation precision by combining a small human gold set with an LLM-as-a-judge filter. We applied our pipeline to the 167 million files of the Stack-Edu corpus, creating the first known large-scale open-taxonomy knowledge graph for source code. Our graph, named CodeGraph, contains approximately 158 million nodes, which include around 145 million files, about 63,000 extracted concept entities (such as algorithms, paradigms, design patterns, and application domains), and roughly 19,800 grounded Wikidata entities. Furthermore, CodeGraph features approximately 1 billion typed edges that connect files to their respective concepts, link these concepts to their grounded Wikidata identifiers, and relate them to their parent categories, covering 14 programming languages.