A hybrid static analysis and retrieval-augmented generation framework for ML code modernization
Abstract
Machine learning research often relies on legacy codebases built on deprecated libraries, making reproducibility difficult in modern environments. Updating such code requires significant manual effort to adapt to evolving APIs and frameworks, diverting researchers from core scientific work. This work presents an automated code migration system that modernizes legacy machine learning code through a hybrid three-tier architecture. The system first applies deterministic Abstract Syntax Tree (AST) transformations to update deprecated APIs and restructure code. When rule-based methods are insufficient, it uses a Retrieval-Augmented Generation(RAG) mechanism to identify and reuse relevant migration patterns from a curated knowledge base. For complex or previously unseen cases, a Large Language Model (LLM) performs guided refinement using retrieved contextual examples, improving reliability while reducing hallucinations. The system incorporates dependency-aware processing, multi-stage validation, and iter ative error correction to ensure correctness of the migrated code. Although evaluated on TensorFlow migrations, the architecture is framework-agnostic and can be extended to other ecosystems by modifying transformation rules and retrieval data. This approach reduces the effort required for code migration and improves reproducibility, enabling researchers to focus on experimentation rather than software maintenance.
Read the paper
Related studies
- Knowledge Management Perspective of Generative Artificial Intelligence
- Navigating Generative Artificial Intelligence Promises and Perils for Knowledge and Creative Work
- Characterizing the evolving research on enterprise content management
- Large language models and multimodal foundation models for precision oncology
- From Generative AI to Extended Reality: Multidisciplinary Perspectives on the Challenges, Opportunities, and Future of Educational Computing
- Generative Artificial Intelligence: A New Engine for Advancing Environmental Science and Engineering
Go deeper in Evidence Hub
Evidence Hub adds a study data sheet (design, sample size, evidence level, key numbers), an AI summary and a chat grounded in the paper's text.