search
HomeTechnology peripheralsAIICML 2024 | Revealing the mechanism of non-linear Transformer learning and generalization in contextual learning

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制
The AIxiv column is a column where academic and technical content is published on this site. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com

The author of this article, Li Hongkang, is a doctoral student in the Department of Electrical, Computer and Systems Engineering at Rensselaer Polytechnic Institute in the United States. He graduated from the University of Science and Technology of China with a bachelor's degree. Research directions include deep learning theory, large language model theory, statistical machine learning, etc. He has published many papers at top AI conferences such as ICLR/ICML/Neurips.

In-context learning (ICL) has demonstrated powerful capabilities in many LLM-related applications, but its theoretical analysis is still relatively limited. People are still trying to understand why LLM based on the Transformer architecture can exhibit the capabilities of ICL.

Recently, a team from Rensselaer Polytechnic Institute and IBM Research analyzed the ICL of Transformer with nonlinear attention module (attention) and multilayer perceptron (MLP) from the perspective of optimization and generalization theory ability. In particular, they theoretically proved the ICL mechanism in which a single-layer Transformer first selects some contextual examples based on the query in the attention layer, and then makes predictions based on label embeddings in the MLP layer. This article has been included in ICML 2024.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

  • Paper title: How Do Nonlinear Transformers Learn and Generalize in In-Context Learning?

  • Paper address: https://arxiv.org/pdf/2402.15607

Background introduction

In context learning (ICL)

Context learning (ICL) is a new learning paradigm that is very popular in large language models (LLM). It specifically refers to adding N test sample testing examples (context) before the testing query (testing query) ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制, that is, the combination of test input ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 and test output ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制, thus forming a testing prompt: ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 as the input of the model to guide the model Make correct inferences. This method is different from the classic method of fine-tuning a pre-trained model. It does not require changing the weight of the model, making it more efficient.

Progress in ICL theoretical work

Many recent theoretical works are based on the research framework proposed by [1], that is, people can directly use the prompt format to train the Transformer (this step can also be understood as simulating A simplified LLM pre-training mode), thereby making the model have ICL capabilities. Existing theoretical work focuses on the expressive power of the model [2]. They found that one could find a Transformer with “perfect” parameters that could perform ICL through forward operations and even implicitly perform classic machine learning algorithms such as gradient descent. But these works cannot answer why Transformer can be trained to such "perfect" parameters with ICL capabilities. Therefore, there are also some works trying to understand the ICL mechanism from the perspective of training or generalization of Transformer [3,4]. However, due to the complexity of analyzing the Transformer structure, these works currently stop at studying linear regression tasks, and the models considered usually omit the non-linear part of the Transformer.

This article analyzes the ICL capabilities and mechanisms of Transformer with nonlinear attention and MLP from the perspective of optimization and generalization theory:

  • Based on a simplified classification model, this article specifically quantifies how the characteristics of the data affect a The in-domain and out-of-domain (OOD) ICL generalization capabilities of the layer single-head Transformer.

  • This article further explains how ICL is implemented through trained Transformer.

  • Based on the characteristics of the trained Transformer, this article also analyzes the feasibility of using magnitude-based model pruning during ICL inference.

Theoretical part

Problem description

This paper considers a two-classification problem, that is, mapping ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 to ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 through a task ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制. In order to solve such a problem, this article builds prompt for learning. The prompt here is represented as:

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

Training the network as a single-layer single-head Transformer:

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

The pre-training process is to solve an empirical risk minimization for all training tasks. The loss function uses Hinge loss, which is suitable for binary classification problems, and the training algorithm is stochastic gradient descent.

This article defines two cases of ICL generalization. One is in-domain, that is, the distribution of the test data is the same as the training data during generalization. Note that the test task does not have to be the same as the training task in this case, that is, the generalization of unseen tasks has been considered here. The other one is out-of-domain, that is, the distribution of test and training data is different.

This article also involves the analysis of magnitude-based pruning during ICL inference. The pruning method here refers to deleting each neuron obtained by training from small to large according to its amplitude.

Construction of data and tasks

Please refer to Section 3.2 of the original text for this part. Here is just an overview. The theoretical analysis of this article is based on the recently popular feature learning route, that is, the data is usually assumed to be separable (usually orthogonal) patterns, thereby deriving gradient changes based on different patterns. This article first defines a set of in-domain-relevant (IDR) patterns used to determine the classification of in-domain tasks, and a set of task-independent in-domain-irrelevant (IDI) patterns. These patterns are orthogonal to each other. There are ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 IDR patterns and ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 IDI patterns. A ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 is represented as the sum of an IDR pattern and an IDI pattern. An in-domain task is defined as a classification problem based on two IDR patterns.

Similarly, this article can describe the data and tasks when OOD is generalized by defining out-of-domain-relevant (ODR) pattern and out-of-domain-irrelevant (ODI) pattern.

