HackerPapers

arXiv:2212.10559cs.CL

Why Can GPT Learn In-Context? Language Models Implicitly Perform Gradient Descent as Meta-Optimizers

Damai Dai, Yutao Sun, Li Dong, Yaru Hao, Shuming Ma, Zhifang Sui, Furu Wei

Abstract

Large pretrained language models have shown surprising in-context learning (ICL) ability. With a few demonstration input-label pairs, they can predict the label for an unseen input without parameter updates. Despite the great success in performance, its working mechanism still remains an open question. In this paper, we explain language models as meta-optimizers and understand in-context learning as implicit finetuning. Theoretically, we figure out that Transformer attention has a dual form of gradient descent. On top of it, we understand ICL as follows: GPT first produces meta-gradients according to the demonstration examples, and then these meta-gradients are applied to the original GPT to build an ICL model. We comprehensively compare the behaviors of in-context learning and explicit finetuning on real tasks to provide empirical evidence that supports our understanding. Experimental results show that in-context learning behaves similarly to explicit finetuning from multiple perspectives. Inspired by the dual form between Transformer attention and gradient descent, we design a momentum-based attention by analogy with gradient descent with momentum. The improved performance over vanilla attention further supports our understanding from another perspective, and more importantly, shows the potential to utilize our understanding for future model design. The code is available at \url{https://aka.ms/icl}.

arXiv comments
Accepted to ACL 2023 findings
Journal reference
DOI
Subjects
cs.CLComputation and Language

On Hacker News

Linked by 14 identifiable commenters in 26 comments across 22 threads, from Jan 2023 to Jul 2024. Found in 1 HN submission from Dec 2022 to Dec 2022. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments22 threads

    • That's false. It has been shown that LLMs can perform e.g. gradient descent internally [1], which can explain why they are so good at few shot prompting. The universal approximation theorem already tells us that a single layer is sufficient to approximate any function, so it…

      sigmoid10View on HNParent context

    • I can’t provide an example as I would rather not jeopardise my employment and livelihood. The domain is actually novel, is not a subdomain in any way whatsoever unless you consider “next token prediction” to be the class of all possible problems that LLMs may be used for. As for…

      PartiallyTypedView on HNParent context

    • >but they can only reason using their memories and the prompt. Eh no. https://arxiv.org/abs/2212.10559 >But if you try very hard you can find "held out" data and when you test on it, GPT4 stops looking so smart: This can be done to anybody. This can be done to you. It's not a…

      famouswafflesView on HNParent context

    • For those who don't completely get the impact of this: We already know Large Language Models (LLMs) can learn at runtime (ie, separately to the training process.) This is called "In Context Learning". See [1], [2] for more details. (BTW, when anyone says "LLMs are stochastic…

      nlView on HNParent context

    • > The “learning” in “In context learning” is not the same concept as learning during the network “training”. The former is loosely named and does not have any impact on what’s actually “learned” by the model. Actually (and very surprisingly!) it is related. See the "Similarity…

      nlView on HNParent context

  1. Saying Goodbye to GitHub 1 comment
    • The relevant keyword you want is "zero-shot learning". (EDIT: Correction; "in-context learning". Sorry for that.) LLMs can pick up patterns from the context window purely at evaluation time using dynamic reinforcement learning. (This is one of those capabilities models seem to…

      FeepingCreatureView on HNParent context

    • No there is reasoning in LLMs. This is actually proven through several scientific papers. I can't say whether it's using reasoning for specific answers. I'm sure many times it just regurgitates something that is known... But saying that LLMs in general can and do reason is…

      Herval_freireView on HNParent context

    • I think there is an issue in vocabulary size though. If I'm correct in thinking that the OP is proposing that what Llama does ("Notably, we split all numbers into individual digits") explicitly this allows the model to treat a number as a sequence of digits so it can learn how…

      nlView on HNParent context

    • The idea that updating weights is particularly necessary is questionable. Memory augmented llms are computationally universal. https://arxiv.org/abs/2301.04589 and make no mistake, in context learning can be used in a meaningful way to resolve deficiencies. gpt-3 getting 98.5%…

      famouswafflesView on HNParent context

    • >> LLMs have no knowledge of the underlying reality > They have no common sense & they can't plan their answer If his arguments are entirely based on this, then it's not fully correct: - GPT style language models try to build a model of the world…

      HervalFreireView on HNParent context

    • I don't think that's clear at all. https://arxiv.org/abs/2212.10559 shows a LLM is doing gradient descent on the context window at inference time. If it's learning relationships between concepts at runtime based on information in the context window then it seems about as useful…

      nlView on HNParent context

    • In context learning is already implicit finetuning. https://arxiv.org/abs/2212.10559. It's very questionable to what extent continuous training is necessary past a threshold of intelligence. Memory Augmented Large Language Models are Computationally Universal…

      famouswafflesView on HNParent context

    • > We know how LLMs work and they auto-complete text. This isn't true. See eg[1] It seems to be a common misconception that the training objective "predict the next word" implies something about the capabilities of a LLM. As [1[] shows, instead they perform very sophisticated…

      nlView on HNParent context

    • - GPT style language models try to build a model of the world: https://arxiv.org/abs/2210.13382 - GPT style language models end up internally implementing a mini "neural network training algorithm" (gradient descent fine-tuning for given examples)…

      HervalFreireView on HNParent context

    • - GPT style language models try to build a model of the world: https://arxiv.org/abs/2210.13382 - GPT style language models end up internally implementing a mini "neural network training algorithm" (gradient descent fine-tuning for given examples)…

      HervalFreireView on HNParent context

  2. GPT-4 1 comment
    • > I must have missed the part when it started doing anything algorithmically. Yeah. "Why Can GPT Learn In-Context? Language Models Secretly Perform Gradient Descent as Meta-Optimizers" https://arxiv.org/abs/2212.10559 @dang there's something weird about this URL in HN. It has 35…

      nlView on HNParent context

    • I didn't agree with the OP but just noting this is wrong: > These nets regurgitate the most average possible output given inputs. By definition. You seem to be confusing the training objective with the capabilities. For example: > Why Can GPT Learn In-Context? Language Models…

      nlView on HNParent context

    • Bingo. There’s a recent paper that posits language models are meta learners where the transformer layer is approximating stochastic gradient descent updates from the inputs—this is what allows them to perform in-context learning. [1] If that’s true, then it is going to be…

      cgearhartView on HNParent context

    • - GPT style language models try to build a model of the world: https://arxiv.org/abs/2210.13382 - GPT style language models end up internally implementing a mini "neural network training algorithm" (gradient descent fine-tuning for given examples)…

      kilgnadView on HNParent context

    • - GPT style language models try to build a model of the world: https://arxiv.org/abs/2210.13382 - GPT style language models end up internally implementing a mini "neural network training algorithm" (gradient descent fine-tuning for given examples)…

      kilgnadView on HNParent context

    • I saw this paper’s abstract and was reminded of your comment: https://arxiv.org/abs/2212.10559 > Experimentally, we comprehensively compare the behavior of ICL and explicit finetuning based on real tasks to provide empirical evidence that supports our understanding

      l33t233372View on HNParent context

    • The answer to this is: "we don't really know as its a very complex function automatically discovered by means of slow gradient descent, and we're still finding out" Here are some of the fun things we've found out so far: - GPT style language models try to build a model of the…

      spionView on HNParent context

  3. A GPT in 60 Lines of NumPy 1 comment
    • I thought you were asking about attention only transformers. This paper touches on some of it https://arxiv.org/abs/2212.10559v2.

      adamnemecekView on HNParent context

    • 1. I don't understand how LLMs work. 2. I don't understand how ChatGPT works, but I have used it a few times. 3. I will use ChatGPT as the absolute measure of what LLMs are capable of. --- 1. I don't understand intelligence. 2. Humans are intelligent, humans can learn to do…

      dhruvdhView on HNParent context

    • With transformer-based model, their inner-state is a deterministic function (the features encoded by the Neural Networks weights) applied to the text-generated up-until the current-time step, so it's relatively easy to know what they currently have in mind. For example if the…

      GistNoesisView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.