Hybrid API Migration: A Marriage of Small API Mapping Models and Large Language Models
计算机科学
程序设计语言
并行计算
作者
Bingzhe Zhou,Xinying Wang,Shengbin Xu,Yuan Yao,Minxue Pan,Feng Xu,Xiaoxing Ma
标识
DOI:10.1145/3609437.3609466
摘要
API migration is an essential step for code migration between libraries or programming languages, and it is a challenging task as it requires detailed comprehension of both source and target APIs. The existing work either recommends mapped API names only and requires developers to select specific parameters and return value, or uses encoder-decoder models to directly "translate" the source API code into the target API code without considering the characteristics of APIs. In this paper, we propose a hybrid approach that combines small API mapping models with Large Language Models (LLMs). Specifically, the small API mapping model is employed to embed API semantics through their usages and declarations, enabling accurate inference of API mappings across different libraries and programming languages. The inferred mappings are subsequently used as part of the prompts to guide LLMs to generate the target API code corresponding to the source API code. Experimental evaluations demonstrate the effectiveness of our approach in comparison to existing approaches w.r.t. both cross-library and cross-language API migration.