The representation of prompt in this article can be explained by the example in the figure below, where ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 is the IDR pattern and ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 is the IDI pattern. The task being done here is to classify based on ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 in x. If it is ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制, then its label is + 1, which corresponds to +q. If it is ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制, then its label is - 1, which corresponds to -q. α, α' are defined as the context examples that are the same as the query's IDR/ODR pattern in the training and testing prompts respectively. In the example below, ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

Theoretical results

First of all, for the in-domain situation, this article first gives a condition 3.2 to specify the conditions that the training task needs to meet, that is, the training task needs to cover all IDR patterns and labels. Then the in-domain results are as follows:

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

This shows: 1. The number of training tasks only needs to account for a small proportion of all tasks that meets condition 3.2, and we can achieve good generalization of unseen tasks ; 2. The higher the proportion of IDR patterns related to the current task in the prompt, the ideal generalization can be achieved with less training data, number of training iterations, and shorter training/testing prompts.

Next is the result of out-of-domain generalization.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

It is explained here that if the ODR pattern is a linear combination of the IDR pattern and the coefficient sum is greater than 1, then OOD ICL generalization can achieve the ideal effect at this time. This result gives the intrinsic connection between training and test data required for good OOD generalization under the framework of ICL. This theorem has also been verified by experiments on GPT-2. As shown in the figure below, when the coefficient sum ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 in (12) is greater than 1, OOD classification can achieve ideal results. At the same time, when ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制, that is, when the proportion of ODR/IDR patterns related to classification tasks in the prompt is higher, the required context length is smaller.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

Then, this paper gives the ICL generalization results with magnitude-based pruning.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

This result shows that, first of all, some (constant proportion) neurons in the trained ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制 have small amplitudes, while the remaining ones are relatively large (Equation 14). When we only prune small neurons, there is basically no impact on the generalization results. When the proportion of pruning increases to pruning large neurons, the generalization error will increase significantly (Formula 15, 16). The following experiment verifies Theorem 3.7. The light blue vertical line in Figure A below represents the ICML 2024 | Revealing the mechanism of non-linear Transformer learning and generalization in contextual learning obtained by training and presents the results of Formula 14. However, pruning small neurons will not worsen generalization. This result is consistent with the theory. Figure B reflects that when there is more task-related context in the prompt, we can allow a larger pruning ratio to achieve the same generalization performance.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

ICL mechanism

By characterizing the pre-training process, this article obtains the internal mechanism of single-layer single-head nonlinear Transformer for ICL, which is in Section 4 of the original article. This process can be represented by the diagram below.

ICML 2024 | 揭示非线形Transformer在上下文学习中学习和泛化的机制

In short, the attention layer will select the same context as the ODR/IDR pattern of the query, giving them almost all attention weights, and then the MLP layer will focus on making the final classification based on the label embedding in the attention layer output. .

Summary

This article explains the training mechanism of nonlinear Transformer in ICL, as well as its generalization ability to new tasks and distribution shift data. The theoretical results have certain practical significance for designing prompt selection algorithm and LLM pruning algorithm.

参考文献

[1] Garg, et al., Neurips 2022. "What can transformers learn in-context? a case study of simple function classes."

[2] Von Oswald et al., ICML 2023. "Transformers learn in-context by gradient descent."

[3] Zhang et al., JMLR 2024. "Trained transformers learn linear models in-context."

[4] Huang et al., ICML 2024. "In-context convergence of transformers."

The above is the detailed content of ICML 2024 | Revealing the mechanism of non-linear Transformer learning and generalization in contextual learning. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
DSA如何弯道超车NVIDIA GPU?DSA如何弯道超车NVIDIA GPU?Sep 20, 2023 pm 06:09 PM

你可能听过以下犀利的观点:1.跟着NVIDIA的技术路线,可能永远也追不上NVIDIA的脚步。2.DSA或许有机会追赶上NVIDIA,但目前的状况是DSA濒临消亡,看不到任何希望另一方面,我们都知道现在大模型正处于风口位置,业界很多人想做大模型芯片,也有很多人想投大模型芯片。但是,大模型芯片的设计关键在哪,大带宽大内存的重要性好像大家都知道,但做出来的芯片跟NVIDIA相比,又有何不同?带着问题,本文尝试给大家一点启发。纯粹以观点为主的文章往往显得形式主义,我们可以通过一个架构的例子来说明Sam

阿里云通义千问14B模型开源!性能超越Llama2等同等尺寸模型阿里云通义千问14B模型开源!性能超越Llama2等同等尺寸模型Sep 25, 2023 pm 10:25 PM

2021年9月25日,阿里云发布了开源项目通义千问140亿参数模型Qwen-14B以及其对话模型Qwen-14B-Chat,并且可以免费商用。Qwen-14B在多个权威评测中表现出色,超过了同等规模的模型,甚至有些指标接近Llama2-70B。此前,阿里云还开源了70亿参数模型Qwen-7B,仅一个多月的时间下载量就突破了100万,成为开源社区的热门项目Qwen-14B是一款支持多种语言的高性能开源模型,相比同类模型使用了更多的高质量数据,整体训练数据超过3万亿Token,使得模型具备更强大的推

