Difference between revisions of "In-Context Learning (ICL)"

From
Jump to: navigation, search
(Created page with "{{#seo: |title=PRIMO.ai |titlemode=append |keywords=artificial, intelligence, machine, learning, models, algorithms, data, singularity, moonshot, Tensorflow, Google, Nvidia, M...")
 
m
 
(75 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
|title=PRIMO.ai
 
|title=PRIMO.ai
 
|titlemode=append
 
|titlemode=append
|keywords=artificial, intelligence, machine, learning, models, algorithms, data, singularity, moonshot, Tensorflow, Google, Nvidia, Microsoft, Azure, Amazon, AWS  
+
|keywords=ChatGPT, artificial, intelligence, machine, learning, GPT-4, GPT-5, NLP, NLG, NLC, NLU, models, data, singularity, moonshot, Sentience, AGI, Emergence, Moonshot, Explainable, TensorFlow, Google, Nvidia, Microsoft, Azure, Amazon, AWS, Hugging Face, OpenAI, Tensorflow, OpenAI, Google, Nvidia, Microsoft, Azure, Amazon, AWS, Meta, LLM, metaverse, assistants, agents, digital twin, IoT, Transhumanism, Immersive Reality, Generative AI, Conversational AI, Perplexity, Bing, You, Bard, Ernie, prompt Engineering LangChain, Video/Image, Vision, End-to-End Speech, Synthesize Speech, Speech Recognition, Stanford, MIT |description=Helpful resources for your journey with artificial intelligence; videos, articles, techniques, courses, profiles, and tools
|description=Helpful resources for your journey with artificial intelligence; videos, articles, techniques, courses, profiles, and tools  
+
 
 +
<!-- Google tag (gtag.js) -->
 +
<script async src="https://www.googletagmanager.com/gtag/js?id=G-4GCWLBVJ7T"></script>
 +
<script>
 +
  window.dataLayer = window.dataLayer || [];
 +
  function gtag(){dataLayer.push(arguments);}
 +
  gtag('js', new Date());
 +
 
 +
  gtag('config', 'G-4GCWLBVJ7T');
 +
</script>
 
}}
 
}}
[https://www.youtube.com/results?search_query=Generative+AI YouTube]
+
[https://www.youtube.com/results?search_query=In+context+Learning+LLM YouTube]
[https://www.quora.com/search?q=Generative%20AI ... Quora]
+
[https://www.quora.com/search?q=In%20context%20Learning%20LLM ... Quora]
[https://www.google.com/search?q=Generative+AI ...Google search]
+
[https://www.google.com/search?q=In+context+Learning+LLM ...Google search]
[https://news.google.com/search?q=Generative+AI ...Google News]
+
[https://news.google.com/search?q=In+context+Learning+LLM ...Google News]
[https://www.bing.com/news/search?q=Generative+AI&qft=interval%3d%228%22 ...Bing News]
+
[https://www.bing.com/news/search?q=In+context+Learning+LLM%3d%228%22 ...Bing News]
  
* [[Generative AI]] ... [[Conversational AI]] ... [[OpenAI]]'s [[ChatGPT]] ... [[Perplexity]] ... [[Microsoft]]'s [[Bing]] ... [[You]] ...[[Google]]'s [[Bard]] ... [[Baidu]]'s [[Ernie]]
+
* [[Perspective]] ... [[Context]] ... [[In-Context Learning (ICL)]] ... [[Transfer Learning]] ... [[Out-of-Distribution (OOD) Generalization]]
* [[Capabilities]]  
+
* [[Causation vs. Correlation]] ... [[Autocorrelation]] ...[[Convolution vs. Cross-Correlation (Autocorrelation)]]  
** [[Video/Image]] ... [[Vision]] ... [[Colorize]] ... [[Image/Video Transfer Learning]]
+
* [[Artificial General Intelligence (AGI) to Singularity]] ... [[Inside Out - Curious Optimistic Reasoning| Curious Reasoning]] ... [[Emergence]] ... [[Moonshots]] ... [[Explainable / Interpretable AI|Explainable AI]] ...  [[Algorithm Administration#Automated Learning|Automated Learning]]
** [[End-to-End Speech]] ... [[Synthesize Speech]] ... [[Speech Recognition]]  
+
* [[What is Artificial Intelligence (AI)? | Artificial Intelligence (AI)]] ... [[Generative AI]] ... [[Machine Learning (ML)]] ... [[Deep Learning]] ... [[Neural Network]] ... [[Reinforcement Learning (RL)|Reinforcement]] ... [[Learning Techniques]]
* [[Discriminative vs. Generative]]
+
* [[Conversational AI]] ... [[ChatGPT]] | [[OpenAI]] ... [[Bing/Copilot]] | [[Microsoft]] ... [[Gemini]] | [[Google]] ... [[Claude]] | [[Anthropic]] ... [[Perplexity]] ... [[You]] ... [[phind]] ... [[Grok]] | [https://x.ai/ xAI] ... [[Groq]] ... [[Ernie]] | [[Baidu]] ... [[DeepSeek]]
* [[Assistants]]  ... [[Agents]]  ... [[Negotiation]] ... [[Hugging_Face#HuggingGPT|HuggingGPT]] ... [[LangChain]]
+
* [[Large Language Model (LLM)]] ... [[Natural Language Processing (NLP)]]  ...[[Natural Language Generation (NLG)|Generation]] ... [[Natural Language Classification (NLC)|Classification]] ... [[Natural Language Processing (NLP)#Natural Language Understanding (NLU)|Understanding]] ... [[Language Translation|Translation]] ... [[Natural Language Tools & Services|Tools & Services]]
 +
* [[Chain of Thought (CoT)]]  ... [[Chain of Thought (CoT)#Tree of Thoughts (ToT)|Tree of Thoughts (ToT)]]
 +
* [[Learning Techniques]]
 +
* [[Few Shot Learning]]
 +
* [https://arxiv.org/abs/2301.00234 A Survey on In-context Learning | Q. Dong, L. Li, D. Dai, C. Zheng, Z. Wu, B. Chang, X. Sun, J. Xu, L. Li, Z. Sui - arXiv Cornell University]
 
* [https://en.wikipedia.org/wiki/Context-based_learning Context-based learning | Wikipedia]
 
* [https://en.wikipedia.org/wiki/Context-based_learning Context-based learning | Wikipedia]
 +
* [https://medium.com/@atmabodha/how-does-gpt-do-in-context-learning-5f37866813dc How does GPT do in-context learning? | Kushal Shah - Medium]
 +
* [https://thegradient.pub/in-context-learning-in-context/ In Context | Daniel Bashir - The Gradient]
 +
* [https://www.marktechpost.com/2023/07/14/think-like-this-and-answer-me-this-ai-approach-uses-active-prompting-to-guide-large-language-models/ Think Like this and Answer Me: This AI Approach Uses Active Prompting to Guide Large Language Models | Ekrem Çetinkaya - MarketTechPost]
 +
* [https://towardsdatascience.com/in-context-learning-approaches-in-large-language-models-9c0c53b116a1 In-Context Learning Approaches in Large Language Models | Javaid Nabi - Towards Data Science - Medium] ... Simple and powerful techniques to make LLMs learn new tasks at inference time
 +
 +
 +
In-context[[context]] learning (ICL) is a paradigm in [[Natural Language Processing (NLP)]] where [[Large Language Model (LLM)]] make predictions based on [[context]]s augmented with just a few training examples. [[Large Language Model (LLM)|LLM]]s are able to extract patterns from the examples provided in the [[context]] and use them to perform many complex [[Natural Language Processing (NLP)|NLP]] tasks. - [https://theglobalnlplab.substack.com/p/in-context-learning-a-new-paradigm In-context Learning - A New Paradigm in NLP? | The Global NLP Lab]
 +
 +
 +
 +
<hr><center><b>
 +
 +
Why can LLMs learn to do something entirely new by merely being shown a few input-output examples?
 +
 +
</b>
 +
Prompt: Given the criteria for determining whether something is true or false, based on whether or not it is found in the sky. <br>
 +
bird is true, plane is true, car is false, truck is false, <br>
 +
is train true or false?
 +
</center><hr>
 +
 +
 +
 +
= Tips =
 +
 +
* <b>Use relevant and informative examples</b>. The examples you provide to the model should be relevant to the task you want it to learn, and they should be informative enough for the model to learn from.
 +
* <b>Provide a variety of examples</b>. The more varied the examples you provide, the better the model will be able to generalize to new data.
 +
* <b>Use clear and concise prompts</b>. The prompts you give to the model should be clear and concise, and they should accurately reflect the task you want the model to perform.
 +
* <b>Experiment with different prompt formats</b>. There is no one-size-fits-all prompt format for ICL. Experiment with different formats to see what works best for your task and model.
 +
* <b>Use a powerful computer</b>. ICL can be computationally expensive, so it is important to use a powerful computer to train and deploy ICL models.
 +
* <b>Use demonstrations that are similar to the target task</b>. This will help the model to learn the task more quickly and efficiently.
 +
* <b>Use a small number of demonstrations</b>. A small number of well-chosen demonstrations can be more effective than a large number of irrelevant demonstrations.
 +
* <b>Use demonstrations that are representative of the target data distribution</b>. This will help the model to generalize to new data more effectively.
 +
* <b>Use a pre-trained model</b>. Pre-trained models have already learned a lot about the world, which can give them a head start on learning new tasks using ICL.
 +
 +
= Why is ICL exciting? =
 +
* [https://lastweekin.ai/p/how-in-context-learning-emerges How In-Context Learning Emerges | Jacky Liang - Last Week in AI] ... [[Large Language Model (LLM)|LLM]]s have been able to do something more powerful: learn new tasks and skills simply from new examples in the input, without any gradient updates or changes to the pretrained model.
 +
 +
In-context learning has enormous potential to unlock more flexible, general, and human-like intelligence in AI systems. Some reasons it is generating so much interest:
 +
 +
* <b>Versatility</b> - With ICL, a single model can learn a wide variety of skills at the same time, instead of needing separate training for each one.
 +
 +
* <b>Generalization</b> - ICL allows models to learn underlying rules and patterns from just a few examples, and generalize them to new situations.
 +
 +
* <b>Efficiency</b> - No lengthy or costly re-training of models is needed. Skills can be acquired instantly.
 +
 +
* <b>Accessibility</b> - ICL enables AI systems that can be taught by everyday users through simple demonstrations of the task.
 +
 +
In short, ICL enables LLMs to become powerful systems that can continually learn, reason, and adapt to new tasks.
 +
 +
 +
= Mystery: Why does ICL work so well? =
 +
* [http://ai.stanford.edu/blog/understanding-incontext/ How does in-context learning work? A framework for understanding the differences from traditional supervised learning | Sang Michael Xie and Sewon Min - The Stanford AI Lab Blog]
 +
 +
There have been a few studies aiming to uncover this in the literature.
 +
 +
* One factor that might play a role is the distribution of the training data. When training on a very large dataset, the ICL ability of [[Large Language Model (LLM)|LLM]]s seems to emerge when the data appears in clusters and there are a sufficient number of rare classes present.
 +
 +
* Another factor is that [[Transformer]] models might be learning to encode learning algorithms implicitly during the training process, due to the properties of their architecture. During inference, transformer [[Large Language Model (LLM)|LLM]]s might be performing an implicit [[finetuning]] using the provided examples in the [[context]].
 +
 +
In-[[context]] learning works well because it allows users to quickly build models for a new use case without worrying about [[fine-tuning]] and storing new parameters for each task. It typically requires very few training examples to get a prototype working, and the natural language interface is intuitive even for non-experts. [https://ai.stanford.edu/blog/understanding-incontext/  How does in-context learning work? A framework for understanding the differences from traditional supervised learning | Sang Michael Xie and Sewon Min - The Stanford AI Lab]
 +
 +
 +
<img src="https://ai.stanford.edu/blog/assets/img/posts/2022-08-01-understanding-incontext/images/image11.gif" width="900">
 +
 +
 +
<youtube>BCAagkgDy9U</youtube>
 +
<youtube>n4HR4_j_xS8</youtube>
 +
<youtube>pC4zRb_5noQ</youtube>
 +
<youtube>XV1RXLPIVlw</youtube>
 +
<youtube>dCkQQYwPxdM</youtube>
 +
<youtube>7GikRXc6Y-8</youtube>
 +
 +
= Pretraining vs [[Fine-tuning]] vs In-context Learning (ICL) of LLM =
 +
[https://www.youtube.com/results?search_query=Pretraining+Fine+tuning+In+context+Learning+LLM YouTube]
 +
[https://www.quora.com/search?q=Pretraining%20Fine%20tuning%20In%20context%20Learning%20LLM ... Quora]
 +
[https://www.google.com/search?q=Pretraining+Fine+tuning+In+context+Learning+LLM ...Google search]
 +
[https://news.google.com/search?q=Pretraining+Fine+tuning+In+context+Learning+LLM ...Google News]
 +
[https://www.bing.com/news/search?q=Pretraining+Fine+tuning+In+context+Learning+LLM%3d%228%22 ...Bing News]
 +
 +
* [https://medium.com/@atmabodha/pre-training-fine-tuning-and-in-context-learning-in-large-language-models-llms-dd483707b122 Pre-training, fine-tuning and in-context learning in Large Language Models (LLMs) | Kushal Shah - Medium]
 +
 +
 +
 +
<table style="border-collapse: collapse;">
 +
  <tr>
 +
    <th style="border-bottom: 1px solid black;">Method</th>
 +
    <th style="border-bottom: 1px solid black;">Description</th>
 +
  </tr>
 +
  <tr>
 +
    <td style="border-bottom: 1px solid black;"><b>Pretraining</b></td>
 +
    <td style="border-bottom: 1px solid black;">... training a model on a large dataset to learn general language patterns. This is usually done using an unsupervised or self-supervised objective such as predicting the next word in a sequence.</td>
 +
  </tr>
 +
  <tr>
 +
    <td style="border-bottom: 1px solid black;"><b>[[Fine-tuning]]</b></td>
 +
    <td style="border-bottom: 1px solid black;">... taking a pretrained model and further training it on a smaller dataset specific to a particular task. This allows the model to adapt to the specific task while still leveraging the general language patterns learned during pretraining.</td>
 +
  </tr>
 +
  <tr>
 +
    <td style="border-bottom: 1px solid black;"><b>In-context learning (ICL)</b></td>
 +
    <td style="border-bottom: 1px solid black;">... involves using a pretrained model to make predictions based on [[context]]s augmented with just a few training examples. The model is able to extract patterns from the examples provided in the [[context]] and use them to perform many complex NLP tasks without any additional training.</td>
 +
  </tr>
 +
</table>
 +
 +
 +
<youtube>_FYwnO_g-4E</youtube>
 +
 +
= <span id="In-context Reinforcement Learning"></span>In-context Reinforcement Learning =
 +
[https://www.youtube.com/results?search_query=In+context+Reinforcement+Learning YouTube]
 +
[https://www.quora.com/search?q=In%20context%20Reinforcement%20Learning ... Quora]
 +
[https://www.google.com/search?q=In+context+Reinforcement+Learning ...Google search]
 +
[https://news.google.com/search?q=In+context+Reinforcement+Learning ...Google News]
 +
[https://www.bing.com/news/search?q=In+context+Reinforcement+Learning%3d%228%22 ...Bing News]
 +
 +
* [[Reinforcement Learning (RL)]]
 +
* [[Agents]] ... [[Robotic Process Automation (RPA)|Robotic Process Automation]] ... [[Assistants]] ... [[Personal Companions]] ... [[Personal Productivity|Productivity]] ... [[Email]] ... [[Negotiation]] ... [[LangChain]]
 +
* [https://arxiv.org/abs/2210.14215 In-context Reinforcement Learning with Algorithm Distillation | M. Laskin, L. Wang, J. Oh, E. Parisotto, S. Spencer, R. Steigerwald, DJ Strouse, S. Hansen, A. Filos, E. Brooks, M. Gazeau, H. Sahni, S. Singh, V. Mnih - arXiv - Cornell University]
 +
  
In-context learning (ICL) is a new paradigm in natural language processing (NLP) where large language models (LLMs) make predictions based on contexts augmented with just a few training examples1. LLMs are able to extract patterns from the examples provided in the context and use them to perform many complex NLP tasks. - [https://theglobalnlplab.substack.com/p/in-context-learning-a-new-paradigm In-context Learning - A New Paradigm in NLP? | The Global NLP Lab]
+
<youtube>OkmSC2J0two</youtube>
 +
<youtube>akeUVn6WQoU</youtube>

Latest revision as of 05:06, 30 January 2025

YouTube ... Quora ...Google search ...Google News ...Bing News


In-contextcontext learning (ICL) is a paradigm in Natural Language Processing (NLP) where Large Language Model (LLM) make predictions based on contexts augmented with just a few training examples. LLMs are able to extract patterns from the examples provided in the context and use them to perform many complex NLP tasks. - In-context Learning - A New Paradigm in NLP? | The Global NLP Lab



Why can LLMs learn to do something entirely new by merely being shown a few input-output examples?

Prompt: Given the criteria for determining whether something is true or false, based on whether or not it is found in the sky.
bird is true, plane is true, car is false, truck is false,
is train true or false?



Tips

  • Use relevant and informative examples. The examples you provide to the model should be relevant to the task you want it to learn, and they should be informative enough for the model to learn from.
  • Provide a variety of examples. The more varied the examples you provide, the better the model will be able to generalize to new data.
  • Use clear and concise prompts. The prompts you give to the model should be clear and concise, and they should accurately reflect the task you want the model to perform.
  • Experiment with different prompt formats. There is no one-size-fits-all prompt format for ICL. Experiment with different formats to see what works best for your task and model.
  • Use a powerful computer. ICL can be computationally expensive, so it is important to use a powerful computer to train and deploy ICL models.
  • Use demonstrations that are similar to the target task. This will help the model to learn the task more quickly and efficiently.
  • Use a small number of demonstrations. A small number of well-chosen demonstrations can be more effective than a large number of irrelevant demonstrations.
  • Use demonstrations that are representative of the target data distribution. This will help the model to generalize to new data more effectively.
  • Use a pre-trained model. Pre-trained models have already learned a lot about the world, which can give them a head start on learning new tasks using ICL.

Why is ICL exciting?

In-context learning has enormous potential to unlock more flexible, general, and human-like intelligence in AI systems. Some reasons it is generating so much interest:

  • Versatility - With ICL, a single model can learn a wide variety of skills at the same time, instead of needing separate training for each one.
  • Generalization - ICL allows models to learn underlying rules and patterns from just a few examples, and generalize them to new situations.
  • Efficiency - No lengthy or costly re-training of models is needed. Skills can be acquired instantly.
  • Accessibility - ICL enables AI systems that can be taught by everyday users through simple demonstrations of the task.

In short, ICL enables LLMs to become powerful systems that can continually learn, reason, and adapt to new tasks.


Mystery: Why does ICL work so well?

There have been a few studies aiming to uncover this in the literature.

  • One factor that might play a role is the distribution of the training data. When training on a very large dataset, the ICL ability of LLMs seems to emerge when the data appears in clusters and there are a sufficient number of rare classes present.
  • Another factor is that Transformer models might be learning to encode learning algorithms implicitly during the training process, due to the properties of their architecture. During inference, transformer LLMs might be performing an implicit finetuning using the provided examples in the context.

In-context learning works well because it allows users to quickly build models for a new use case without worrying about fine-tuning and storing new parameters for each task. It typically requires very few training examples to get a prototype working, and the natural language interface is intuitive even for non-experts. How does in-context learning work? A framework for understanding the differences from traditional supervised learning | Sang Michael Xie and Sewon Min - The Stanford AI Lab



Pretraining vs Fine-tuning vs In-context Learning (ICL) of LLM

YouTube ... Quora ...Google search ...Google News ...Bing News


Method Description
Pretraining ... training a model on a large dataset to learn general language patterns. This is usually done using an unsupervised or self-supervised objective such as predicting the next word in a sequence.
Fine-tuning ... taking a pretrained model and further training it on a smaller dataset specific to a particular task. This allows the model to adapt to the specific task while still leveraging the general language patterns learned during pretraining.
In-context learning (ICL) ... involves using a pretrained model to make predictions based on contexts augmented with just a few training examples. The model is able to extract patterns from the examples provided in the context and use them to perform many complex NLP tasks without any additional training.


In-context Reinforcement Learning

YouTube ... Quora ...Google search ...Google News ...Bing News