<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0"><channel><title><![CDATA[Few Shot Learning in Public]]></title><description><![CDATA[This is where I am posting my learning in public about Machine Learning, LLMs, and the rest of this wild new wave of AI systems.]]></description><link>https://www.fewshotlearning.co</link><image><url>https://substackcdn.com/image/fetch/$s_!C45b!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc756204-5170-438c-9656-91fb1496891c_500x500.jpeg</url><title>Few Shot Learning in Public</title><link>https://www.fewshotlearning.co</link></image><generator>Substack</generator><lastBuildDate>Wed, 06 May 2026 11:54:39 GMT</lastBuildDate><atom:link href="https://www.fewshotlearning.co/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[KBall]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[fewshotlearning@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[fewshotlearning@substack.com]]></itunes:email><itunes:name><![CDATA[KBall]]></itunes:name></itunes:owner><itunes:author><![CDATA[KBall]]></itunes:author><googleplay:owner><![CDATA[fewshotlearning@substack.com]]></googleplay:owner><googleplay:email><![CDATA[fewshotlearning@substack.com]]></googleplay:email><googleplay:author><![CDATA[KBall]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Shifting from models to applications]]></title><description><![CDATA[I&#8217;ve neglected publishing here for the last year or so, but during that time the focus of my learning about machine learning has shifted from a focus on understanding models, and in particular large language models and towards how to build useful applications using those models.]]></description><link>https://www.fewshotlearning.co/p/shifting-from-models-to-applications</link><guid isPermaLink="false">https://www.fewshotlearning.co/p/shifting-from-models-to-applications</guid><dc:creator><![CDATA[KBall]]></dc:creator><pubDate>Sun, 03 Mar 2024 18:59:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!rVQQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I&#8217;ve neglected publishing here for the last year or so, but during that time the focus of my learning about machine learning has shifted from a focus on understanding models, and in particular large language models and towards how to build useful applications using those models.<br><br>This distinction is one that is very deliberately burry in a lot of the marketing about AI. People talk about ChatGPT, Claude, or Gemini and they speak as if this is all a single model. But really the model is a component in a larger architecture - perhaps a central component, but a component nonetheless.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rVQQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rVQQ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rVQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp" width="1024" height="1024" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:443458,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/webp&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!rVQQ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 424w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 848w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 1272w, https://substackcdn.com/image/fetch/$s_!rVQQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b7c7f3a-51e9-437e-bc6a-2996b4aacb01_1024x1024.webp 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">DALL-E generated image for a diagram with an LLM in the center</figcaption></figure></div><p>Some of the other elements that go into an LLM-based application include</p><ol><li><p>Some sort of structured user interface and organization for interaction. In the chat-focused applications above this is usually the concept of a thread of messages.</p></li><li><p>A set of (sometimes interacting) prompts and pipes between different information. In <a href="https://www.youtube.com/watch?v=v5tRc_5-8G4">a YouTube video about Gemini reasoning about user intent</a>, they break down that responding to a single user interaction involves an entire workflow with several decision steps. Each of those steps is either an algorithmic process or an interaction with a model, resulting in some structured or unstructured information that gets taken to the next step.</p></li><li><p>Often some sort of structured/known data source that can be searched and fed in as context</p></li><li><p>Often some sort of conceptual &#8220;memory&#8221; and way to keep track of what has already happened.</p></li></ol><p></p><h2>Emerging AI Architectures</h2><p>Fleshing these out a little bit, there are two big architectural patterns that have emerged for building applications around LLMs: Retrieval Augmented Generation (RAG) and Agents.</p><p>A few points about each:</p><h2>Retrieval Augmented Generation</h2><ul><li><p>Core architecture for layering proprietary/domain knowledge into chat interaction.</p></li><li><p>Essential mental model:</p><ul><li><p>Use query/prompt to have LLM generate a search</p></li><li><p>Load relevant documents from search</p></li><li><p>Use documents + initial prompt as context to LLM to generate response</p></li></ul></li><li><p>Stereotypical example: &#8220;Chat with this project&#8217;s documentation&#8221;</p></li></ul><p>There&#8217;s a <a href="https://blog.langchain.dev/deconstructing-rag/">great article on the langchain blog</a> that goes deeper into how RAG works and the different elements of it.</p><p>Some of the benefits of using RAG:</p><ul><li><p>It&#8217;s a relatively straightforward way to create a unique and valuable chat/textual interaction</p></li><li><p>Can work &#8220;globally&#8221; (e.g. All customers search these documents) or &#8220;locally&#8221; (e.g. we search content from your specific documents)</p></li><li><p>It has &#8220;better&#8221; factuality / reduced hallucinations</p></li><li><p>There&#8217;s a reduced dependency (relative to fine tuning or other mechanisms to customize) on training data</p></li><li><p>Can link to / directly reference source material. </p></li></ul><p>That last one is key for building traceability and the ability to verify factuality into an AI application. Because the model has no concept of &#8220;truth&#8221; and (at least in today&#8217;s generations) no way to trace back the source material for any particular thing that was generated, having a way to connect (outside the LLM) to the original source is the only way I have found where you can create true traceability &amp; ability to verify factuality.</p><h2>Generative Agents</h2><ul><li><p>Architecture for creating evolving system.</p></li><li><p>Core components</p><ul><li><p>Memory stream</p></li><li><p>Reflection/summarization</p></li><li><p>Planning</p></li></ul></li><li><p>Stereotypical example: AI-based game characters that learn and evolve</p></li></ul><p>One of the classic examples of using a generative agent is in <a href="https://arxiv.org/pdf/2304.03442.pdf">this academic research paper</a> that explores an entire game filled with characters that learn, evolve, and interact.</p><p>Variations on agentic approaches are being attempted all over, but most of the well-published examples (e.g. <a href="https://github.com/muellerberndt/mini-agi">Mini-AGI</a>) demo well but break down quickly in production.</p><p>Some of the benefits of Generative Agents are they</p><ul><li><p>Can learn and improve behavior over time (even without model changes)</p></li><li><p>Maintain history of previous interactions</p><p></p></li></ul><h2>The Application Layer is the frontier for LLMs</h2><p>At this point the power of the big LLM foundation models is very well established, but what feels much more unproven is how to build actual useful and valuable applications with them.</p><p>The most successful examples so far have been coding assistants (Which follow a variation on RAG &#8212; super interesting conversation around this in <a href="https://www.latent.space/p/sourcegraph">this podcast</a>) and summarization assistants for meetings.</p><p>Outside of those, there have been a few niche consumer successes like <a href="https://www.chatpdf.com/">ChatPDF</a>  or <a href="https://photoai.com/">PhotoAI</a> but much of the world still feels like it is grappling with how to use LLMs effectively, with as many <a href="https://arstechnica.com/tech-policy/2024/02/air-canada-must-honor-refund-policy-invented-by-airlines-chatbot/">epic failures</a> as successes.</p><p>There&#8217;s a lot to learn and figure out here&#8230; if you&#8217;re reading this and curious, one least thing you might be interested in is joining the AI in Action discussion group that happens weekly organized as a part of <a href="https://www.latent.space/">Latent Space</a>. You can find that (and other events like ML focused paper clubs) at the<a href="https://lu.ma/ls"> Latent Space Luma</a>.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Few Shot Learning in Public! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Few Shot Learning in Public! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://www.fewshotlearning.co/subscribe?"><span>Subscribe now</span></a></p><p></p>]]></content:encoded></item><item><title><![CDATA[Thinking about Latent Space]]></title><description><![CDATA[I think one of the most powerful ways for thinking about what an LLM is actually doing is this concept of a "Latent Space". What is a latent space? Here's...]]></description><link>https://www.fewshotlearning.co/p/thinking-about-latent-space</link><guid isPermaLink="false">https://www.fewshotlearning.co/p/thinking-about-latent-space</guid><dc:creator><![CDATA[KBall]]></dc:creator><pubDate>Wed, 10 May 2023 13:31:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WVj1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I think one of the most powerful ways for thinking about what an LLM is actually doing is this concept of a "Latent Space".</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WVj1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WVj1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WVj1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg" width="768" height="768" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:768,&quot;width&quot;:768,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:150600,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!WVj1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 424w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 848w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!WVj1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcd514d54-9fe4-4f83-b49b-eaa4f500d3c1_768x768.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Image generated by stable diffusion with the prompt &#8220;3d visualization of &#8216;latent space&#8217;&#8221;</figcaption></figure></div><p>What is a latent space? Here's a description from Chat-GPT (that yes, checks out with what I've learned)</p><blockquote><p>Latent space refers to an abstract space that represents a compressed or hidden representation of complex data, often high-dimensional data such as images, videos, or sound. In machine learning, the term is frequently used in the context of generative models, such as autoencoders and variational autoencoders, where a latent space is learned by mapping the high-dimensional input data to a lower-dimensional latent space.</p><p>In this lower-dimensional latent space, the data is represented in a more compact and meaningful way, allowing for easier manipulation, exploration, and generation of new data. The latent space is often designed to have desirable properties, such as continuity and smoothness, that make it possible to interpolate between different points in the space, and generate novel data that follows the underlying distribution of the original data.</p></blockquote><p><em>*Interestingly, this was one example where GPT-3.5 did better than GPT-4. The GPT-4 answer got bogged down in too many details and examples and didn't do a great job of explaining the core concept.</em></p><h3>Describing an LLM using the concept of Latent Space</h3><p>Conceptually, an LLM is doing a few things. Breaking it down using a transformer model (as I explored in <a href="https://www.fewshotlearning.co/p/trying-to-understand-transformer">https://www.fewshotlearning.co/p/trying-to-understand-transformer</a>) the LLM does the following:</p><ol><li><p>Transform from a set of language tokens into a token-based "embedding" or latent space of word concepts. </p></li><li><p>Use this word-based representation plus a positional vector as input to the encoder side of our transformer, which transforms the chunk of token-based embeddings into a location in a different (language concept based? phrase based?) latent space. I'll tentatively describe the vectors that describe a position in this latent space as "concept vectors".</p></li><li><p>The decoder then is essentially applying a mapping function, trained over a large amount of data, to move from the position in latent space described by the current content vector to the <em>next most likely</em> position in latent space, as described by our current position plus a single token. This mapping function is part of what has been trained over all of the millions of documents of training data.</p></li><li><p>The token is output, and the decoder us run again with it and all previous output tokens added to the input until it generates the next token. Steps 3 and 4 are applied iteratively until you reach a stop point.</p><p></p></li></ol><p>One way we might conceptualize what has happened as language models have grown is that they have both gotten a much more detailed "latent space", and a much more precise mapping function.</p><p>All of the exercises in prompt tuning are about setting up the right starting position in latent space. "Think step by step, cite your sources" is moving us to a part of the latent space where the language outputted includes breaking things down into steps and adding source links.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RGgh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RGgh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 424w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 848w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 1272w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RGgh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png" width="728" height="491.8918918918919" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:850,&quot;width&quot;:1258,&quot;resizeWidth&quot;:728,&quot;bytes&quot;:775417,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!RGgh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 424w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 848w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 1272w, https://substackcdn.com/image/fetch/$s_!RGgh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5c82c3a9-1f11-4a1e-b75f-f91aa094cc1c_1258x850.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">A visualization of a function mapping from one place to another in an abstract space. Such as might happen by prompting an LLM to &#8220;Think step by step&#8221;.</figcaption></figure></div><h3>Implications for what LLMs are and aren&#8217;t good at</h3><p>The latent space encodes both <em>linguistic patterns</em> and <em>knowledge</em>, captured by the training data. This is what allows an LLM like GPT-4 to not only handle language tasks, but to share and explore knowledge about the world.</p><p>However understanding the core model is a key concept. The LLM is mapping over a space that is purely derived from language. When we see LLMs reproducing what we might describe as higher order reasoning, they're not doing it the same way we might do so. We use language as an <em>interface</em> to other types of mental models, but for LLMs language is all there is.</p><p>It's hard to reason about what this means in the abstract, so let's look at an example.</p><h3>An example using logical reasoning</h3><p>One of the interesting emergent properties evident in the latest LLMs is the emergence of what appears to be logical reasoning. Especially when we prompt the LLM with something like "<a href="https://arxiv.org/abs/2201.11903">chain of thought prompting</a>", the LLM appears to be able to reason logically.</p><p><strong>I don't believe that there is an embodied concept of reasoning</strong>, but rather that there is an area of latent space along some dimensions of the concept vector that captures the parts of the training data that look like logical reasoning. If you are able to move the model into that part of the space, it will reproduce what looks like logical reasoning.</p><p>The fidelity of that logical reasoning is still somewhat suspect. Sometimes it works, sometimes it doesn't. </p><p>GPT-4 is way better than prior models at it, but still gets things wrong pretty frequently. </p><p>And I think that is related to this difference in what is happening. The LLM doesn't have an underlying representation of a logical model or logical reasoning that it can somehow "check its work" against. It has instead a high-dimensional vector space that has some number of dimensions that represent "logical-like" arguments, and a mapping function that attempts to reproduce those.</p><h3>Implications for LLMs as general purpose agents.</h3><p>I think this comes to a core limitation of LLMs as "general purpose" agents.</p><p>Humans use language as an interface to attempt to communicate about other underlying models. Using the logic example, there is a relatively straightforward model for how logic works that can be described as a relatively simple set of rules. When we talk about logical problems, we are mapping between particular situations (described using language) and that underlying logical model.</p><p>LLMs have no such underlying logical model. They have <em>linguistic</em> model. By training it with very large numbers of logical examples, it can get to pretty high fidelity on reproducing what looks like logic, but it both is <em>inefficient</em> in that representation relative to our simpler rule-based model, and <strong>it will tend to fail in places where small linguistic changes imply large logical changes</strong>.</p><h3>Does this imply LLMs <em>cannot</em> derive these underlying models?</h3><p>I'm not sure that I'm willing to go that far. There is definitely <a href="https://openreview.net/forum?id=DeG07_TcZvT">research showing the abilities of these models to represent underlying rules and state</a> when properly trained.</p><p>However, it seems pretty clear with the current generation of LLMs that they have <em>not</em> managed to derive an underlying logical model, or they wouldn't fall victim to the types of mistakes they do now. And OpenAI's Sam Altman <a href="https://techcrunch.com/2023/04/14/sam-altman-size-of-llms-wont-matter-as-much-moving-forward/">seems to be indicating that we've reached the end of gains</a> to be made simply by scaling up models.</p><p>It's possible that we'll be able to train <a href="https://www.latent.space/p/multimodal-gpt4">multi-modal models</a> that address this by training on many different types of data. Apparently GPT-4 can do this to some extent with images &amp; text (but that has not been released to the public generally, leading me to believe it's got a lot of edge cases and issues and needs to be pretty carefully constrained)</p><p>Instead, I think it would point to a future that looks much more like the latter half of that article: multiple models wrapped up inside of applications, where large numbers of domain-specific models are integrated together with some sort of interface layer.</p><p>In other words, a lot like our existing AI world. Except what LLMs <em>do</em> provide is an <em>extremely</em> powerful interface layer, where we can ask for what we want using natural language, and it can interpret that natural language to understand what model is likely to be the best at answering our question.</p><h3>Looking towards the future</h3><p>I'm using this mental framework for a few different things. </p><p>First, to try to better understand what LLMs are and more importantly <em>are not</em> going to be good at themselves. I'll flesh this out in future posts, but I think a broad way of thinking about this is that the better a domain is modeled by language, the better an LLM will do at it. And the more small linguistic changes mean big domain changes, the worse an LLM will do. </p><p>A quick example is around asking for statistics - when asking an LLM about the world (say what percentage of people have anxiety disorders), the difference between 21% and 42% is extremely small linguistically, but makes a massive difference in our model of the world.</p><p>Second, to think about how to integrate LLMs into applications. I'm looking strongly at things I do using text, and trying to figure out applications take advantage of the LLM strong understanding of text to make my processes better.</p><p>Third, to try to understand what our risks are of some sort of "True AGI", with either utopian or dystopian outcomes. There's a lot of very smart people who are concerned here, but based on what we've seen here I think the LLM advancements are not a massive acceleration in the danger curve. </p><p>They have provided a step-function increase in our ability to parse and do things with natural language, which is an extremely powerful general-purpose technology, and now there is a tremendous excitement and rush of people figuring out now ways to apply this technology. That creates a massive excitement, lots of new people and money jumping into AI, and probably <em>does</em> increase the likelihood and speed at which we'll arrive at something that looks like AGI. </p><p>But I see no evidence that LLMs themselves have put us near to that, and the projections of "AGI in the next 5 years" are IMO pure hyperbole.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Few Shot Learning in Public! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div><p></p>]]></content:encoded></item><item><title><![CDATA[Trying to understand Transformer Models]]></title><description><![CDATA[The fundamental breakthrough that appears to have led to the current &#8220;Cambrian Explosion&#8221; around language models was the invention of the Transformer architecture.]]></description><link>https://www.fewshotlearning.co/p/trying-to-understand-transformer</link><guid isPermaLink="false">https://www.fewshotlearning.co/p/trying-to-understand-transformer</guid><dc:creator><![CDATA[KBall]]></dc:creator><pubDate>Sat, 06 May 2023 23:50:03 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!adZI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>The fundamental breakthrough that appears to have led to the current &#8220;<a href="https://twitter.com/karpathy/status/1654892810590650376">Cambrian Explosion</a>&#8221; around language models was the invention of the Transformer architecture. If I&#8217;m understanding it properly, this new way of arranging neural networks dramatically simplified the way we represent contextual information about how a word fits in a sentence, allowing us to encode it in some vectors that can be passed along, which in turn allows these models to take what was once a serial process and parallelize it, running many tokens in parallel at once.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!adZI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!adZI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!adZI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!adZI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!adZI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!adZI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg" width="512" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:512,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:82092,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!adZI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!adZI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!adZI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!adZI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb2e25aaf-6a37-4421-a149-c0fee933d8a2_512x512.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Stable Diffusion generated image for &#8216;Transformers inside of a computer&#8217;</figcaption></figure></div><p>This huge efficiency gain allowed much much larger models to be trained much more rapidly, and as model size has gone up, there have been <a href="https://swizec.com/blog/eight-things-to-know-about-llms/">both predictable improvements </a><em><a href="https://swizec.com/blog/eight-things-to-know-about-llms/">and</a></em><a href="https://swizec.com/blog/eight-things-to-know-about-llms/"> surprising emergent capabilities</a>.</p><p>So now I&#8217;m trying to understand what these transformer models are and how they work. Here&#8217;s what I&#8217;ve got so far; if you&#8217;re reading this and anything doesn&#8217;t sound right please let me know.</p><h3>Transformer Models</h3><p>The <a href="https://papers.nips.cc/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf">original paper</a> that introduced the approach is pretty dense, and I found myself reading it multiple times to try to understand what different parts mean. I've found <a href="https://jalammar.github.io/illustrated-transformer/">https://jalammar.github.io/illustrated-transformer/</a> to be the most useful resource to transformer models so far. It is phenomenal, go and read it, it will likely do better than I will in explaining this.</p><p>Here's how I'm understanding it: Transformer models have two core pieces, an encoder and a decoder. The encoder's job is to start with an input vector representing a series of tokens, and passes it through a series of steps to attempt to "encode" the relationships between those tokens. These encoded values are stored in three vectors (called the 'query', 'key', and 'value' vectors). The decoder then uses these vector representations to predict new symbols, one at a time.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!FFA_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!FFA_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 424w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 848w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 1272w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!FFA_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png" width="1218" height="793" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:793,&quot;width&quot;:1218,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:127812,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!FFA_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 424w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 848w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 1272w, https://substackcdn.com/image/fetch/$s_!FFA_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28005176-1d47-4a6e-b1e0-763a42a97e2f_1218x793.png 1456w" sizes="100vw"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Image from https://jalammar.github.io/illustrated-transformer/ showing a simplified explanation of how transformers work</figcaption></figure></div><h3>Encoders</h3><p>The encoder is a stack of identical layers. In the original introduction of the approach, the stack size was 6 layers, though it doesn't seem like that is a "magic" number and it's entirely possible different models might use a different number of layers.</p><p>Each layer of the encoder is a feed-forward neural network combined with a 'self-attention layer'. For the first layer it takes in the embedding of your text (essentially a mapping of the original words into a numerical vector space) as the input, while each subsequent layer uses the output of the previous layer as its input.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5TEd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5TEd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 424w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 848w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 1272w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5TEd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png" width="792" height="411" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:411,&quot;width&quot;:792,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:32628,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!5TEd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 424w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 848w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 1272w, https://substackcdn.com/image/fetch/$s_!5TEd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1ddd38a7-8c8c-4e3a-9e2b-939ee781b3b6_792x411.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Image from https://jalammar.github.io/illustrated-transformer/ showing a simplified explanation of an encoder layer</figcaption></figure></div><p>The self-attention layer takes the vector input and transforms it in three ways using 3 matrices to create 3 new vectors. The value of the matrices are generated as a part of training. For those familiar with other neural network based models, one of these vectors is the direct output of this network layer (called the 'query' in articles about the transformer architecture) while the other two represent hidden state from the neural network (and are called the 'key' and 'value' vectors).</p><p>These vectors give a way for the model to understand as it analyzes each symbol (probably a word), the importance of any of the other symbols in the sentence.</p><p>For example, if you have a sentence that looks like "I petted my cat and she was very happy", this will allow the model to represent the relevance of "my cat" when analyzing the word "she".</p><p>One of the key advances of the transformer model was creating these (relatively) simple representations of how information moves forward from one step to the next through the model, which allows relatively fast computation of a large number of words in parallel. This encoder step essentially turns into a series of wide vector multiplications, which is why GPUs (and TPUs) are the core underlying processing technology that lets these drive forward.</p><p>However, because words are run in parallel, the model needs a mechanism to capture their position in the input sentence. This is done using a 'positional' encoding, which is a vector that is computed based on the position of the symbol/word, and added to the word embedding vector before it is processed by the self-attention vector. There have been several proposed positional functions that have been tried in different approaches. The important characteristics of this function are that it generates unique values for each position, and that it is easy to understand "relative" positioning (ie the functions vary continuously based on position). During training, the model will then be able to incorporate these values in its training.</p><h3>Decoders</h3><p>The decoder phase is pretty similar to the encoder phase, consisting of a set of stacked layers with attention layers and feed-forward neural networks. The difference is that in a decoder, there are two attention layers before the neural network. The first attention layer is fed any symbols already generated by the transformer. In the first time point, this may be an empty vector, but as it generates symbols these become the "prompt" for each additional step. The second attention layer takes the output of this empty vector and incorporates the "key" and "value" vectors generated by the encoder phases. This allows the model to incorporate all context from the original prompt.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!taEG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!taEG!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 424w, https://substackcdn.com/image/fetch/$s_!taEG!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 848w, https://substackcdn.com/image/fetch/$s_!taEG!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 1272w, https://substackcdn.com/image/fetch/$s_!taEG!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!taEG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png" width="416" height="261" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/50dc9820-053a-40ff-a907-f50851615dc8_416x261.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:261,&quot;width&quot;:416,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:20635,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!taEG!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 424w, https://substackcdn.com/image/fetch/$s_!taEG!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 848w, https://substackcdn.com/image/fetch/$s_!taEG!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 1272w, https://substackcdn.com/image/fetch/$s_!taEG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F50dc9820-053a-40ff-a907-f50851615dc8_416x261.png 1456w" sizes="100vw" loading="lazy"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Image from https://jalammar.github.io/illustrated-transformer/ showing a simplified explanation of a decoder layer.</figcaption></figure></div><p>Multiple of these decoders are then stacked. At each layer beyond the first, the input is the output of the previous layer, but the "key" and "value" vectors from the encoder are applied in the same way, allowing every layer of the model to incorporate the encoded prompt.</p><p>At the top of the stack, the vector output is run through a process called 'output projection" which consists of very wide linear layer that maps back from the fixed vector size of the transformer into a vector the size of the token library (in English this might be every possible word). This new vector is normalized to a probability distribution, and a single predicted symbol is output (either the most probable, or through some other sampling methodology). Now that you have a new token in the output, the entire decoder stack is run again, with that token (and all previously predicted tokens) as the new input.</p><h3>Creating your own models</h3><p>If you're creating your own model, these core "encoder" and "decoder" abstractions are available in standard machine learning libraries such as pytorch and tensorflow. As much as I wanted to know what they were doing, to use them we can treat them as black boxes. </p><h3>Embedding</h3><p>One more key concept needed to understand how these things are working under the hood.</p><p>Before and after these phases, we need to do some sort of translation between the original form of the input data (human language for a large language model) and the vector representation these models understand. This is done via 'embedding', which is a term used to describe the mapping of any form of input into a vector space. In the case of words, this maps from the series of free text inputs into a vector of continuously varying number values.</p><p>There are a variety of embedding algorithms out there, but some of the goals of a good embedding algorithm are to capture semantic similarity (two words with similar meanings should result in similar values in the embedding space) and to have lower dimensionality than raw text (in fact as low a dimension as possible so we can pack the most meaning into a single vector operation)</p><p>These embeddings algorithms are themselves often machine learning models that have been trained on a wide range of data.</p><p>OpenAI exposes embedding directly as an API. There are also a variety of other options - <a href="https://python.langchain.com/en/latest/modules/models/text_embedding.html">Langchain includes models for interacting with 13 different embedding approaches</a> as of this writing. If I'm understanding things correctly, for large language models typically these consist of a word/token level embedding added to a positional embedding (to let the model understand where a token is relative to the tokens around it).</p><p>Embeddings are the "translation" layer between human language and these deep learning models that are the engines of LLMs like GPT-3 and GPT-4.</p><h3>Next steps</h3><p>I&#8217;m not sure I need to dig any deeper on transformers themselves; I like having an understanding of how things work, but I&#8217;m more interested in applications than in building new models. Next week I&#8217;ll be digging into building my first LLM-based application using LangChain.<br><br>As always, if something in this article doesn&#8217;t match your knowledge or understanding, please let me know! And send me any recommended reading or listening to help me learn faster.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Few Shot Learning in Public! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Dimensions for thinking about AI Model applicability]]></title><description><![CDATA[I was listening to the 2nd episode of the Latent Space podcast, and really loved the way Varun Mohan from Codeium broke down some dimensions for thinking about LLMs, or models in general, and how they need to work in different domains.]]></description><link>https://www.fewshotlearning.co/p/dimensions-for-thinking-about-ai</link><guid isPermaLink="false">https://www.fewshotlearning.co/p/dimensions-for-thinking-about-ai</guid><dc:creator><![CDATA[KBall]]></dc:creator><pubDate>Fri, 05 May 2023 16:42:57 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!RL-O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I was listening to the <a href="https://www.latent.space/p/varun-mohan">2nd episode of the Latent Space podcast</a>, and really loved the way Varun Mohan from Codeium broke down some dimensions for thinking about LLMs, or models in general, and how they need to work in different domains.</p><p>In particular, he laid out the dimensions of latency, quality, and correctability.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RL-O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RL-O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RL-O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg" width="512" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:512,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:96651,&quot;alt&quot;:&quot;A cube graph with what looks like spiderwebs running through it&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="A cube graph with what looks like spiderwebs running through it" title="A cube graph with what looks like spiderwebs running through it" srcset="https://substackcdn.com/image/fetch/$s_!RL-O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!RL-O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F347cb490-158e-4cf4-822d-fccfc831bb4f_512x512.jpeg 1456w" sizes="100vw" fetchpriority="high"></picture><div class="image-link-expand"><div class="pencraft pc-display-flex pc-gap-8 pc-reset"><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container restack-image"><svg role="img" width="20" height="20" viewBox="0 0 20 20" fill="none" stroke-width="1.5" stroke="var(--color-fg-primary)" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><g><title></title><path d="M2.53001 7.81595C3.49179 4.73911 6.43281 2.5 9.91173 2.5C13.1684 2.5 15.9537 4.46214 17.0852 7.23684L17.6179 8.67647M17.6179 8.67647L18.5002 4.26471M17.6179 8.67647L13.6473 6.91176M17.4995 12.1841C16.5378 15.2609 13.5967 17.5 10.1178 17.5C6.86118 17.5 4.07589 15.5379 2.94432 12.7632L2.41165 11.3235M2.41165 11.3235L1.5293 15.7353M2.41165 11.3235L6.38224 13.0882"></path></g></svg></button><button tabindex="0" type="button" class="pencraft pc-reset pencraft icon-container view-image"><svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-maximize2 lucide-maximize-2"><polyline points="15 3 21 3 21 9"></polyline><polyline points="9 21 3 21 3 15"></polyline><line x1="21" x2="14" y1="3" y2="10"></line><line x1="3" x2="10" y1="21" y2="14"></line></svg></button></div></div></div></a><figcaption class="image-caption">Blog image generated using Stable Diffusion with prompt &#8220;three dimensional cube graph with an artificial intelligence in the background&#8221;</figcaption></figure></div><p></p><p>These dimensions form axes that may vary in importance based on the domain. By manipulating them, we can tailor our approach to meet the specific needs of a given situation. Interestingly, latency and quality tend to have a direct trade-off in the model creation process. If you can't lower the latency to achieve the quality you need, you might need to institute some latency hiding techniques. Correctability, on the other hand, is linked to the model's intended use and how it's integrated into a user experience.</p><p>To think about this, let&#8217;s flesh out how these axes might play out in a few different current hot AI domains.</p><h3><strong>Code Generation</strong></h3><p>In the realm of code generation, particularly when integrated into an editor, the priority is to maintain a low latency. You need to avoid disrupting the user's flow, similar to how a fast compile/reload/test cycle prevents the loss of mental context waiting for newly coded material to be tested. The same principle applies to codegen, where a swift prompt/output cycle allows for a higher level of cognitive engagement with the functions being written.</p><p>Quality is of moderate importance here. If it's more challenging to compile generated code than the code I wrote myself, the tool is not adding value. However, it can still provide significant value even if it's only effective for relatively boilerplate cases.</p><p>Correctability feels like a lever you can play with. The more your quality goes up the less correctability you'll need. Correctability in code is high if it is suggesting small changes directly in your editor. The larger the blocks that are generated at once and the more steps that are automated (e.g. creating full pull requests), the harder it is to correct.</p><h3><strong>Writing Blog Posts</strong></h3><p>When it comes to blog post writing, latency is only moderately important. If it takes five minutes to generate a draft post, that's still significantly faster than my current writing pace.</p><p>Quality is important to me, but it's a sliding scale. If the output quality is too low, the model is not useful. But above a certain threshold, the higher the quality, the less editing I have to do.</p><p>Correctability is the key factor in this domain. I wouldn't want to use a model that pushes content directly from generation to publication. Instead, I prefer a model that generates a draft I can review and edit.</p><p>I used ChatGPT to help me with drafting this post, going from bullet points to a first draft, but it required substantial editing before I was happy with it. I would be terrified of an approach that pushed articles directly from a model to publication.</p><h3><strong>Learning</strong></h3><p>In learning scenarios, latency is important up to a point. A real-time question-answer cycle can create an exploratory flow, similar to the flow in coding.</p><p>Quality is paramount here. We want to ensure the information we're learning is accurate.</p><p>Correctability can be challenging in this domain. How do we know if what we've learned needs to be corrected?</p><p>I think the learning usecase introduces the need for an additional dimension&#8212;'traceability' or 'verifiability'. </p><h3>Verifiability</h3><p>When using models for learning new concepts or facts, it's crucial to validate with independent sources to ensure we're learning something factual, not confabulated by the machine. For this usecase (and probably for others), we need some way to understand how the model generated its output, and a way to validate it.</p><p>Using "Cite your sources" in the prompt with GPT-4 seems to work reasonably well for this, at least in some topic areas. It worked remarkably well for me when I was learning about foundation models, as it pointed me to actual papers that substantiated the summaries provided by chatGPT. However, it fell short when I was trying to explore mental health outcome data&#8212;the model made up some numbers, and then made up some sources. The sources did not actually exist. However this at least let me know not to trust the info it had given me.</p><h3>Working through some examples</h3><p>For example, we can use this to evaluate search as a domain. We&#8217;ve seen initial stumbles here (bing chat coming to mind), and one way we can think of this is that in search, we need latency, correctness, and verifiability. Especially when we&#8217;re searching for factual things. But current language models are poor at having high latency and high correctness at the same time, and they are not particularly good at verifiability. This indicates that applying these directly to replace search will be difficult.</p><p>Similarly taking an example from an OpenAI plugin, ordering plane tickets online using a chatbot. In this case latency may not be super important, but quality and correctability are key. And correctability may even supercede quality because when I'm spending money on plane tickets even if I get the best possible answer, it may be that the price is beyond what I'm willing to spend, and I need to correct it. There's also multiple dimensions of "quality" (price, time, connections) that I may want to optimize for, and which dimension I want to choose may vary as I see the possibilities.</p><p>Does this imply we shouldn&#8217;t use a chatbot for ordering plane tickets? Not necessarily, but we&#8217;ll need to build in lots of affordances (whether directly through chat or as an additional step) that allow for correcting the generated response before spending money.</p><h3>Moving forward</h3><p>Right now one of the biggest challenges in the AI space is understanding what the edges are. What will these machines be good at, and what won&#8217;t they?<br><br>We have some fundamentally new capabilities available to us, how can we use those to create new products and services that will make our lives better?</p><p>I don&#8217;t think we&#8217;ve got that anywhere closed to mapped out, but these dimensions provide a lens for thinking about new possible domains for AI. As we consider them, we can use the dimensions of latency, quality, correctness, and possibly verifiability to determine what constraints we have on our building, and if the tools we have available will be a good fit at all.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="SubscribeWidgetToDOM"><div class="subscription-widget show-subscribe"><div class="preamble"><p class="cta-caption">Thanks for reading Few Shot Learning in Public! Subscribe for free to receive new posts and support my work.</p></div><form class="subscription-widget-subscribe"><input type="email" class="email-input" name="email" placeholder="Type your email&#8230;" tabindex="-1"><input type="submit" class="button primary" value="Subscribe"><div class="fake-input-wrapper"><div class="fake-input"></div><div class="fake-button"></div></div></form></div></div>]]></content:encoded></item><item><title><![CDATA[Learning in public about LLMs and AI]]></title><description><![CDATA[I&#8217;m deep diving down the LLM and AI rabbit hole, and taking inspiration from the one and only swyx, I&#8217;m going to learn in public. This substack is intended to document my progress, share my learnings, and give plenty of opportunities for folks who know more to correct me and push me in better directions.]]></description><link>https://www.fewshotlearning.co/p/coming-soon</link><guid isPermaLink="false">https://www.fewshotlearning.co/p/coming-soon</guid><dc:creator><![CDATA[KBall]]></dc:creator><pubDate>Fri, 05 May 2023 15:26:55 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!C45b!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc756204-5170-438c-9656-91fb1496891c_500x500.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>I&#8217;m deep diving down the LLM and AI rabbit hole, and taking inspiration from the one and only <a href="https://twitter.com/swyx">swyx</a>, I&#8217;m going to <a href="https://www.swyx.io/learn-in-public">learn in public</a>. This substack is intended to document my progress, share my learnings, and give plenty of opportunities for folks who know more to correct me and push me in better directions.<br><br>Subscribe to follow along and learn with me, but regardless don&#8217;t hesitate to reply or send me notes telling me I&#8217;m wrong, pointing me in new directions, or otherwise helping in this learning journey.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://www.fewshotlearning.co/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://www.fewshotlearning.co/subscribe?"><span>Subscribe now</span></a></p>]]></content:encoded></item></channel></rss>