In-Context Learning State Vector with Inner and Momentum Optimization

Dongfang Li,Zhenyu Liu,Xinshuo Hu,Zetian Sun,Baotian Hu,Min Zhang
2024-07-04
Abstract:Large Language Models (LLMs) have exhibited an impressive ability to perform In-Context Learning (ICL) from only a few examples. Recent works have indicated that the functions learned by ICL can be represented through compressed vectors derived from the transformer. However, the working mechanisms and optimization of these vectors are yet to be thoroughly explored. In this paper, we address this gap by presenting a comprehensive analysis of these compressed vectors, drawing parallels to the parameters trained with gradient descent, and introduce the concept of state vector. Inspired by the works on model soup and momentum-based gradient descent, we propose inner and momentum optimization methods that are applied to refine the state vector progressively as test-time adaptation. Moreover, we simulate state vector aggregation in the multiple example setting, where demonstrations comprising numerous examples are usually too lengthy for regular ICL, and further propose a divide-and-conquer aggregation method to address this challenge. We conduct extensive experiments using Llama-2 and GPT-J in both zero-shot setting and few-shot setting. The experimental results show that our optimization method effectively enhances the state vector and achieves the state-of-the-art performance on diverse tasks. Code is available at <a class="link-external link-https" href="https://github.com/HITsz-TMG/ICL-State-Vector" rel="external noopener nofollow">this https URL</a>
Computation and Language,Artificial Intelligence
What problem does this paper attempt to address?
The paper attempts to address the problem of how to optimize and utilize compressed vectors to improve the performance of large language models (LLMs) in In-Context Learning (ICL). Specifically, the paper focuses on the following aspects: 1. **Mechanism and Optimization of Compressed Vectors**: - The paper explores the mechanism of compressed vectors in ICL and draws an analogy with parameters trained through gradient descent, introducing the concept of state vectors. - The authors introduce inner optimization and momentum optimization methods to gradually improve the state vectors, enhancing adaptability during testing. 2. **Challenges in Multi-Example Settings**: - When dealing with multiple examples, conventional ICL methods often encounter the problem of context length limitations. To address this, the paper proposes a divide-and-conquer aggregation method, compressing multiple examples into a single state vector, effectively solving this challenge. 3. **Experimental Validation**: - The authors conducted extensive experiments using Llama-2 and GPT-J in zero-shot and few-shot settings to validate the effectiveness of the proposed methods. The experimental results demonstrate that the optimized state vectors achieve state-of-the-art performance across various tasks. In summary, the main goal of the paper is to improve the performance of ICL in large language models by optimizing and aggregating state vectors, particularly in multi-example settings.