A Retrieval-Augmented Generation Approach to Extracting Algorithmic Logic from Neural Networks
Waleed Khalid, Dmitry Ignatov, Radu Timofte

TL;DR
NN-RAG is a retrieval-augmented system that extracts, validates, and enables cross-repository reuse of neural network modules from large codebases, significantly expanding the diversity of available architectures.
Contribution
The paper introduces NN-RAG, a novel scalable system for extracting and validating neural modules from code repositories, facilitating cross-project architectural reuse.
Findings
Extracted 1,289 candidate blocks from 19 repositories
Validated 941 (73%) blocks as scope-closed and runnable
Contributed approximately 72% of all novel network structures in the dataset
Abstract
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Taxonomy
TopicsScientific Computing and Data Management · Machine Learning in Materials Science · Software Engineering Research
