Evidence Hub

A hybrid static analysis and retrieval-augmented generation framework for ML code modernization

Sai Harshitha Sivalingala

Iowa State University Digital Repository (Iowa State University), 2026

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

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.

Open this study Sign up free