LLM-Rosetta: 一个用于跨提供商LLM API翻译的枢纽-辐射中间表示
LLM-Rosetta: A Hub-and-Spoke Intermediate Representation for Cross-Provider LLM API Translation
AI总结:
LLM-Rosetta通过枢纽-辐射中间表示捕捉共享语义核心,实现跨提供商LLM API双向转换,支持流式传输和状态管理,覆盖主要商业提供商,具备高效率和中立性。
摘要:
随着大型语言模型(LLM)提供商的快速增加,每个提供商都暴露了专有的API格式,导致生态系统碎片化,应用程序紧密耦合于个别供应商。切换或桥接提供商需要O(N^2)双边适配器,阻碍了可移植性和多供应商架构。我们发现尽管存在显著的语法差异,主要LLM API共享一个共同的语义核心:实际挑战是语法变化的组合表面,而非深层语义不兼容。基于此发现,我们提出了LLM-Rosetta,一个开源翻译框架,基于枢纽-辐射中间表示(IR),在9种内容模型和10种流事件模式中捕捉共享语义核心——消息、内容部分、工具调用、推理轨迹和生成控制。模块化的Ops组合转换架构使每个API标准可以独立添加。LLM-Rosetta支持请求和响应负载的双向转换,包括分块级流式传输和具有状态管理的上下文。我们为四个API标准(OpenAI Chat Completions、OpenAI Responses、Anthropic Messages和Google GenAI)实现了转换器,覆盖了大多数商业提供商。实证评估显示无损往返保真度、正确流式行为和亚100微秒的转换开销——与LiteLLM的单次通过方法竞争,同时提供双向性和供应商中立性。LLM-Rosetta通过了Open Responses合规套件,并在Argonne国家实验室部署生产。代码可在https://github.com/Oaklight/llm-rosetta获取。
英文摘要:
The rapid proliferation of Large Language Model (LLM) providers--each exposing proprietary API formats--has created a fragmented ecosystem where applications become tightly coupled to individual vendors. Switching or bridging providers requires $O(N^2)$ bilateral adapters, impeding portability and multi-provider architectures. We observe that despite substantial syntactic divergence, the major LLM APIs share a common semantic core: the practical challenge is the combinatorial surface of syntactic variations, not deep semantic incompatibility. Based on this finding, we present LLM-Rosetta, an open-source translation framework built on a hub-and-spoke Intermediate Representation (IR) that captures the shared semantic core--messages, content parts, tool calls, reasoning traces, and generation controls--in a 9-type content model and 10-type stream event schema. A modular Ops-composition converter architecture enables each API standard to be added independently. LLM-Rosetta supports bidirectional conversion (provider-to-IR-to-provider) for both request and response payloads, including chunk-level streaming with stateful context management. We implement converters for four API standards (OpenAI Chat Completions, OpenAI Responses, Anthropic Messages, and Google GenAI), covering the vast majority of commercial providers. Empirical evaluation demonstrates lossless round-trip fidelity, correct streaming behavior, and sub-100 microsecond conversion overhead--competitive with LiteLLM's single-pass approach while providing bidirectionality and provider neutrality. LLM-Rosetta passes the Open Responses compliance suite and is deployed in production at Argonne National Laboratory. Code is available at https://github.com/Oaklight/llm-rosetta.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。