<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: koshin takeuchi</title>
    <description>The latest articles on DEV Community by koshin takeuchi (@koshin).</description>
    <link>https://dev.to/koshin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2006841%2F903a0cd7-fe8a-4f19-bca0-0d7a77645f55.jpeg</url>
      <title>DEV Community: koshin takeuchi</title>
      <link>https://dev.to/koshin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/koshin"/>
    <language>en</language>
    <item>
      <title>Optimizing LLM with Few Shot</title>
      <dc:creator>koshin takeuchi</dc:creator>
      <pubDate>Sat, 31 Aug 2024 10:45:48 +0000</pubDate>
      <link>https://dev.to/koshin/optimizing-llm-with-few-shot-5dhd</link>
      <guid>https://dev.to/koshin/optimizing-llm-with-few-shot-5dhd</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwu8tjvgu9d1zz4bm4vl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuwu8tjvgu9d1zz4bm4vl.jpg" alt="An example of Few Shot learning using Chat GPT" width="800" height="546"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hello 👋&lt;br&gt;
I'd like to introduce Few-Shot learning, which is one of the basic and powerful technique for large language model!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Few Shot
&lt;/h2&gt;

&lt;p&gt;Few-Shot learning is a technique in prompt engineering that allows you to optimize the responses generated by large language models (LLM) for specific tasks by adding a few examples within the context.&lt;/p&gt;

&lt;p&gt;In the first image, you can see that using Few-Shot has changed it from Zero-Shot, and that it has been optimized for specific tasks such as “color and food type” and “introduction to emoji”.&lt;/p&gt;

&lt;p&gt;According to the paper “Language Models are Few-Shot Learners”&lt;sup id="fnref1"&gt;1&lt;/sup&gt;, the larger the model, the more effective it is to use it. Incidentally, in this paper, the definition of Few-Shot learning is given as giving 10 to 100 shots to match the context window (prompt to be input to LLM) of GPT-3.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcwxlcu4oku60uognod71.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcwxlcu4oku60uognod71.png" alt="This graph shows that the more extensive the LLM model, the more effective Few-Shot learning becomes" width="800" height="383"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;from "Language Models are Few-Shot Learners"&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Difference from fine-tuning
&lt;/h2&gt;

&lt;p&gt;When you hear the phrase “optimizing AI models”, you may think of fine-tuning. In fact, fine-tuning often achieves higher performance in benchmark tests.&lt;br&gt;
However, it is necessary to make trade-offs with many conditions.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fine-tuning requires several thousand to several hundred thousand labeled training data.&lt;/li&gt;
&lt;li&gt;It requires a lot of money. When using a service like the fully managed OpenAI API, the price is often higher than for a normal request. Also, when using a custom AI model, fine-tuning requires a lot of GPU resources because it involves recalculating the weights of the neural network to suit the task.&lt;/li&gt;
&lt;li&gt;The possibility of using out-of-distribution generalization or spurious features in the training data is higher than with Few-Shot learning.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The OpenAI article also recommends that if you want to perform optimization, you should first consider few-shot learning, and then consider fine-tuning.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae63s25bdl9l37i8r66p.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fae63s25bdl9l37i8r66p.png" alt="Steps to consider when optimizing a LLM" width="800" height="407"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;from &lt;a href="https://platform.openai.com/docs/guides/optimizing-llm-accuracy/llm-optimization-context" rel="noopener noreferrer"&gt;https://platform.openai.com/docs/guides/optimizing-llm-accuracy/llm-optimization-context&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You was able to learn about how to optimize using &lt;strong&gt;Few-Shot learning&lt;/strong&gt; and how to proceed when using it.&lt;br&gt;
I hope this article will help you optimize your LLM.&lt;br&gt;
Thank you for reading!&lt;/p&gt;




&lt;ol&gt;

&lt;li id="fn1"&gt;
&lt;p&gt;&lt;a href="https://arxiv.org/abs/2005.14165" rel="noopener noreferrer"&gt;https://arxiv.org/abs/2005.14165&lt;/a&gt; ↩&lt;/p&gt;
&lt;/li&gt;

&lt;/ol&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>promptengineering</category>
    </item>
  </channel>
</rss>