ICCV 2023揭晓:ControlNet、SAM等热门论文斩获奖项ICCV 2023揭晓:ControlNet、SAM等热门论文斩获奖项Oct 04, 2023 pm 09:37 PM

在法国巴黎举行了国际计算机视觉大会ICCV(InternationalConferenceonComputerVision)本周开幕作为全球计算机视觉领域顶级的学术会议,ICCV每两年召开一次。ICCV的热度一直以来都与CVPR不相上下,屡创新高在今天的开幕式上,ICCV官方公布了今年的论文数据:本届ICCV共有8068篇投稿,其中有2160篇被接收,录用率为26.8%,略高于上一届ICCV2021的录用率25.9%在论文主题方面,官方也公布了相关数据:多视角和传感器的3D技术热度最高在今天的开

AI技术在蚂蚁集团保险业务中的应用:革新保险服务,带来全新体验AI技术在蚂蚁集团保险业务中的应用:革新保险服务,带来全新体验Sep 20, 2023 pm 10:45 PM

保险行业对于社会民生和国民经济的重要性不言而喻。作为风险管理工具,保险为人民群众提供保障和福利,推动经济的稳定和可持续发展。在新的时代背景下,保险行业面临着新的机遇和挑战,需要不断创新和转型,以适应社会需求的变化和经济结构的调整近年来,中国的保险科技蓬勃发展。通过创新的商业模式和先进的技术手段,积极推动保险行业实现数字化和智能化转型。保险科技的目标是提升保险服务的便利性、个性化和智能化水平,以前所未有的速度改变传统保险业的面貌。这一发展趋势为保险行业注入了新的活力,使保险产品更贴近人民群众的实际

复旦大学团队发布中文智慧法律系统DISC-LawLLM,构建司法评测基准,开源30万微调数据复旦大学团队发布中文智慧法律系统DISC-LawLLM,构建司法评测基准,开源30万微调数据Sep 29, 2023 pm 01:17 PM

随着智慧司法的兴起,智能化方法驱动的智能法律系统有望惠及不同群体。例如,为法律专业人员减轻文书工作,为普通民众提供法律咨询服务,为法学学生提供学习和考试辅导。由于法律知识的独特性和司法任务的多样性,此前的智慧司法研究方面主要着眼于为特定任务设计自动化算法,难以满足对司法领域提供支撑性服务的需求,离应用落地有不小的距离。而大型语言模型(LLMs)在不同的传统任务上展示出强大的能力,为智能法律系统的进一步发展带来希望。近日,复旦大学数据智能与社会计算实验室(FudanDISC)发布大语言模型驱动的中

百度文心一言全面向全社会开放,率先迈出重要一步百度文心一言全面向全社会开放,率先迈出重要一步Aug 31, 2023 pm 01:33 PM

8月31日,文心一言首次向全社会全面开放。用户可以在应用商店下载“文心一言APP”或登录“文心一言官网”(https://yiyan.baidu.com)进行体验据报道,百度计划推出一系列经过全新重构的AI原生应用,以便让用户充分体验生成式AI的理解、生成、逻辑和记忆等四大核心能力今年3月16日,文心一言开启邀测。作为全球大厂中首个发布的生成式AI产品,文心一言的基础模型文心大模型早在2019年就在国内率先发布,近期升级的文心大模型3.5也持续在十余个国内外权威测评中位居第一。李彦宏表示,当文心

致敬TempleOS,有开发者创建了启动Llama 2的操作系统,网友:8G内存老电脑就能跑致敬TempleOS,有开发者创建了启动Llama 2的操作系统,网友:8G内存老电脑就能跑Oct 07, 2023 pm 10:09 PM

不得不说,Llama2的「二创」项目越来越硬核、有趣了。自Meta发布开源大模型Llama2以来,围绕着该模型的「二创」项目便多了起来。此前7月,特斯拉前AI总监、重回OpenAI的AndrejKarpathy利用周末时间,做了一个关于Llama2的有趣项目llama2.c,让用户在PyTorch中训练一个babyLlama2模型,然后使用近500行纯C、无任何依赖性的文件进行推理。今天,在Karpathyllama2.c项目的基础上,又有开发者创建了一个启动Llama2的演示操作系统,以及一个

快手黑科技“子弹时间”赋能亚运转播,打造智慧观赛新体验快手黑科技“子弹时间”赋能亚运转播,打造智慧观赛新体验Oct 11, 2023 am 11:21 AM

杭州第19届亚运会不仅是国际顶级体育盛会,更是一场精彩绝伦的中国科技盛宴。本届亚运会中,快手StreamLake与杭州电信深度合作,联合打造智慧观赛新体验,在击剑赛事的转播中,全面应用了快手StreamLake六自由度技术,其中“子弹时间”也是首次应用于击剑项目国际顶级赛事。中国电信杭州分公司智能亚运专班组长芮杰表示,依托快手StreamLake自研的4K3D虚拟运镜视频技术和中国电信5G/全光网,通过赛场内部署的4K专业摄像机阵列实时采集的高清竞赛视频,

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software