A da S witch: Adaptive Switching between Small and Large Agents for Effective Cloud-Local Collaborative Learning (2024)

Abstract: Recent advancements in large language models (LLMs) have been remarkable. Users face a choice between using cloud-based LLMs for generation quality and deploying local-based LLMs for lower computational cost. The former option is typically costly and inefficient, while the latter usually fails to deliver satisfactory performance for reasoning steps requiring deliberate thought processes. In this work, we propose a novel LLM utilization paradigm that facilitates the collaborative operation of large cloud-based LLMs and smaller local-deployed LLMs. Our framework comprises two primary modules: the local agent instantiated with a relatively smaller LLM, handling less complex reasoning steps, and the cloud agent equipped with a larger LLM, managing more intricate reasoning steps. This collaborative processing is enabled through an adaptive mechanism where the local agent introspectively identifies errors and proactively seeks assistance from the cloud agent, thereby effectively integrating the strengths of both locally-deployed and cloud-based LLMs, resulting in significant enhancements in task completion performance and efficiency. We evaluate AdaSwitch across 7 benchmarks, ranging from mathematical reasoning and complex question answering, using various types of LLMs to instantiate the local and cloud agents. The empirical results show that AdaSwitch effectively improves the performance of the local agent, and sometimes achieves competitive results compared to the cloud agent while utilizing much less computational overhead.

## introduction recently, the advent of large language models (llms) has garnered substantial attention from the public, industry, and academia, attributed to their advanced language comprehension and generation capabilities. these llms, such as ope-nai's gpt-4 @xcite ) and google's question: in a cage, there are chickens and rabbits. there are 10 heads and 24 legs in total. how many more legs do chickens have compared to rabbits? palm @xcite , are characterized by their massive scale, both in terms of the colossal number of parameters and the substantial volume of data utilized during their training process. due to their large number of parameters, llms are typically deployed on cloud servers. however, the reliance on cloud computing makes llm utilization considerably costly and inefficient, owing to the substantial bandwidth consumption, considerable strain on the network architecture and the need for extensive computational resources. a promising solution is to reduce the high computational demand of llms through techniques such as knowledge distillation @xcite or model quantization @xcite @xcite , and to deploy llms directly on local devices. though effective, small-sized llms are prone to severe performance degradation when confronted with complex and demanding situations, and usually fail to deliver satisfactory performance for reasoning steps requiring deliberate thought processes. to harness the strong capabilities of large-sized llms with the convenience of small-sized llms, we propose adaswitch, a novel framework enabling these two types of llms to collaboratively solve complex open-world tasks. this framework is inspired by human behavior in similar scenarios: when faced with complex tasks, people often seek assistance from more knowledgeable individuals for challenging components and learn from their guidance to complete the tasks. this ability to proactively seek assistance and apply acquired knowledge is a critical aspect of human intelligence. similarly, adaswitch comprises two primary modules: the local agent and the cloud agent. the local agent, instantiated with a relatively smaller llm, is capable of handling less complex reasoning steps. in contrast, the cloud agent, responsible for more deliberate reasoning, utilizes larger llms, such as llama-30b. our proposed approach is designed to enable both efficient inference with local smaller llms and resource-intensive cloud llm executions for task steps requiring higher cognitive capabilities. it effectively integrates the strengths of both locally-deployed and cloud-based llms, resulting in significant enhancements in task completion performance and efficiency. as depicted in figure 1 , given the question "how many more legs do chickens have compared to rabbits?", adaswitch interleaves its generation by first composing the sub-solution "calculate the number of chickens", then reflecting on the prior failing step, and offloading this challenging step to the cloud agent. the local agent thus is able to form an improved action to finally accomplish the task. using the cloud agent as an assistant allows the local agent to make effective use of a larger knowledge base and focus its efforts on learning the task steps appropriate for the model's current competence. the main idea behind adaswitch is to allow the local agent to adaptively activate the cloud agent when it introspectively judges the current step as incorrect. to this end, we enhance the local agent's self-checking capabilities by meticulously collecting inaccurate reasoning paths to con-struct the mistake-checking dataset. specifically, we ask the local agent to undertake an exam during which the cloud agent dynamically corrects the local agent's mistakes, incentivizing the local agent to learn from mistakes, determine when to ask for assistance, and how to utilize feedback to correct the mistake. finally, the resultant local agent can introspectively judge the running steps, proactively seek assistance, and apply acquired feedback to improve its subsequent actions. we conduct experiments on mathematical reasoning and complex reasoning benchmarks. adaswitch consistently improves the performance across various llms and tasks. for instance, the performance of the local model instantiated with the deepseek-coder-1.3b can be improved from 29.3% to 53.9%, requiring 3x fewer computational costs for llm inference than competitor system while achieving similar results. notably, our proposed framework even enables starcoder2-3b to achieve comparable performance against llama-30b, with 5x less computational overhead for llm inference. the effectiveness of the proposed method is also verified by ablation experiments and analytical experiments. ## conclusion in this work, we advocate adaswitch, a novel multi-agent collaboration framework that effectively integrates the strengths of both locally deployed and cloud-based llms. the local agent is responsible for less complex reasoning steps, and the cloud agent is dedicated to intricate reasoning steps. experimental results and in-depth analysis demonstrate that adaswitch is able to bring significant improvements in task performance while using much less computational overhead.