arXiv:2512.04329cs.CVcs.SE2025-12被引 13

将零散神经网络代码转化为可搜索、可复现的模块库,提升算法复用效率。

A Retrieval-Augmented Generation Approach to Extracting Algorithmic Logic from Neural Networks

  • 通过依赖解析与重构,提取可独立运行的神经网络模块。
  • 从19个仓库中提取1289个模块,验证941个(73%),超80%结构独特。
  • 支持跨项目迁移架构模式,适合研究者高效复用和发现新模型。

重用现有神经网络组件是提升研究效率的关键,但跨数千个开源仓库发现、提取并验证这些模块仍极困难。我们提出NN-RAG,一种检索增强生成系统,将大规模异构的PyTorch代码库转化为可搜索、可执行的已验证神经模块库。不同于传统代码搜索或克隆检测工具,NN-RAG实现作用域感知依赖解析、导入保留重构及验证器控制晋升,确保每个检索到的代码块均为作用域闭合、可编译且可运行。应用于19个主要仓库,该流程提取1,289个候选模块,验证941个(73.0%),并证明超80%具有结构唯一性。通过多级去重(精确、词法、结构),发现NN-RAG为LEMUR数据集贡献了绝大多数独特架构,提供约72%的新网络结构。除数量外,NN-RAG还首次实现跨仓库架构模式迁移,自动识别某项目中的可复用模块,并在新上下文中完整重构其依赖关系。据我们所知,尚无其他开源系统具备此规模能力。框架的中立规范支持与语言模型集成以实现合成或数据集注册,无需分发第三方代码。总体而言,NN-RAG将碎片化视觉代码转化为可复现、可溯源的算法发现基础,成为首个同时量化与扩展跨仓库可执行神经架构多样性的开源方案。

原文摘要 · Abstract (English)

Reusing existing neural-network components is central to research efficiency, yet discovering, extracting, and validating such modules across thousands of open-source repositories remains difficult. We introduce NN-RAG, a retrieval-augmented generation system that converts large, heterogeneous PyTorch codebases into a searchable and executable library of validated neural modules. Unlike conventional code search or clone-detection tools, NN-RAG performs scope-aware dependency resolution, import-preserving reconstruction, and validator-gated promotion -- ensuring that every retrieved block is scope-closed, compilable, and runnable. Applied to 19 major repositories, the pipeline extracted 1,289 candidate blocks, validated 941 (73.0%), and demonstrated that over 80% are structurally unique. Through multi-level de-duplication (exact, lexical, structural), we find that NN-RAG contributes the overwhelming majority of unique architectures to the LEMUR dataset, supplying approximately 72% of all novel network structures. Beyond quantity, NN-RAG uniquely enables cross-repository migration of architectural patterns, automatically identifying reusable modules in one project and regenerating them, dependency-complete, in another context. To our knowledge, no other open-source system provides this capability at scale. The framework's neutral specifications further allow optional integration with language models for synthesis or dataset registration without redistributing third-party code. Overall, NN-RAG transforms fragmented vision code into a reproducible, provenance-tracked substrate for algorithmic discovery, offering a first open-source solution that both quantifies and expands the diversity of executable neural architectures across repositories.

神经网络代码提取模块复用检索生成

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。