<?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[Decoding Coding]]></title><description><![CDATA[Deconstructing concepts from Computer Science & Technology]]></description><link>https://decodingcoding.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!XJ7x!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F73df595b-097e-48aa-bc16-9722ac73b8cd_400x400.png</url><title>Decoding Coding</title><link>https://decodingcoding.substack.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 05 Jun 2026 05:28:24 GMT</lastBuildDate><atom:link href="https://decodingcoding.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Prathmesh Deshpande]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[decodingcoding@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[decodingcoding@substack.com]]></itunes:email><itunes:name><![CDATA[Prathmesh Deshpande]]></itunes:name></itunes:owner><itunes:author><![CDATA[Prathmesh Deshpande]]></itunes:author><googleplay:owner><![CDATA[decodingcoding@substack.com]]></googleplay:owner><googleplay:email><![CDATA[decodingcoding@substack.com]]></googleplay:email><googleplay:author><![CDATA[Prathmesh Deshpande]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[Issue #3: Model Context Protocol]]></title><description><![CDATA[Week 3: 4th April 2025 - 10th April 2025]]></description><link>https://decodingcoding.substack.com/p/issue-3-model-context-protocol</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/issue-3-model-context-protocol</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Fri, 11 Apr 2025 01:00:57 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!l7zl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Week 3: 4th April 2025 - 10th April 2025</p><h3>{Article: Model Context Protocol}</h3><p><a href="https://modelcontextprotocol.io/introduction">(Source)</a></p><p>So there&#8217;s been a lot of noise about MCP. I saw many claims that it was basically AGI and completely useless. So I decided to read up on it straight from the source. No explainers, no blogs, no videos. </p><p>Here are my notes:</p><div><hr></div><p>(If you want just a high-level overview, I made a diagram)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!l7zl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!l7zl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 424w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 848w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 1272w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!l7zl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png" width="527" height="399.5934065934066" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1104,&quot;width&quot;:1456,&quot;resizeWidth&quot;:527,&quot;bytes&quot;:684224,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/png&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:&quot;https://decodingcoding.substack.com/i/160834010?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" title="" srcset="https://substackcdn.com/image/fetch/$s_!l7zl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 424w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 848w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 1272w, https://substackcdn.com/image/fetch/$s_!l7zl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F099ca734-ebbd-4bd7-bbcd-c6c2eb8a54cc_3280x2486.png 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></figure></div><h3>{Code}</h3><p>I also wrote a minimal implementation of an MCP server here:</p><p><a href="https://github.com/Prathmesh2498/MCP-Practice">https://github.com/Prathmesh2498/MCP-Practice</a></p><div><hr></div><ul><li><p>The most useful thing to separate fluff from the real stuff is the definition given on the first page, first para:</p><p><em>MCP is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications. Just as USB-C provides a standardized way to connect your devices to various peripherals and accessories, MCP provides a standardized way to connect AI models to different data sources and tools.</em></p></li><li><p>The most important part to focus on in MCP is P. It&#8217;s a protocol &#8212; a standardized way to feed data into an LLM. </p></li><li><p>The easiest use case of this is if your LLM is independent of your data ingester, you can plug and play LLMs into your app and see which one works best. What enables this? &#8212; standardization, i.e. protocol.</p></li><li><p>They mention 3 core components that make up MCP:</p><ul><li><p>Protocol Layer: The protocol layer handles message framing, request/response linking, and high-level communication patterns.</p></li><li><p>Transport Layer: Either Stdio or HTTP over SSE</p><p>(<em>Server-Sent Events (SSE) is a method for pushing data from a server to a client over an HTTP connection, enabling real-time updates without the need for constant polling.</em>)</p></li><li><p>Messages: Can be Requests, Results, Errors or One-way Notifications. <br>One-way here means a notification that expects no response, can be sent from either the client or the server.</p></li></ul></li><li><p>The Client-Server will use these to initiate a 3-way handshake:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DBl-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DBl-!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 424w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 848w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 1272w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DBl-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png" width="368" height="323.96065573770494" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:537,&quot;width&quot;:610,&quot;resizeWidth&quot;:368,&quot;bytes&quot;:27637,&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;:&quot;https://decodingcoding.substack.com/i/160834010?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!DBl-!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 424w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 848w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.png 1272w, https://substackcdn.com/image/fetch/$s_!DBl-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fca5e6f34-e41f-4d57-9e96-8e8926cd66b7_610x537.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></figure></div><ul><li><p>Resources are a core primitive in the Model Context Protocol (MCP) that allow servers to expose data and content that can be read by clients and used as context for LLM interactions &#8212; like files, DB data, API responses, media, etc.</p></li><li><p>Prompts enable servers to define reusable prompt templates and workflows that clients can easily surface to users and LLMs. They provide a powerful way to standardize and share common LLM interactions. &#8212; Basically things we want to do over and over will be done via predefined prompts, it has a well-defined structure, and you can discover them from the prompt/list endpoint. <br>For example:</p><pre><code>{
  name: Reality Check;
  description: Forgot to code without LLMs; 
  arguments?: [              
    {
      name: Error;
      description?: Just paste the error dummy;
      required?: True
    }
  ]
}</code></pre></li><li><p>The response will contain the well-defined prompt with the error that you feed to the LLM.<br></p></li><li><p>Tools are functions -_-</p><pre><code>@app.list_tools()
async def list_tools() -&gt; list[types.Tool]:
    return [
        types.Tool(
            name="calculate_sum",
            description="Add two numbers together",
            inputSchema={
                "type": "object",
                "properties": {
                    "a": {"type": "number"},
                    "b": {"type": "number"}
                },
                "required": ["a", "b"]
            }
        )
    ]

@app.call_tool()
async def call_tool(
    name: str,
    arguments: dict
) -&gt; list[types.TextContent | types.ImageContent | types.EmbeddedResource]:
    if name == "calculate_sum":
        a = arguments["a"]
        b = arguments["b"]
        result = a + b
        return [types.TextContent(type="text", text=str(result))]
    raise ValueError(f"Tool not found: {name}")</code></pre></li><li><p>Sampling allows the server to ask completions from the LLM. <br>I did not understand the use case of this, but here&#8217;s something I found on a DigitalOcean Blog. <br>[&#8230;] <em>while clients maintain the authority to decline potentially malicious requests or limit resource usage. This approach is valuable in scenarios where clients interact with unfamiliar servers that still require access to intelligent capabilities. <a href="https://www.digitalocean.com/community/tutorials/model-context-protocol#the-components-of-mcp?ref=prathmesh6.substack.com">(Source)</a></em><br>If you know of any specific use cases here, let me know!</p></li><li><p>Roots are soft boundaries (defined as URIs) which the client can send to the server. One thing that seems useful is prioritizing operations for resources within roots compared those outside the roots. </p></li></ul><div><hr></div><h3><strong>{Return}</strong></h3><p>I hope you enjoyed this newsletter. Let me know if you have any feedback.</p><p>Next week &#2346;&#2369;&#2344;&#2381;&#2361;&#2366; &#2349;&#2375;&#2335;&#2370;!</p><h4></h4>]]></content:encoded></item><item><title><![CDATA[Issue #3: On Passkeys, Kafka Internals, Textshop, etc.]]></title><description><![CDATA[[System Design: Passkeys For Passwordless Authentication]]]></description><link>https://decodingcoding.substack.com/p/issue-3-on-passkeys-kafka-internals</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/issue-3-on-passkeys-kafka-internals</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Sat, 05 Apr 2025 01:01:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!bxGE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>[System Design: Passkeys For Passwordless Authentication]</h3><p><a href="https://blog.quastor.org/p/the-architecture-of-grab-s-auth-system?ref=decodingcoding.substack.com">(Source)</a></p><p>A good primer on what passkeys are and how they are integrated by Grab in the auth flow. One thing I did notice was that passkeys are supposed to make user login easier by not making users remember passwords. However, the private keys are stored on the device (Icloud for Apple). This takes away the control from the user. If my private keys are managed by an external service, I become dependent on that service. <br>Still, I feel it&#8217;s a good read nonetheless. </p><div><hr></div><h3>{Article: Kafka Internals}</h3><p><a href="https://cefboud.com/posts/exploring-kafka-internals/?ref=decodingcoding.substack.com">(Source)</a></p><p>A detailed post that walks through the Kafka source code. It shows how Kafka handles new zookeeper vs Raft,  Socket connections, and writes logs. </p><div><hr></div><h3>{Paper: Textshop - Photoshop For Text}</h3><p><a href="https://arxiv.org/abs/2409.17088">(Source)</a></p><p>A new tool which reimagines image operations on text. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bxGE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bxGE!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 424w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 848w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 1272w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bxGE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png" width="1077" height="359" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:359,&quot;width&quot;:1077,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:155086,&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;:&quot;https://decodingcoding.substack.com/i/160304474?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!bxGE!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 424w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 848w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.png 1272w, https://substackcdn.com/image/fetch/$s_!bxGE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8783f3d3-2d9b-41c8-9499-f90ce72d84ba_1077x359.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></figure></div><p>In addition to dragging to change sentence ordering, resizing to expand or summarize, and rotation for changing word orders, it also introduces tools like:</p><ul><li><p><strong>Brush</strong> &#8211; Adjusts the tone of selected text based on the chosen style.</p></li><li><p><strong>Tone Eyedropper</strong> &#8211; Captures the tone of selected text and updates the tone picker.</p></li><li><p><strong>Smudge</strong> &#8211; Rewrites selected text for variation or smoother transitions.</p></li><li><p><strong>Singularizer and Pluralizer</strong> &#8211; Changes number agreements in text.</p></li><li><p><strong>Tense Changer</strong> &#8211; Converts text to past, present, or future tense while maintaining consistency.</p></li><li><p><strong>Repair</strong> &#8211; Fixes grammar, punctuation, and spelling errors.</p></li><li><p><strong>Eraser</strong> &#8211; Deletes text while keeping sentences grammatically correct.</p></li><li><p><strong>Prompt</strong> &#8211; Applies a user-defined prompt to modify selected text using AI.</p></li></ul><div><hr></div><h3>{Return}</h3><p>I hope you enjoyed this newsletter. Let me know if you have any feedback.</p><p>Next week &#2346;&#2369;&#2344;&#2381;&#2361;&#2366; &#2349;&#2375;&#2335;&#2370;!</p><p></p>]]></content:encoded></item><item><title><![CDATA[Issue #2: On Kafka, Pytorch Internals, Job Interviews, etc.]]></title><description><![CDATA[Week 2: 21st March 2025 - 27th March 2025]]></description><link>https://decodingcoding.substack.com/p/issue-2-on-kafka-pytorch-internals</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/issue-2-on-kafka-pytorch-internals</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Fri, 28 Mar 2025 01:01:03 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/a4cb023c-81e6-4127-83e0-d73aeb4d20d5_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Week 2: 21st March 2025 - 27th March 2025</p><h3>{System Design: Managing 1.5 Trillion Kakfa Events}</h3><p><a href="https://medium.com/agoda-engineering/how-agoda-manages-1-5-trillion-events-per-day-on-kafka-f0a27fc32ecb?ref=decodingcoding.substack.com">(Source)</a></p><p>This is a great read on how Agoda managed 1.5 trillion Kafka events daily. The key insight was to separate the concerns of generating events and sending them to Kafka clusters. The dev team wrote to a cold data store, and then another dedicated service managed using the data with required metadata and wrote to the Kakka clusters.<br>What I like about this blog is that  they have also explained the tradeoff considerations, which I feel is a critical part of any system design. </p><div><hr></div><h3>{Article: Pytorch Internals}</h3><p><a href="https://blog.ezyang.com/2019/05/pytorch-internals/?ref=decodingcoding.substack.com">(Source)</a></p><p>This article dives deep into how Pytorch is implemented, including Tensor structures, strides, index calculation, operator operations, how to make tensor extensions, how auto-grad works, etc.</p><div><hr></div><h3>{On Acing Your Remote Interviews}</h3><p><a href="https://increment.com/remote/remote-job-interview-tips/?ref=decodingcoding.substack.com">(Source)</a></p><p>This is a surprisingly tempered and practical guide for things to consider when appearing for remote job interviews.</p><div><hr></div><h3>{Return}</h3><p>I hope you enjoyed this newsletter. Let me know if you have any feedback.</p><p>Next week &#2346;&#2369;&#2344;&#2381;&#2361;&#2366; &#2349;&#2375;&#2335;&#2370;!</p>]]></content:encoded></item><item><title><![CDATA[Issue #1: On Python lists, DyT, GitHub Push System, etc.]]></title><description><![CDATA[Trying something new...]]></description><link>https://decodingcoding.substack.com/p/issue-1-on-python-lists-dyt-github</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/issue-1-on-python-lists-dyt-github</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Fri, 21 Mar 2025 01:01:17 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Heom!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>For the last few months, I have started to share my favourite non-tech articles and my thoughts <a href="https://prathmesh6.substack.com/">in my other newsletter</a> and this experiment is working very well. It forces me to read more technical blogs and papers and consequently, learn more. So I have decided to bring the theme here as well. I hope it forces me to read more technical articles and learn more. </p><p>Let me know if you like this format.</p><p>Here we go!</p><p>Week 1: 20th March - 26th March</p><h3>{Blog: Why len(list) == 0 is slower than not list}</h3><p><a href="https://blog.codingconfessions.com/p/python-performance-why-if-not-list?ref=decodingcoding.substack.com">(Read Here)</a></p><p>I read this interesting blog post that shows using len(list) == 0 is 2x slower than  using not list.</p><p>Well turns out the reason is because of the len() function call overhead. </p><p>The post is paywalled, but I used the dis package to generate the bytecode and it shows the overhead for the len(list) function call.  The code on the right calls the len(list) function.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Heom!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Heom!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Heom!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Heom!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Heom!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Heom!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg" width="548" height="284.91483516483515" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:757,&quot;width&quot;:1456,&quot;resizeWidth&quot;:548,&quot;bytes&quot;:520406,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:true,&quot;topImage&quot;:false,&quot;internalRedirect&quot;:&quot;https://decodingcoding.substack.com/i/159264975?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!Heom!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Heom!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Heom!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Heom!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fab1a6d62-80a0-49e8-97c6-ff158786d52f_2568x1336.jpeg 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></figure></div><p>The layout of CPython is explained really well in the article. </p><div><hr></div><h3>{Paper: Dynamic Tanh}</h3><p><a href="https://arxiv.org/abs/2503.10622">(Read Here)</a></p><p>This paper is very popular right now since Kaiming He and Yann Lecun are among the authors and it proposes a very simple but potentially ground-breaking idea. <br>The paper proposes to replace Layer-Norm with a parameterised Tanh function. </p><p>The key observation was that if you consider all data points together, Layer Norm&#8217;s linear transformation for each point actually looks like a scaled tanh since smaller inputs have larger slopes and vice-versa. </p><p>This image from the paper shows this effect:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nCaV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nCaV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 424w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 848w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 1272w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nCaV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png" width="1018" height="437" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:437,&quot;width&quot;:1018,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:145315,&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;:&quot;https://decodingcoding.substack.com/i/159264975?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="https://substackcdn.com/image/fetch/$s_!nCaV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 424w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 848w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.png 1272w, https://substackcdn.com/image/fetch/$s_!nCaV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02228919-daa7-4b7d-9d03-1c517c9d4922_1018x437.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></figure></div><p>They claim to have equivalent or better accuracies on different models like ViT and ConvNeXt as well as LLaMA models. In addition to this, they also claim an 8% reduction in inference time for LLaMA 7B. It is a good read!</p><div><hr></div><h3>{System Design: How GitHub Rebuilt Their Push Processing System}</h3><p><a href="https://blog.quastor.org/p/how-github-rebuilt-their-push-processing-system?ref=decodingcoding.substack.com">(Read Here)</a></p><p>I want to consistently read about system design so I will try to include at least one article every week. This one talks about how GitHub used Kafka to decouple their push processing system. And the advantages and disadvantages of a decoupled system.</p><div><hr></div><h3>{Return}</h3><p>I hope you enjoyed this newsletter. Let me know if you have any feedback.</p><p>Next week &#2346;&#2369;&#2344;&#2381;&#2361;&#2366; &#2349;&#2375;&#2335;&#2370;!</p>]]></content:encoded></item><item><title><![CDATA[Newsletter 21: To keepdims or not to keepdims!]]></title><description><![CDATA[A note about broadcasting rules in Pytorch]]></description><link>https://decodingcoding.substack.com/p/newsletter-21-to-keepdims-or-not</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-21-to-keepdims-or-not</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Fri, 19 Jul 2024 01:12:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!fjqA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hi Everyone! It's been a long time since I wrote a post, if you are still subscribed, thank you! :)</p><p></p><p>So I am working through Andrej Karpathy&#8217;s makemore series to understand better how different ML models work. In his bi-gram model video, he talks about the keepdims parameter in the tensor.sum function and how understanding it is important. So I thought I&#8217;d write a post (mostly for myself), so I can come back and revise what I have learnt. </p><p></p><p>Let&#8217;s start with the basics: </p><p>The 2 conditions for tensors to be broadcastable is </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!fjqA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!fjqA!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 424w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 848w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 1272w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!fjqA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png" width="1174" height="345" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c85e3296-e993-46e5-9c81-979245d24e82_1174x345.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:345,&quot;width&quot;:1174,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:62939,&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;: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_!fjqA!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 424w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 848w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 1272w, https://substackcdn.com/image/fetch/$s_!fjqA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc85e3296-e993-46e5-9c81-979245d24e82_1174x345.png 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></figure></div><p>The <a href="https://pytorch.org/docs/stable/notes/broadcasting.html">official documentation</a> has many examples, but I will just use the example from the tutorial. </p><p>In the bi-gram model, the first step is to create a n*n character array that stores the frequency of each pair or bi-grams. For example row[1][1] stores how frequently the bi-gram &#8216;aa&#8217; appeared in the dataset. Additionally, we also add a &#8216;.&#8217; symbol to denote the start and end of every sequence hence we get a 27*27 array, with row 0 being the special symbol &#8216;.&#8217; and rows 1 to 27 being characters a-z. Any position [i][j] holds how many times character j followed character i. </p><p></p><p>Now the way we build the model is to sample from a multinomial probability distribution of these counts. To do that we first need to convert the raw counts to probabilities that sum up to 1. To do this, we use the following code:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!vK9x!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!vK9x!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 424w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 848w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 1272w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!vK9x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png" width="695" height="260" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0868751-cc5e-4ddc-af78-2a2328868212_695x260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:260,&quot;width&quot;:695,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:21378,&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_!vK9x!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 424w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 848w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.png 1272w, https://substackcdn.com/image/fetch/$s_!vK9x!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0868751-cc5e-4ddc-af78-2a2328868212_695x260.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></figure></div><p>The generator is just to get consistent results. <br>P is a tensor that stores the counts (stored in N as ints) as floats.<br>Then we sum along the columns and set keepdim to be True.</p><p>The result is a tensor of size [27, 1]</p><p>Now according to the rules, tensors of size 27*27 and 27*1 are broadcastable if from the right, each pair is either 1, equal or non existent.</p><p>Pair 1, 27 &#8594; One of them is 1</p><p>Pair 27, 27 &#8594; Equal</p><p>Internally, Pytorch copies the column vector 27 times and does element-by-element division.  </p><p></p><p>Now to the problem, </p><p>If keepdims is false, we get a tensor of size [27]. If we check [27, 27] and [27, ] are broadcastable, they are since in the first pair, one of dims is non-existent and hence allowed. So the code runs without errors, however, the output produced is complete garbage.  See the example below:</p><p></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pC18!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pC18!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 424w, https://substackcdn.com/image/fetch/$s_!pC18!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 848w, https://substackcdn.com/image/fetch/$s_!pC18!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 1272w, https://substackcdn.com/image/fetch/$s_!pC18!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pC18!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png" width="232" height="531.8814814814815" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:619,&quot;width&quot;:270,&quot;resizeWidth&quot;:232,&quot;bytes&quot;:13212,&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_!pC18!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 424w, https://substackcdn.com/image/fetch/$s_!pC18!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 848w, https://substackcdn.com/image/fetch/$s_!pC18!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.png 1272w, https://substackcdn.com/image/fetch/$s_!pC18!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffdafe3a8-3c66-4459-912d-3eb40083234e_270x619.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">Keepdim = True</figcaption></figure></div><p></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!7WDH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!7WDH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 424w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 848w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 1272w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!7WDH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png" width="630" height="186.4903846153846" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/eb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:431,&quot;width&quot;:1456,&quot;resizeWidth&quot;:630,&quot;bytes&quot;:56698,&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_!7WDH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 424w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 848w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 1272w, https://substackcdn.com/image/fetch/$s_!7WDH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Feb35ba93-9b44-4132-a53a-ae44c59f884a_1734x513.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a><figcaption class="image-caption">Keepdims = False</figcaption></figure></div><p></p><p>These are supposed to be names! Granted that the bi-gram model is pretty poor at estimating names, but the first image has at least lengths that somewhat resemble names with keepdims = False, it is producing sentences!</p><p></p><p>So what is happening here? </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!U5c2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!U5c2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 424w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 848w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 1272w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!U5c2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png" width="702" height="961.3477765108324" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1201,&quot;width&quot;:877,&quot;resizeWidth&quot;:702,&quot;bytes&quot;:246068,&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_!U5c2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 424w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 848w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.png 1272w, https://substackcdn.com/image/fetch/$s_!U5c2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F78741ff5-d8aa-43b5-bfda-8d269fdb9403_877x1201.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></figure></div><p></p><p>Look at the image above, in the first case, we have the shape (27,1) hence we sum across columns and then get a column vector which is copied 27 times across. However, when we implicitly get (1,27) due to missing dimensions, we sum across rows and get a row vector which is copied horizontally 27 times. </p><p>Hence in case 1, we correctly divide the count of say &#8216;.b&#8217; with the sum of all instances where the the prefix is &#8216;.&#8217; ,  But in the second case, we divide with instances where b followed some letter, which is incorrect!</p><p>This can be a tricky bug given that neural nets and ml models can produce incorrect results for myriad of reasons and hence when you have a complex model, it&#8217;s easy to miss this simple reason.</p><p>I would love to read any more tutorials you might come across, feel free to send them to me! <br><br>I hope you found this article useful. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://pytorch.org/docs/stable/notes/broadcasting.html">Official Documentation - Broadcasting Semantics</a></p></li><li><p><a href="https://www.youtube.com/watch?v=PaCmpygFfXo">Bigram Video</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div>]]></content:encoded></item><item><title><![CDATA[Newsletter #20: PDFTraige]]></title><description><![CDATA[A new way to extract contexts]]></description><link>https://decodingcoding.substack.com/p/newsletter-20-pdftraige</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-20-pdftraige</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Wed, 08 Nov 2023 00:00:30 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Rglw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h3>Introduction</h3><p>Before we start with this post, <a href="https://prathmesh6.substack.com/p/newsletter-32-on-home-and-family">go here if you want to know why I was inactive for the last few months</a>, I am back to posting regularly now :)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Rglw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Rglw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Rglw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png" width="544" height="544" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:544,&quot;bytes&quot;:1351192,&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;: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_!Rglw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Rglw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84baec74-a976-4f03-97dc-28f8ebb7aded_1024x1024.png 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></figure></div><p>This is an interesting paper I read recently that has a novel way to parse user questions about a document. The key insight is that articles or research papers have a very structured format. In some cases, strict templates need to be followed. When this is true, it makes little sense to get context from just blobs of text which is what current approaches follow. PDFTriage proposes a way to train the model not only on the content but also on the metadata which provides the structure of the document. This is helpful because the AI model can now understand the mental model the user had in mind when writing the article.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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>This enables PDFTriage to accurately answer queries such as &#8220;Summarize pages 3-7&#8221;, &#8220;analyze data in table 3&#8221;, etc. In this post, let&#8217;s take a look at how it works.</p><h3>Why do we need to have pre-processing?</h3><p>It&#8217;s trivial but important to note that we need the pre-processing stage since for long documents it&#8217;s computationally infeasible to have the entire context in memory. And when we are analyzing tomes &#8212; which is what we ideally want our NLP Agents to do &#8212; we need to only extract the information relevant to the user query to get useful results.</p><h3>Architecture</h3><p>PDFTraige has 3 stages, Getting the document structure, Using the structure to get the relevant context from LLMs and then using the context to answer user queries.</p><p>This is the figure presented in the paper:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!C_vy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!C_vy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 424w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 848w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 1272w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!C_vy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png" width="698" height="626" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:626,&quot;width&quot;:698,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:155488,&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_!C_vy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 424w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 848w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.png 1272w, https://substackcdn.com/image/fetch/$s_!C_vy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80c1e771-b6c9-4998-b85a-1c300b04a6ce_698x626.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></figure></div><h4>Stage 1: Generate Document Structure</h4><p>The authors consider born-digital PDF documents &#8212; documents that are created completely electronically (not scanned) &#8212; and use the AdobeExtract API to create a DOM-like structure of the document. This is then converted to a JSON file and given as input to the LLM.</p><h4>Stage 2: LLM Querying</h4><p>As mentioned above, the input to the LLM is the JSON object which represents the structure and the following 5 functions:</p><ul><li><p>fetch_pages</p></li><li><p>fetch_sections</p></li><li><p>fetch_table</p></li><li><p>fetch_figures</p></li><li><p>retrieve</p></li></ul><p>The paper just mentions &#8220;<em>each function allows the PDFTriage system to gather precise information related to the given PDF document, centring around structured textual data in headers, subheaders, figures, tables, and section paragraphs.</em>&#8221;</p><p>Each function is used in a separate query to get multiple answers and combined to get the final context.</p><h3>A small note on how to call the functions</h3><p>OpenAPI has a detailed example <a href="https://platform.openai.com/docs/guides/function-calling#">here</a>. However, I&#8217;ll just briefly explain how a function could be called based on the query.</p><p>You first define the function in Python, then pass it as a JSON object which has keys like description, parameters, etc.</p><p>This is then passed as an argument to the OpenAPI model call. In the response, the model returns an array of the function calls it needs to make based on the user query. You use this array to call the functions and then run a second query where you input the original query and the response of the function calls requested by the model.</p><h4>Stage 3: User QnA</h4><p>This is the prompt used to initialize the system:</p><p>&#8220;<em>You are an expert document question-answering system. You answer questions by finding relevant content in the document and answering questions based on that content. Document: &lt;textual metadata of document&gt;</em>&#8221;</p><p>The model uses the functions described above in addition to the context retrieved in stage 2 to output the final answer.</p><h3>Conclusion</h3><p>Even though the approach seems simple enough, I enjoyed reading this paper because it shows how we can make improvements to AI models by literally thinking about what a human would do in the given context. Since we have a mental model when writing anything, like this post for example, it makes sense that the AI model should be able to parse and reference it to get better answers.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://huggingface.co/papers/2309.08872">PDFTriage Paper</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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[Newsletter #19: CM3Leon]]></title><description><![CDATA[Decoder-only image and text generation and completion.]]></description><link>https://decodingcoding.substack.com/p/newsletter-19-cm3leon</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-19-cm3leon</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 20 Jul 2023 12:30:19 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!wL_W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Introduction</h2><p>CM3Leon (pronounced chameleon) is a retrieval-augmented, token-based, decoder-only multi-modal language that can not only generate images but also infill images as well as generate and infill text. It combines image and text generation using a combination of models to achieve performance comparable to diffusion models.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wL_W!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wL_W!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wL_W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png" width="482" height="482" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/06301713-33d6-476f-b21f-867190d9d868_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:482,&quot;bytes&quot;:2295127,&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;: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_!wL_W!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!wL_W!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06301713-33d6-476f-b21f-867190d9d868_1024x1024.png 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></figure></div><p></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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>Let&#8217;s take a look at how it works!</p><h2>Design</h2><p>The pre-training stage has two steps</p><h3>Image Tokenization</h3><p>The image tokenizer tokenized a 256x256 image into 1024 tokens from a vocabulary of 8192 tokens. Here, vocabulary means the set of all possible tokens. For the text, the process uses a pre-trained transformer with a vocabulary of 56320. In addition to image and text, is also a special token &lt;break&gt; which is used to differentiate between them.</p><h3>Retrieval Augmentation</h3><p>The retriever takes a query q, and a candidate document m, and returns a relevance score r(q, m). Using a CLIP-based architecture, the text and image parts are separated and tokenized. Then the average of the two vector representations is used as the vector representation of the document.</p><h2>Training</h2><p>While training, 3 parameters are used for selecting the candidate documents:</p><ol><li><p>The document selected should be relevant to the input sequence x.</p></li><li><p>The document should contain images and text instead of just one of the two.</p></li><li><p>While selecting top K documents, no two documents should be too similar.</p></li></ol><h3>Objective function</h3><p>The objective function of CM3Leon is the next token loss -log p(x) where x is the input sequence.</p><p>Here&#8217;s an example of how all of it works together</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xTRS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xTRS!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 424w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 848w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 1272w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xTRS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png" width="600" height="455.7759626604434" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:651,&quot;width&quot;:857,&quot;resizeWidth&quot;:600,&quot;bytes&quot;:310582,&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_!xTRS!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 424w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 848w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.png 1272w, https://substackcdn.com/image/fetch/$s_!xTRS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc396a07b-ce51-433c-a58a-9859ca830fd7_857x651.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></figure></div><h2>Conclusion</h2><p>CM3Leon is in line with the last few posts which combine LLMs and vision transformers to get good results in not only image generation but also image description. This will be the last post where I just break down the paper on a general level, from the next post, I plan to explore classic research papers including all the math as well as code if possible. I am excited about what&#8217;s next! Let me know if you have any suggestions on which topics I should cover.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://scontent.fbom3-1.fna.fbcdn.net/v/t39.2365-6/358725877_789390529544546_1176484804732743296_n.pdf?_nc_cat=108&amp;ccb=1-7&amp;_nc_sid=3c67a6&amp;_nc_ohc=mM8qM4dpIIQAX8uqW_O&amp;_nc_ht=scontent.fbom3-1.fna&amp;oh=00_AfBIgiU3b7wOtW-oFJQATKxaQ4DtcUjTGq4M0Wn6OP9FkQ&amp;oe=64BD43B2">CM3Leon Paper</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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"></figcaption></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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[Newsletter #18: Vision via language]]></title><description><![CDATA[How to achieve computer vision using natural language]]></description><link>https://decodingcoding.substack.com/p/newsletter-18-vision-via-language</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-18-vision-via-language</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 13 Jul 2023 12:30:07 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!oPzh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<h2>Introduction</h2><p>LENS (Large Language Models ENnhanced to See) is a model that combines the reasoning capabilities of LLMs with computer vision. It combines vision-based models to get general-purpose data on the image and then uses an LLM with context to answer user-defined queries.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!oPzh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!oPzh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!oPzh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg" width="370" height="370" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/cc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_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;:370,&quot;bytes&quot;:65188,&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_!oPzh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!oPzh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fcc57e3ab-45c6-4a6c-a9e5-4438da1fdc57_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></figure></div><p>In this post, let&#8217;s take a look at how it works.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!wAw1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!wAw1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 424w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 848w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 1272w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!wAw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png" width="249" height="401.8443804034582" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/dcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:560,&quot;width&quot;:347,&quot;resizeWidth&quot;:249,&quot;bytes&quot;:47438,&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_!wAw1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 424w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 848w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.png 1272w, https://substackcdn.com/image/fetch/$s_!wAw1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fdcd75fdb-4fbe-46c5-8af5-d66338570b78_347x560.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">Overview</figcaption></figure></div><h2>Working</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!68x8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!68x8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 424w, https://substackcdn.com/image/fetch/$s_!68x8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 848w, https://substackcdn.com/image/fetch/$s_!68x8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 1272w, https://substackcdn.com/image/fetch/$s_!68x8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!68x8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png" width="1058" height="601" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:1058,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:200272,&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_!68x8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 424w, https://substackcdn.com/image/fetch/$s_!68x8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 848w, https://substackcdn.com/image/fetch/$s_!68x8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.png 1272w, https://substackcdn.com/image/fetch/$s_!68x8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff82ad0af-38e7-4085-b2ef-bfc09cd5256d_1058x601.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">Design</figcaption></figure></div><p>LENS consists of 3 different vision modules and 1 language module. The vision modules generate all information irrespective of the user query. Then, this information and user-specific context are given to the LLM to generate the output.</p><p>Here&#8217;s what each model is responsible for:</p><h3>Tag Module</h3><p>The module generates the most appropriate tag for a given image using the CLIP vision encoder. The prompt is &#8220;The photo is of _______&#8221;</p><h3>Attribute Model</h3><p>The attribute model uses a pre-trained CLIP model to generate descriptions of the image.</p><h3>Intensive captioner model</h3><p>It uses the BLIP model to generate N captions that capture diverse aspects of the image.</p><h3>Visual Vocabularies</h3><p>These act as a connecting dot between the image and the text. The tags are obtained from various datasets such as object detection and semantic segmentation, and genome. Attributes data uses GPT-3 to get descriptions for various object types. These are then used by the vision modules to generate a description of the image free of user query context.</p><h3>Reasoning Module</h3><p>This is a trained LLM module that gets as input the output of the 3 vision modules as well as the use query.</p><p>Here are some of the examples given in the paper</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!RPn8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!RPn8!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 424w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 848w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 1272w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!RPn8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png" width="1358" height="531" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:531,&quot;width&quot;:1358,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:373385,&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_!RPn8!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 424w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 848w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.png 1272w, https://substackcdn.com/image/fetch/$s_!RPn8!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a092938-2055-4420-a7f3-2bade3cb55b4_1358x531.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">Example</figcaption></figure></div><h2>Conclusion</h2><p>LENS is an example of adapting LLMs to vision tasks. This will make to make LLMs more general-purpose and work with images and eventually with videos and other forms of visual input as well.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/abs/2306.16410">LENS Paper</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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://decodingcoding.substack.com/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://decodingcoding.substack.com/subscribe?"><span>Subscribe now</span></a></p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! 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://decodingcoding.substack.com/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 Decoding Coding! 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[Newletter #17: Textbooks are all you need!]]></title><description><![CDATA[Exploring phi-1: the LLM trained on "textbook" code]]></description><link>https://decodingcoding.substack.com/p/newletter-17-textbooks-are-all-you</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newletter-17-textbooks-are-all-you</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 29 Jun 2023 12:31:26 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Conventionally, LLMs trained for Code Generation use the code available online for training. In their paper, &#8216;Textbooks Are All You Need&#8216;, Gunasekar et. al. propose a textbook-based approach, where code is filtered based on quality and then used for training. </p><p>The result, is phi-1, a model that performs better than traditionally trained code generation LLMs. </p><p>Let&#8217;s take a look at how it works. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!zDT9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!zDT9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!zDT9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png" width="444" height="444" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:444,&quot;bytes&quot;:1981942,&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;: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_!zDT9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!zDT9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb969ceda-b79c-4b4e-8718-9173f45eb80c_1024x1024.png 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></figure></div><p></p><h3>The problem with training on online code</h3><p>There are a few problems when you train the LLM on online codes found on Stackoverflow, CodeContest, etc. They are:</p><ol><li><p>The codes are not often self-sustained i.e. external information is required for the code to make sense. </p></li><li><p>A lot of boilerplate code gets repeated. </p></li><li><p>Examples might not have any algorithmic value, i.e. a lot of code that is just manipulating data and passing it on without actually doing any meaningful contributions. </p></li></ol><p></p><h3>Working of phi-1</h3><p>Phi-1 uses 3 datasets:</p><ol><li><p>Filtered-code language dataset</p></li><li><p>Synthetic Textbook</p></li><li><p>Synthetic Exercises</p></li></ol><p></p><p>The filtered code is obtained by prompting GPT-4 to filter based on educational quality to a student whose objective is to learn code.  </p><p>Here&#8217;s an example of a positive and negative sample:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!B31z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!B31z!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 424w, https://substackcdn.com/image/fetch/$s_!B31z!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 848w, https://substackcdn.com/image/fetch/$s_!B31z!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 1272w, https://substackcdn.com/image/fetch/$s_!B31z!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!B31z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png" width="931" height="718" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:718,&quot;width&quot;:931,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:171620,&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_!B31z!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 424w, https://substackcdn.com/image/fetch/$s_!B31z!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 848w, https://substackcdn.com/image/fetch/$s_!B31z!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.png 1272w, https://substackcdn.com/image/fetch/$s_!B31z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8ff1347f-e38c-4f31-8ca1-c55f813195e1_931x718.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></figure></div><p>The synthetic textbook is generated using prompts that mention different levels of understanding to generate diversity.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!gAH6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!gAH6!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 424w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 848w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 1272w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!gAH6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png" width="1256" height="523" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:523,&quot;width&quot;:1256,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:96558,&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_!gAH6!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 424w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 848w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.png 1272w, https://substackcdn.com/image/fetch/$s_!gAH6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9eefabd5-cce2-4976-9c77-1a936d40834a_1256x523.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></figure></div><p>The exercises are generated by giving a doc string of the code that needs to be completed. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jFP4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jFP4!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 424w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 848w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 1272w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jFP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png" width="1255" height="430" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:430,&quot;width&quot;:1255,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83854,&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_!jFP4!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 424w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 848w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.png 1272w, https://substackcdn.com/image/fetch/$s_!jFP4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2933aa8e-30dc-41f7-9824-1e0c646ea40d_1255x430.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></figure></div><p>The training is done first on the CodeTextBook (Filtered code-language + Synthetic Textbook) to get phi-1-base. The base model is then fine-tuned on the exercises to get phi-1.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j4N2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j4N2!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 424w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 848w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 1272w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j4N2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png" width="1046" height="662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:662,&quot;width&quot;:1046,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:177783,&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_!j4N2!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 424w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 848w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.png 1272w, https://substackcdn.com/image/fetch/$s_!j4N2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b70a531-7021-4a38-a194-d98635e6917b_1046x662.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></figure></div><p></p><h3>Conclusion</h3><p>The authors show that phi-1 performs well on various tasks. The reason I choose to write about this paper is it shows how using small tweaks in data used for training as well as fine-tuning, superior performance can be achieved. </p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="http://Textbooks Are All You Need">Textbooks Are All You Need</a></p></li></ol><ol><li><p><a href="https://proceedings.neurips.cc/paper_files/paper/2017/file/3f5ee243547dee91fbd053c1c4a845aa-Paper.pdf">Attention is all you need</a> (Other than the title inspiration, this has nothing to do with this paper. But if you haven&#8217;t read this paper, you must!)</p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #16: PEARL — A LLM brain for large texts ]]></title><description><![CDATA[Planning and execution of queries on large documents using LLMs]]></description><link>https://decodingcoding.substack.com/p/newsletter-16-pearl-a-llm-brain-for</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-16-pearl-a-llm-brain-for</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 22 Jun 2023 12:31:05 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!ixCR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>More and more system designs are being proposed where the LLMs are used not only for text analysis but also as a pseudo brain. A few weeks ago, <a href="https://decodingcoding.substack.com/p/newsletter-9-building-a-brain-with">I wrote about one such approach</a> where the LLMs were modularized as the eye, the nerve and the brain.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!ixCR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!ixCR!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!ixCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png" width="458" height="458" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:458,&quot;bytes&quot;:1492808,&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;: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_!ixCR!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!ixCR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a2b7447-e6f3-41c9-8ff7-0d690a1fc536_1024x1024.png 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></figure></div><p>In this post, we take a look at another model that works on a similar principle of using a sophisticated <a href="https://decodingcoding.substack.com/i/111570669/chain-of-thought-prompting">Chain-Of-Thought (COT) prompting</a> approach to plan and execute tasks over long documents.</p><p>The model proposes 3 steps: Action Mining, Plan Generation and Plan Execution.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pgsx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pgsx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 424w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 848w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 1272w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pgsx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png" width="486" height="550" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:550,&quot;width&quot;:486,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:117488,&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_!pgsx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 424w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 848w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.png 1272w, https://substackcdn.com/image/fetch/$s_!pgsx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7634185b-6c69-483f-ac01-1e94ca97be40_486x550.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></figure></div><p>Let&#8217;s explore how it works.</p><h2>Model Design</h2><h3>Action Mining</h3><p>The model generates all possible steps that might be required for the task. The output of this step is a function definition and it&#8217;s a description in natural language.</p><p>The module gives a few seed actions along with the task to get task-specific results.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!6eZJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!6eZJ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 424w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 848w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 1272w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!6eZJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png" width="638" height="583" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/da9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:583,&quot;width&quot;:638,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:142423,&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_!6eZJ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 424w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 848w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.png 1272w, https://substackcdn.com/image/fetch/$s_!6eZJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fda9273b5-1aeb-4d87-ae7c-c31c87887ba1_638x583.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></figure></div><p>As seen above, the output is a function definition with parameters and a function description in natural language.</p><p>A full pass over the training data is required to generate the set of all actions.</p><h3>Plan Generation</h3><p>This is the framework for producing the answer. It will choose the actions mined in the previous step. The input arguments to action could be the input document, a string or output from the previous step.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!UDgV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!UDgV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 424w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 848w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 1272w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!UDgV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png" width="651" height="598" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:598,&quot;width&quot;:651,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:170597,&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_!UDgV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 424w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 848w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.png 1272w, https://substackcdn.com/image/fetch/$s_!UDgV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8be39a1e-ebf5-430c-8045-7ac00be10fd0_651x598.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></figure></div><h3>Plan execution</h3><p>The actions from step 2 are executed in this step. The goal is to execute actions in the right order as well as handle errors where necessary.</p><p>A plan parser is used prior to plan execution for error handling and checking the quality and feasibility of the generated plan. In case of an error, the error message is fed back to the LLM and a new plan is generated.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!XXFB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!XXFB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 424w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 848w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 1272w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!XXFB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png" width="661" height="591" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:591,&quot;width&quot;:661,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:152553,&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_!XXFB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 424w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 848w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.png 1272w, https://substackcdn.com/image/fetch/$s_!XXFB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F097b2ada-ab02-433f-9637-6a2467ed3d27_661x591.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></figure></div><h2>Limitations</h2><p>Even though this is a novel approach to using LLMs of generating misinformation or hallucination. There were some cases in the evaluation where the plan generated was incorrect or a good plan was executed in an erroneous way. In addition to this, even though the model is designed to work on large documents, it is bottlenecked by the max context size of the LLM.</p><h2>Conclusion</h2><p>Auto planners using LLMs are in the nascent stage of development. As LLMs get more powerful, better architecture can be designed to build an efficient planner of difficult tasks. This will have huge applications in education since once the model is tuned to a particular student, a smart planner can plan an action map suited to each individual student.</p><p>I&#8217;m sure we are in for exciting times ahead!</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/pdf/2305.14564.pdf">PEARL Paper</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #15: ViperGPT]]></title><description><![CDATA[Answering user queries about images using LLM and Python]]></description><link>https://decodingcoding.substack.com/p/newsletter-15-vipergpt</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-15-vipergpt</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 15 Jun 2023 12:31:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!DuQ0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A lot of different tools are released every week that leverage fine-tuned LLMs. In last few weeks, we saw models such as <a href="https://decodingcoding.substack.com/p/newsletter-8-hugginggpt">HuggingGPT</a>, which uses LLMs to plan complex tasks, <a href="https://decodingcoding.substack.com/p/newsletter-13-structgpt">StructGPT</a>, which uses iterative read-then-reason approach to find insights from structured data, <a href="https://decodingcoding.substack.com/p/newsletter-14-adding-memory-to-llms">DT-Mem</a> which adds a memory module to the LLM to better model the human brain, etc.</p><p>In line with these advances, ViperGPT is a new LLM based model that uses LLMs as well as some vision models such as GLIP, MiDaS, X-VLM in conjunction with Codex to create a model capable of answering questions based on images and videos.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DuQ0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DuQ0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DuQ0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png" width="386" height="386" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:386,&quot;bytes&quot;:1846369,&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;: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_!DuQ0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!DuQ0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff14f190b-3505-4015-99ce-69410cfe1ed5_1024x1024.png 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></figure></div><p>The use of LLMs to generate code and pre-trained models to make the code generation fast and efficient makes this model interesting.</p><p>Let&#8217;s take a look at how ViperGPT works.</p><div><hr></div><h2>Design</h2><p>The input to the program is a visual input (image/video) and a user query related to the visual input.</p><p>The first step is to generate a program using the query q,</p><p>z = &#10986;(q), where &#10986; is the program generator</p><p>Then using the program z, and the visual input v, we get the result r.</p><p>r = &#216;(x, v), where &#216; is the execution engine.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!iv9s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!iv9s!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 424w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 848w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 1272w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!iv9s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png" width="1343" height="349" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:349,&quot;width&quot;:1343,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:86321,&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_!iv9s!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 424w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 848w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.png 1272w, https://substackcdn.com/image/fetch/$s_!iv9s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9f3532b7-34b6-4057-80ba-6a5c4e8bd132_1343x349.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">IMG1: Basic Architecture [For attributions, See Below] </figcaption></figure></div><p>The program z is generated in Python using OpenAI Codex API to allow flexibility as well as programming tools such as loops and conditional statements. </p><h2>Implementation</h2><p>Not that we&#8217;ve seen the high level design, let&#8217;s look at how each of the components work, starting with the program generator &#10986;.</p><h2>Program Generator &#10986;</h2><p>In previous approaches, &#10986; was generated using a neural network. However this has certain drawbacks such as</p><ol><li><p>At scale, supervised learning is not efficient due lack of available data.</p></li><li><p>The computation costs also grow with size.</p></li></ol><p>ViperGPT uses LLMs to autoregressively* generate code based on the user query. Since the optimization is done using LLMs, all the python code available on the internet can be used for fine-tuning, hence removing the issue of scale in traditional approaches.</p><p>*<em>Autoregressive prediction - Predict token at time T based on a few token x before time T i.e. for computing T use tokens T-1, T-2, &#8230;.., T-x.</em></p><p>The input to the LLM is the API specification of certain pre-trained models along with the user-query. Since the exact implementation is not provided it allows for greater flexibility in the output.</p><p>For example:</p><pre><code>def find(self, object_name: str) -&gt; List[ImagePatch]:
 """Returns a list of ImagePatch objects matching object_name contained in the crop if any are found.
&#9;&#9;Otherwise, returns an empty list.
&#9;&#9;Parameters
&#9;&#9;----------
&#9;&#9;object_name : str
&#9;&#9;the name of the object to be found

&#9;&#9;Returns
&#9;&#9;-------
&#9;&#9;List[ImagePatch]
&#9;&#9;a list of ImagePatch objects matching object_name contained in the crop

&#9;&#9;Examples
&#9;&#9;--------
&#9;&#9;&gt;&gt;&gt; # return the children
&#9;&#9;&gt;&gt;&gt; def execute_command(image) -&gt; List[ImagePatch]:
&#9;&#9;&gt;&gt;&gt; image_patch = ImagePatch(image)
&#9;&#9;&gt;&gt;&gt; children = image_patch.find("child")
&#9;&#9;&gt;&gt;&gt; return children
&#9;&#9;"""

Example API Spec input to the LLM</code></pre><p>Let&#8217;s look at an example from the paper for the task of Visual Grounding, which means to find out spatial relationships and visual attributes of an image. Following APIs of the pre-trained model are given as input to ViperGPT: <em>(model names are in parenthesis)</em></p><ol><li><p>find (GLIP): takes as input an image and a short noun phrase (e.g. &#8220;car&#8221; or &#8220;golden retriever&#8221;), and returns a list of image patches containing the noun phrase.</p></li><li><p>exists (GLIP): takes as input an image and a short noun phrase and returns a boolean indicating whether an instance of that noun phrase is present in the image.</p></li><li><p>verify_property (XVLM): takes as input an image, a noun phase representing an object, and an attribute representing a property of that object; it returns a boolean indicating whether the property is present in the image.</p></li><li><p>best_image_match (X-VLM) takes as input a list of image patches and a short noun phrase, and returns the image patch that best matches the noun phrase</p></li><li><p>best_text_match(X-VLM): takes as input a list of noun phrases and one image, and returns the noun phrase that best matches the image.</p></li><li><p>compute_depth (MiDaS) computes the median depth of the image patch.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!W8Fq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!W8Fq!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 424w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 848w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 1272w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!W8Fq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png" width="604" height="659" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:659,&quot;width&quot;:604,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:230513,&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_!W8Fq!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 424w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 848w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.png 1272w, https://substackcdn.com/image/fetch/$s_!W8Fq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd6fac8e7-9cd5-4dbd-b91b-a5768cc4dd50_604x659.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></figure></div><p>Using these methods of pre-trained models as well as the user query, the code z can be generated. Now let&#8217;s look at the execution engine &#216;</p><h2>Execution Engine &#216;</h2><p>At execution time, the generated program z accepts an image or video as input and outputs a result r corresponding to the query provided to the LLM.</p><p>The execution engine uses a Python interpreter to run the code generated by the program generator. This allows it to use built-in functions and tools such as sort, if/else, loops, etc.</p><p>You can see the <a href="https://github.com/cvlab-columbia/viper/tree/main">full code here</a>, but here is how the code is executed using python&#8217;s exec() function:</p><pre><code>"""
exec is used to interpret a string as python code
"""
exec(compile(code_line, 'Codex', 'exec'), globals())
result = execute_command(im, my_fig, time_wait_between_lines, syntax)  # The code is created in the exec()
</code></pre><h3>Examples:</h3><p>Here are a couple example of ViperGPT in action:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PBJu!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PBJu!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 424w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 848w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 1272w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PBJu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png" width="924" height="694" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:694,&quot;width&quot;:924,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:323720,&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_!PBJu!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 424w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 848w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.png 1272w, https://substackcdn.com/image/fetch/$s_!PBJu!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7a605957-e811-4818-a5ff-ec4bccfac17f_924x694.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></figure></div><p>LLMs are helping to build tools that help to give better explanations about raw data. ViperGPT is one of the first tools that can generate python code to preprocess data and use the results in conjunction with LLMs to add better context to the code execution results. I sure had fun reading this paper.</p><p>Let me know your thoughts.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/abs/2303.08128">ViperGPT Paper</a></p></li><li><p><a href="https://github.com/cvlab-columbia/viper/tree/main">GitHub Repo</a></p></li><li><p>IMG1 was made using Vector stock images, below are the attributions as per free license:</p><ol><li><p>https://www.vectorstock.com/royalty-free-vector/random-icons-set-vector-7991904</p></li><li><p>https://www.vectorstock.com/royalty-free-vector/25-engine-icons-vector-36780597</p></li><li><p>https://www.vectorstock.com/royalty-free-vector/site-icons-vector-45958151</p></li><li><p>href="https://www.vectorstock.com/royalty-free-vector/form-icons-vector-45958593"</p></li></ol></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #14: Adding Memory to LLMs]]></title><description><![CDATA[How to make LLMs remember stuff]]></description><link>https://decodingcoding.substack.com/p/newsletter-14-adding-memory-to-llms</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-14-adding-memory-to-llms</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 01 Jun 2023 12:30:37 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!1n65!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the paper, &#8216;&#8217;Think Before You Act: Decision Transformers with Internal Working Memory&#8221;, by Jikun et. al., a new framework called Decision Transformers with Memory (DT-Mem) is proposed in order to improve the ability of LLMs to work better on generalization tasks. LLMs have implicit memory and can be used in novel ways to build something that mimics the human brain as we saw <a href="https://decodingcoding.substack.com/p/newsletter-9-building-a-brain-with">in this post</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!1n65!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!1n65!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1n65!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1n65!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1n65!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!1n65!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png" width="602" height="602" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:602,&quot;bytes&quot;:1878545,&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;: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_!1n65!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!1n65!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!1n65!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!1n65!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F89cfb8c2-3556-4de3-be1b-9a65dacabef6_1024x1024.png 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></figure></div><p>However, as the size of the LLMs grows, the LLM tends to &#8220;forget&#8221; some things resulting in poor results. Hence, the authors propose an internal memory module to improve LLMs' generalizations and adaptability.</p><p>Let&#8217;s take a look at how DT-Mem works.</p><h2>Model Setup</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!qfbH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!qfbH!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 424w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 848w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 1272w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!qfbH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png" width="476" height="391.3953488372093" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:495,&quot;width&quot;:602,&quot;resizeWidth&quot;:476,&quot;bytes&quot;:87610,&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_!qfbH!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 424w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 848w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.png 1272w, https://substackcdn.com/image/fetch/$s_!qfbH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53cfa89b-185e-44f7-8004-08e66129cff0_602x495.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"><a href="https://arxiv.org/pdf/2305.16338.pdf">Source</a></figcaption></figure></div><p>The problem is formulated as a Markov Decision Process (MDP). This means for every state transition Sn &#8594; Sn+1, the inputs as well as some x previous states are taken into consideration.</p><p>The MDP tuple consists of the following elements:</p><p>S - Set of states</p><p>A - Set of Actions</p><p>R - Reward Function</p><p>p - Transition Kernel (More on this below)</p><p>&#947; - Discount Factor</p><p>The transition kernel p is defined as S1 * A * S2 &#8594; (0, 1) which can be thought of as the probability of reaching state S2 from S1 by taking action A.</p><p></p><h4>LoRA</h4><p>A second essential component is LoRA or the Low-Rank Adaption method. This is used to map old knowledge to new tasks. The idea behind LoRA is to learn a low-rank matrix for a new task and then use it to get the relevant subspace from the old task.</p><p>An intuitive way to think about this is using the vector space of the old tasks, which is large, and extracting only the parts relevant to the current tasks from that space.</p><p></p><h2>Architecture</h2><p>DT-Mem consists of three components: the Transformer module, the Memory module, and the Multi-layer perceptron (MLP) module.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!neFP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!neFP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 424w, https://substackcdn.com/image/fetch/$s_!neFP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 848w, https://substackcdn.com/image/fetch/$s_!neFP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 1272w, https://substackcdn.com/image/fetch/$s_!neFP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!neFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png" width="1232" height="566" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:1232,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:144979,&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_!neFP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 424w, https://substackcdn.com/image/fetch/$s_!neFP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 848w, https://substackcdn.com/image/fetch/$s_!neFP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.png 1272w, https://substackcdn.com/image/fetch/$s_!neFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc97ba609-7810-452e-95aa-00897d65c8f4_1232x566.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 href="https://arxiv.org/pdf/2305.16338.pdf">Source</a></figcaption></figure></div><h3>Transformer Module</h3><p>It takes in a sequence of n tokens and gives the output as one of attended state embeddings, action embeddings, or return-to-go embeddings.</p><p></p><h3>Working Memory Module</h3><p>This module is based on the adage &#8220;Think before you act&#8221; and works by identifying the salient information, deciding where to store the information and how to integrate the new memory with the current memory state.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!9R6_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!9R6_!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 424w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 848w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!9R6_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png" width="584" height="413.13186813186815" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1030,&quot;width&quot;:1456,&quot;resizeWidth&quot;:584,&quot;bytes&quot;:1514973,&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_!9R6_!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 424w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 848w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.png 1272w, https://substackcdn.com/image/fetch/$s_!9R6_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b82095f-f63d-445b-b8ca-60dba1cba05e_3054x2160.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">Steps for Memory Module R/W </figcaption></figure></div><p>The memory is initialized as a random M*N matrix where each location (i, j) represents a slot.</p><p>Then using <a href="https://arxiv.org/pdf/2103.01197v1.pdf">content-based addressing</a> that uses the attention mechanism, the right slot to store the memory is identified. The intuition behind this is that we store similar information together.</p><p>To merge the new memory with the current state, two new vectors are used, the erasing vector and the addition vector. The erasing vector selectively removes information from the memory matrix and the addition vector selectively adds new information.</p><p>To retrieve the information, the same attention mechanism is used to identify the slot most relevant to the query and then read from that slot.</p><h3>MLP</h3><p>The multi-layer perception module is similar to the GPT-2 model, only it is decoupled from the transformer module and has the memory model preceding it. It produces the final result by taking the combined embedding from the transformer and memory modules.</p><h2>Conclusion</h2><p>This model was able to work well in Atari and Meta-world environments. Using just the weights of the neural network poses challenges that are solved by having a memory module.</p><p>Such new and innovative ideas are coming up every week. It feels like an inflexion point and maybe a major breakthrough that will vastly improve LLMs&#8217; ability to solve general tasks is right on the horizon. These are exciting days in the world of AI!</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/pdf/2305.16338.pdf">DT-Mem Paper</a></p></li><li><p><a href="https://arxiv.org/pdf/1910.10897.pdf">Meta-World Paper</a></p></li><li><p><a href="https://arxiv.org/pdf/2106.09685.pdf">LoRA Paper</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #13: StructGPT]]></title><description><![CDATA[Making LLMs work better on Graphs and Databases]]></description><link>https://decodingcoding.substack.com/p/newsletter-13-structgpt</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-13-structgpt</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 25 May 2023 12:31:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WmXZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>StructGPT, proposed by Jiang et. al. is an iterative read-and-reason approach to improve the zero-shot capabilities of LLMs on structured data. The proposed method improves the performance of the LLMs on graphs and databases. Traditionally, LLMs are not good at these data structures since their format is absent from the training data. Hence, the method proposed gives a way to process the structured data and convert it into LLMs ingestable format using linearization.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WmXZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WmXZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WmXZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png" width="558" height="558" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bac4978b-407d-4284-8672-75909f385100_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:558,&quot;bytes&quot;:1738566,&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;: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_!WmXZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!WmXZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbac4978b-407d-4284-8672-75909f385100_1024x1024.png 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></figure></div><p>In this post, let&#8217;s explore how it works.</p><h2>Structured Data Types</h2><p>There are 3 types of data considered in this approach</p><ol><li><p>Knowledge Graph</p><p>A set of triplets. Each triplet {x1, r, x2} represents there is a relation r between the head entity x1 and tail entity x2.</p></li><li><p>Data Table</p><p>A table with c columns and r rows.</p></li><li><p>Database</p><p>A set of Data Tables with some relations between the tables represented using foreign keys.</p><p></p></li></ol><h2>Working</h2><p>Based on the 3 data types, there are 3 tasks that StructGPT can solve:</p><h2>KG-based question answering (KGQA)</h2><h3>Setup</h3><p>An intuitive approach is to start from the head entity of the query and jump along various relations that have the head as the tail of the n-1th relation. For example, if we start from with the relation {x1, r, x2}, and we also have {x2, r, x3}, we can move from x1 to x3 via x2.</p><p>The two functions used for this are:</p><ul><li><p>Extract_Neighbor_Relations(e): extracts all the neighbouring relations of the entity e.</p></li><li><p>Extract_Triples (e, {r}): extracts all the triples with the relation in {r} and head entity e.</p></li></ul><h3>Implementation</h3><ol><li><p>Call Extract_Neighbor_Relations(e) to get all the one-hop relations.</p></li><li><p>Linearize the data to form text and feed it into the LLM to get useful relations from the set of all relations.</p></li><li><p>Call Extract_Tripets(e, {r}) to get all the head and tail of the useful relations.</p></li><li><p>Linearize into text, and feed to LLMs to get the answer which will be the tails of the most relevant triplets.</p></li></ol><p></p><h2>Table-based question answering (TableQA)</h2><h3>Setup</h3><p>The goal here is for the LLMs to choose the relevant columns based on the query and then scan them row by row to get the exact sub-table required for generating the response. The methods used for this are:</p><ul><li><p>Extract_Column_Name (T): extracts all the column names of a table T.</p></li><li><p>Extract_Columns (T, {c}): extracts the contents of columns from a table T by indices {c}.</p></li><li><p>Extract_SubTable (T, {c}, {j}): extracts the sub-table specified by the column indices {c} and row indices {j} from a table T.</p></li></ul><h3>Implementation</h3><ol><li><p>Call Extract_Column_Name (T) to get all the columns.</p></li><li><p>Linearize them to text and feed them into the LLM to get the relevant columns.</p></li><li><p>Get the content of the selected columns using Extract_Columns (T, {c}).</p></li><li><p>Get useful rows from the column content using LLM query.</p></li><li><p>Use Extract_SubTable (T, {c}, {j}) to build a new table as the final input to the LLM. The response is the answer to the user query.</p></li></ol><p></p><h2>DB-based semantic parsing (Text-to-SQL)</h2><h3>Setup</h3><p>The process is similar to that of the data table, however, there is an additional step of identifying which tables to use from the DB. The methods used for this are:</p><ul><li><p>Extract_Table &amp; Column_Name (D): extracts the names of all the tables and their contained columns from the database.</p></li><li><p>Extract_Tables_Information ({T}): extracts the table names, column names, and foreign keys from a set of tables {T}.</p></li></ul><h3>Implementation</h3><ol><li><p>Get the relevant table as well as relevant columns using Extract_Table &amp; Column_Name (D).</p></li><li><p>Call Extract_Tables_Information ({T}) to get the data from selected tables.</p></li><li><p>Linearize the data and feed it into the LLM to get the answer.</p></li></ol><p></p><p>Here is an illustration of the architecture given in the paper:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Oies!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Oies!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 424w, https://substackcdn.com/image/fetch/$s_!Oies!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 848w, https://substackcdn.com/image/fetch/$s_!Oies!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 1272w, https://substackcdn.com/image/fetch/$s_!Oies!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Oies!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png" width="648" height="551.7623762376238" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:688,&quot;width&quot;:808,&quot;resizeWidth&quot;:648,&quot;bytes&quot;:211660,&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_!Oies!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 424w, https://substackcdn.com/image/fetch/$s_!Oies!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 848w, https://substackcdn.com/image/fetch/$s_!Oies!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.png 1272w, https://substackcdn.com/image/fetch/$s_!Oies!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e337419-8a50-4e85-891d-b9e4b6e7bc94_808x688.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></figure></div><p></p><h2>Conclusion</h2><p>LLMs are getting better at various tasks day by day. As seen in this paper, one of the crucial tasks that seem to occur in various fine-tuning tasks is to linearize the raw data into a format that the LLM can process. With better linearization, LLMs will be able to solve more generalized tasks efficiently.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/pdf/2305.09645.pdf">StructGPT Paper</a></p></li><li><p><a href="https://github.com/RUCAIBox/StructGPT/tree/e5b38fc3b9ef0ed0ac145d525ea82e568994c26e">GitHub Repo</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #12: System Design for Machine Learning - Part II]]></title><description><![CDATA[Exploring case studies to see how frameworks are applied in production]]></description><link>https://decodingcoding.substack.com/p/newsletter-12-system-design-for-machine</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-12-system-design-for-machine</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 18 May 2023 12:31:14 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!Yrwm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the last post, we explored the basic principles that can be used while designing a Machine Learning System. In this post, let&#8217;s look at a couple of case studies and how they applied these principles.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Yrwm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Yrwm!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Yrwm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png" width="556" height="556" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:556,&quot;bytes&quot;:1738566,&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;: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_!Yrwm!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!Yrwm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1b71a691-33c1-4f7c-a776-33767530c539_1024x1024.png 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></figure></div><h2>Case Study 1: Predicting LTV at Airbnb</h2><p>LTV stands for Customer Lifetime Value, meaning the amount of money a customer will spend once he signs up. Usually, this value is determined using historical data, but Airbnb took it a step further and built a model to predict the LTV of new listings.</p><h3>Feature engineering</h3><p>Airbnb used their internal tool Zipline, which allows the user to select features vetted on past projects. If a feature is unavailable, the user can create a new feature that is added to Zipline for further use. A configuration file is used to specify which features are to be picked up from the data. The LTV model had over 150 features!</p><h3>Prototyping and Model Training</h3><p>Rapid prototyping is essential when you have many features to choose from and many models that can be used for prediction. For feature selection, they used the pipelines available in Scikit-Learn. Here is a simple code given by the author:</p><pre><code>transforms = []

transforms.append(
    ('select_binary', ColumnSelector(features=binary))
)

transforms.append(
    ('numeric', ExtendedPipeline([
        ('select', ColumnSelector(features=numeric)),
        ('impute', Imputer(missing_values='NaN', strategy='mean', axis=0)),
    ]))
)

for field in categorical:
    transforms.append(
        (field, ExtendedPipeline([
            ('select', ColumnSelector(features=[field])),
            ('encode', OrdinalEncoder(min_support=10))
            ])
        )
    )
    
features = FeatureUnion(transforms)</code></pre><p>Using this pipeline as well as estimators, models can be trained quickly and iteratively.</p><h3>Deployment</h3><p>Airbnb uses a framework called AirFlow that automates the process of deployment. The design is as follows:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Rloh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Rloh!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 424w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 848w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 1272w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Rloh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png" width="652" height="396.51642129105323" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:537,&quot;width&quot;:883,&quot;resizeWidth&quot;:652,&quot;bytes&quot;:232823,&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_!Rloh!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 424w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 848w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.png 1272w, https://substackcdn.com/image/fetch/$s_!Rloh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0bdd52dd-febc-4040-81ff-dbf2da017eba_883x537.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></figure></div><p>The framework needs two inputs:</p><ul><li><p>Model Config: Tells the location of training data, how to compute scores and how many resources to allocate.</p></li><li><p>Fit and transform functions: They specify how to train the model and score the model respectively.</p></li></ul><p>As we see the process follows a similar flow as described in the last post. Now let&#8217;s take a look at another case study, of Chicisimo.</p><p></p><h2>Case Study 2: Using ML to Boost the fashion advice</h2><p>Chicisimo&#8217;s goal was to use ML to learn the user&#8217;s fashion preferences and give them advice just like a friend would. Let&#8217;s look at how they set up their system.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LS86!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LS86!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 424w, https://substackcdn.com/image/fetch/$s_!LS86!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 848w, https://substackcdn.com/image/fetch/$s_!LS86!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 1272w, https://substackcdn.com/image/fetch/$s_!LS86!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LS86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512" width="366" height="366" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:&quot;normal&quot;,&quot;height&quot;:512,&quot;width&quot;:512,&quot;resizeWidth&quot;:366,&quot;bytes&quot;:null,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:null,&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_!LS86!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 424w, https://substackcdn.com/image/fetch/$s_!LS86!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 848w, https://substackcdn.com/image/fetch/$s_!LS86!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 1272w, https://substackcdn.com/image/fetch/$s_!LS86!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ef141ae-9f1c-4e54-9d7b-74977c2ea14c_512x512 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></figure></div><h3>Data Gathering</h3><p>Chicisimo used the data provided by their users to build and update their dataset. This included objective features such as size, price, colour, type, etc as well as subjective features such as styles, occasions, etc.</p><p>They built a Social Fashion Graph to make the data actionable. This graph connected outfits, needs and people to each other. They thought of outfits as a playlist of various single items.</p><p>Since people can describe a similar outfit in various ways, they also build another tool called fashion ontology which is a multi-level descriptor of outfits or an n-ary tree.</p><h3>Model Building</h3><p>Chicisimo built a recommendation system on top of the fashion ontology tool. It allowed them to use the descriptors as meta-products and club similar products together. This solved the problem of the confusion caused by different product descriptions for the same product.</p><h2>Conclusion</h2><p>Case studies are an effective way to learn about how frameworks are applied in production. There are always a few changes required due to the specific requirements of a project. Hence I feel you need both, a framework to guide you when you start a new project and enough knowledge from case studies to understand that no framework will give you the full solution, but only a helping hand.</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://medium.com/airbnb-engineering/using-machine-learning-to-predict-value-of-homes-on-airbnb-9272d3d4739d">Airbnb Blog</a></p></li><li><p><a href="https://medium.com/hackernoon/how-we-grew-from-0-to-4-million-women-on-our-fashion-app-with-a-vertical-machine-learning-approach-f8b7fc0a89d7">Chicisimo Blog</a></p></li></ol><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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[Newsletter #11: System Design for Machine Learning - Part I]]></title><description><![CDATA[Exploring how to build and deploy machine learning systems]]></description><link>https://decodingcoding.substack.com/p/newsletter-11-system-design-for-machine</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-11-system-design-for-machine</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 04 May 2023 12:30:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!bEYT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>We all start out by coding and training ML models on test environments (usually our PC), to get a hang of how to build the models, how they work and a few use cases. However, building and deploying ML models in the real world takes much more than just coding and training the model. In this first, of a two-part, post, we will explore other basics of designing an ML system. In the next post, we examine a few use cases of how different companies deployed their ML models.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!bEYT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!bEYT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!bEYT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg" width="422" height="422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/80601924-ad6c-488b-81cf-829877ff38f7_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;:422,&quot;bytes&quot;:124146,&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_!bEYT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!bEYT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F80601924-ad6c-488b-81cf-829877ff38f7_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></figure></div><p>While reading the articles on ML System Design, I found that most of them start with data gathering and preparation. Although this is a crucial step, I found the first step described by Chip Huyen, particularly interesting. Hence I will start the article there.</p><h2>Step 1: Setting up the project</h2><p>Even before you start looking at which datasets you can use, you need to define the goals of the project. Here are a few questions you can ask:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!v0QD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!v0QD!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!v0QD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg" width="436" height="436" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/40a60e22-5722-455c-ad47-2cd38e9e6376_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;:436,&quot;bytes&quot;:40231,&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;: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_!v0QD!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!v0QD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F40a60e22-5722-455c-ad47-2cd38e9e6376_512x512.jpeg 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></figure></div><ol><li><p>Goal: What are you trying to achieve? Why is ML useful for achieving the goal?</p></li><li><p>User experience: What should the end UX be like? For example, DALL.E.2 is intended for everyone, whereas Generative Disco is intended for people with a background in video editing.</p></li><li><p>Constraints: These can be constraints regarding the resources like hardware, cost, etc. or software, like using a particular framework or platform.</p></li><li><p>Evaluation: How do you define the criteria to judge the performance?</p></li></ol><h2>Step 2: Setting up the Data Pipeline</h2><p>The data pipeline is the process of collecting, preparing and doing an exploratory analysis of the data. Once this is done, you can get an idea about the important and non-important parts of the data which will be useful in feature engineering.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!a7wx!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!a7wx!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!a7wx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg" width="502" height="502" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_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;:502,&quot;bytes&quot;:65133,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&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_!a7wx!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!a7wx!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fad0ba3fc-b8c9-4d81-8ac5-cc331a394a45_512x512.jpeg 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></figure></div><p>Here are a few things to consider:</p><ol><li><p>Data Source: Where is the data coming from? Do we need additional data? If yes, how to generate it?</p></li><li><p>Data Storage: Which is the most effective and efficient form of storage?</p></li><li><p>Data preparation and exploration: As mentioned before, this step is necessary to get an idea about measures of central tendency, which features are useful, etc.</p></li><li><p>Privacy issues and Bias analysis: As ML models integrate more into our lives, this is a crucial step while using data. The data that is collected should be collected with consent and the bias if present should be removed to ensure a neutral model.</p></li></ol><p>The Data Pipeline should also include a runtime component which will take real-time data and integrate it into future training iterations.</p><h2>Step 3: Modelling</h2><p>In addition to model selection and model training, this stage also includes feature engineering, hyper-parameter tuning, scaling, etc.</p><p>Model selection is largely based on what the goal is, and hence will depend on how well the project is set up. In addition to looking at obvious things like supervised vs unsupervised, and regression vs classification, an important thing to keep in mind is the resource constraints.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Tg2b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Tg2b!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Tg2b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg" width="462" height="462" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a152a292-b8b9-47b7-92a2-306e2612f56c_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;:462,&quot;bytes&quot;:52780,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&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_!Tg2b!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Tg2b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa152a292-b8b9-47b7-92a2-306e2612f56c_512x512.jpeg 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></figure></div><p>Even though it might be tempting to always choose a neural net of some sort, it is expensive to train and hard to debug. Hence it&#8217;s a good idea to give the &#8220;traditional&#8221; models like KNN, K-means, Decision trees, etc before trying out deep learning models.</p><p>Feature engineering is choosing which features your model will use to make predictions. This will depend on how much of an impact feature X has on the outcome. Methods such as PCA can be used to remove redundant features.</p><p>Hyper-parameters are meta-feature that affect the performance of the model. For example, learning rate, temperature, etc. Techniques such as grid search, random search, Bayesian optimization, etc. can be used for choosing between different hyper-parameter values.</p><h2>Step 4: Deployment</h2><p>For ML models, the deployment is not as simple as a deployment for a website. In addition to the software component used during deployment, the hardware consideration is just as important for initial deployment as well as scaling requirements.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!nBFP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!nBFP!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!nBFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg" width="478" height="478" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9df328a3-d54f-4a0a-811f-efe7b2673b98_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;:478,&quot;bytes&quot;:56924,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&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_!nBFP!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!nBFP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9df328a3-d54f-4a0a-811f-efe7b2673b98_512x512.jpeg 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></figure></div><p>Here are a few things to consider while deploying a model:</p><p>Hardware requirement: How will the model be trained? What are the hardware resources required (GPUs, TPUs, etc.) How will these resources be scaled up if required?</p><p>Software requirements: Where to deploy a model &#8212; on the user&#8217;s device (dedicated app) or a website? How do set up loops to get real-time data into the future training process?</p><p>These are the 4 main components that I learned while doing research for this article. I feel they provide a good framework to think about how we can set up a production-level ML project. If you have any suggestions or experience to improve this framework, please reply to this email or leave a comment!</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://huyenchip.com/machine-learning-systems-design/design-a-machine-learning-system.html">ML System Design Book by Chip Huyen</a></p></li><li><p><a href="https://www.automl.org/wp-content/uploads/2019/05/AutoML_Book_Chapter1.pdf">Auto-ML Book by Matthias Feurer and Frank Hutter</a></p></li><li><p><a href="https://towardsdatascience.com/what-is-machine-learning-system-design-interview-and-how-to-prepare-for-it-537d1271d754">Blog - What is ML system design</a></p></li><li><p><a href="https://www.youtube.com/playlist?list=PLmGsNPZGeM5D8fgr2scwe8wZih4SYB7Vt">A huge playlist on youtube with tons of videos on ML System design</a></p></li></ol><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p>]]></content:encoded></item><item><title><![CDATA[Newsletter #10: Generative Disco]]></title><description><![CDATA[From lyrics to video - Visualizing music]]></description><link>https://decodingcoding.substack.com/p/newsletter-10-generative-disco</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-10-generative-disco</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 27 Apr 2023 12:30:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!PyTX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Generative Disco is an AI system proposed by Liu et. al. that uses large-language models and text-to-image models to generate a video from music. Think DALL.E.2 and ChatGPT combined iteratively. In this post, let&#8217;s look at how it works.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PyTX!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PyTX!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PyTX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg" width="412" height="412" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d042db34-b8b5-402f-8859-fbab6cc25697_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;:412,&quot;bytes&quot;:81645,&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_!PyTX!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 424w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 848w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_512x512.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!PyTX!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd042db34-b8b5-402f-8859-fbab6cc25697_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></figure></div><h2>Design</h2><p>Generative AI has an algorithmic process to generate video from audio files. Below is the representation of all the steps to create a video.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WUXi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WUXi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 424w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 848w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 1272w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WUXi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png" width="462" height="445.16326530612247" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:686,&quot;resizeWidth&quot;:462,&quot;bytes&quot;:401451,&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_!WUXi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 424w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 848w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.png 1272w, https://substackcdn.com/image/fetch/$s_!WUXi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F43ed6b82-8e5e-401f-9172-e15d07fd6ff6_686x661.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></figure></div><p>These are some of the key features that I found while reading the paper:</p><h4>Intervals</h4><p>The process of video generation is done over user-defined intervals from a longer audio track. The users define START TIME and END TIME parameters to initialize an interval. In addition to the audio interval, the user also has to enter a high-level description of the interval which is used as the parent prompt.</p><p>An example given by the authors is after the description is entered, GPT-4 is used with the following prompt:</p><p>&#8220;In less than 5 words, describe an image for the following words {INTERVAL DESCRIPTION}.&#8221;</p><h4>START &amp; END Prompts</h4><p>The video is generated by interpolating between two images that define the start and end of the interval precisely. The user gives an image as well as a text prompt. These images signify the image with which the video will start and the image where it will end.</p><h4>Brainstorming area</h4><p>This is an interesting add-on that provides a way for the user to generate start and end prompts based on text. Just like in text-to-image models, users can also specify a style in which the image, and hence the video should be created.</p><p>The brainstorming area auto-populates some prompts based on the response of GPT-4 on the {INTERVAL DESCRIPTION} from step 1.</p><p>Multiple intervals are then stitched to create the final video.</p><h2>Examples</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!M50a!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!M50a!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 424w, https://substackcdn.com/image/fetch/$s_!M50a!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 848w, https://substackcdn.com/image/fetch/$s_!M50a!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 1272w, https://substackcdn.com/image/fetch/$s_!M50a!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!M50a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png" width="511" height="302" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c211f226-498d-463c-9fe6-e310396597be_511x302.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:302,&quot;width&quot;:511,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:183235,&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_!M50a!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 424w, https://substackcdn.com/image/fetch/$s_!M50a!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 848w, https://substackcdn.com/image/fetch/$s_!M50a!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.png 1272w, https://substackcdn.com/image/fetch/$s_!M50a!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc211f226-498d-463c-9fe6-e310396597be_511x302.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!DeMi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!DeMi!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 424w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 848w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 1272w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!DeMi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png" width="504" height="293" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:293,&quot;width&quot;:504,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:202996,&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_!DeMi!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 424w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 848w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.png 1272w, https://substackcdn.com/image/fetch/$s_!DeMi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa7bdc126-bc0d-4dae-a229-a9f03a0ae207_504x293.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></figure></div><h2>Conclusion</h2><p>Video generation and editing have always been difficult and tedious tasks. Doing it requires deep domain knowledge in terms of various heavy applications like Adobe Premier Pro, FinalCut Pro, etc. AI can help to democratize this process by leveraging LLMs and text-to-image models. This is definitely a super early version of what future video generation and editing might look like and I am excited to see what&#8217;s next!</p><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><p>PS: <a href="https://twitter.com/AMAZlNGNATURE/status/1650979239104245761?s=20">Fun and sweet :)</a></p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/abs/2304.08551">Generative Disco Paper</a></p></li></ol><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p>]]></content:encoded></item><item><title><![CDATA[Newsletter #9: Building a Brain with LLM]]></title><description><![CDATA[Using LLMs to Design a Brain for Robots]]></description><link>https://decodingcoding.substack.com/p/newsletter-9-building-a-brain-with</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-9-building-a-brain-with</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 20 Apr 2023 12:30:21 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!4Dpl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>In the <a href="https://decodingcoding.substack.com/p/newsletter-8-hugginggpt">last post</a>, we explored HuggingGPT which proposed using ChatGPT to take autonomous programming a step further. In this post, we look at how LLMs can be used as a Robotic Brain. The paper &#8216;LLM as A Robotic Brain: Unifying Egocentric Memory and Control&#8217; by Mai et. al., proposes using zero-shot learning to model and language-based communication between different LMs to build a Brain.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4Dpl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4Dpl!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4Dpl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png" width="376" height="376" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:376,&quot;bytes&quot;:1603338,&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;: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_!4Dpl!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!4Dpl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F171b1c67-0811-4e4f-bf47-7d28686485c6_1024x1024.png 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></figure></div><h2>Design</h2><p>The setup consists of 3 parts, The Eye, The Nerve and The Brain.</p><h3>The Eye</h3><p>The Eye is a Visual Language Model (VLM). Its goal is to capture the environment's visual information and answer related questions. The Nerve asks the questions and aims to use visual information to answer them in Natural Language.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!rvB1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!rvB1!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 424w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 848w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 1272w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!rvB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png" width="689" height="129" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:129,&quot;width&quot;:689,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:27047,&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_!rvB1!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 424w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 848w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 1272w, https://substackcdn.com/image/fetch/$s_!rvB1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23604144-2820-4bf1-8893-5469c1ad02d2_689x129.png 1456w" sizes="100vw"></picture><div></div></div></a></figure></div><h3>The Nerve</h3><p>The Nerve perform 2 actions</p><ol><li><p>Asking detailed questions regarding the environment to The Eye.</p></li><li><p>Summarising the answers and generating the corresponding possible robot actions.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!0ETy!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!0ETy!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 424w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 848w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 1272w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!0ETy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png" width="687" height="128" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/19176bba-9194-4d9c-9384-070940fe9a40_687x128.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:128,&quot;width&quot;:687,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:34858,&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_!0ETy!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 424w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 848w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 1272w, https://substackcdn.com/image/fetch/$s_!0ETy!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F19176bba-9194-4d9c-9384-070940fe9a40_687x128.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3>The Brain</h3><p>The Brain is responsible for the following tasks:</p><ol><li><p>Memorising the 3D environment based on the description given by The Nerve.</p></li><li><p>Planning future actions of the robot.</p></li><li><p>Control the actions of the robot based on the current scene and memory.</p></li></ol><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yjKd!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yjKd!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 424w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 848w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 1272w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yjKd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png" width="702" height="145" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8056070d-0379-4610-bb32-d43fc25e912b_702x145.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:145,&quot;width&quot;:702,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:38107,&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_!yjKd!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 424w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 848w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 1272w, https://substackcdn.com/image/fetch/$s_!yjKd!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8056070d-0379-4610-bb32-d43fc25e912b_702x145.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h2>Execution</h2><p>The pipeline has 5 stages:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!SYiT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!SYiT!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 424w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 848w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 1272w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!SYiT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png" width="746" height="464" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:464,&quot;width&quot;:746,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:233176,&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_!SYiT!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 424w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 848w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.png 1272w, https://substackcdn.com/image/fetch/$s_!SYiT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9ab3830b-abf4-47b3-abc8-8ea60a2536b5_746x464.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></figure></div><ol><li><p>Role Initialization</p><p>This is a detailed prompt to set up the 3 agents.</p></li><li><p>Eye-Nerve Perception</p><p>This is an iterative process where The Nerve repeatedly asks questions to The Eye to get as detailed a view of the environment as possible.</p></li><li><p>Brain-Nerve Collaboration</p><p>The Brain acts as a higher-level agent and instructs the next steps to The Nerve.</p></li><li><p>Brain Reasoning and Control</p><p>Using the power of LLMs, The Brain reasons about the most optimal action to take based on current inputs. (<a href="https://decodingcoding.substack.com/i/111570669/chain-of-thought-prompting">Recall Chain-of-Thoughts prompts of LLMs</a>)</p></li><li><p>Brain-Human Interaction</p><p>The Brain of the robot is also responsible to interact with the user.</p></li></ol><h2>Example</h2><h4>Initialization</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!jSTB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!jSTB!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 424w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 848w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 1272w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!jSTB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png" width="1213" height="403" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:403,&quot;width&quot;:1213,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:159487,&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_!jSTB!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 424w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 848w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.png 1272w, https://substackcdn.com/image/fetch/$s_!jSTB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77df11fb-fbe8-4d6d-a36c-6549e723f9e0_1213x403.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></figure></div><h4>Working</h4><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Q_Ya!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 424w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 848w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 1272w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png" width="612" height="471.26132404181186" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:663,&quot;width&quot;:861,&quot;resizeWidth&quot;:612,&quot;bytes&quot;:389158,&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_!Q_Ya!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 424w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 848w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.png 1272w, https://substackcdn.com/image/fetch/$s_!Q_Ya!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe86a2b52-7054-478f-a5a8-6701ed69f2f1_861x663.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></figure></div><h2>Conclusion</h2><p>LLMs are getting more deeply integrated into various aspects of programming. As the LLMs&#8217;s ability to be effective at reasoning improves, we might get truly, fully autonomous agents, which given a task, choose the models, methods and information required to achieve it. This is an exciting time in the field of Computer Science and probably also human history!</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/abs/2304.09349">LLM Brain Paper</a></p></li></ol><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p>]]></content:encoded></item><item><title><![CDATA[Newsletter #8: HuggingGPT]]></title><description><![CDATA[A step closer to an autonomous digital programmer]]></description><link>https://decodingcoding.substack.com/p/newsletter-8-hugginggpt</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-8-hugginggpt</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 06 Apr 2023 12:30:52 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!MBXb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>LLMs are good at coming up with solutions to simple tasks. However, they fail at achieving complex tasks which require multiple steps and coordination between various steps. HuggingGPT is a new model proposed by Shen et. al. that uses LLMs to plan tasks, choose an appropriate model, execute the tasks, and generate a solution. In this post, we explore how it works. The model combines the ability of LLMs to deconstruct and understand human prompts and use them to plan and execute subtasks using the HuggingFace AI models.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!MBXb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!MBXb!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!MBXb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png" width="476" height="476" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:476,&quot;bytes&quot;:1349575,&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;: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_!MBXb!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!MBXb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0a76fa4a-e2fa-4427-848d-6145fb61ebbe_1024x1024.png 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></figure></div><p></p><h2>Why is HuggingGPT required?</h2><p>The authors note that despite the recent advances in LLMs, the current models lack the following abilities:</p><ol><li><p>The lack of ability to process complex data such as speech, images, videos, etc.</p></li><li><p>Creating, scheduling and coordinating between multiple sub-tasks.</p></li><li><p>Not being able to perform well at specialized tasks like image recognition in comparison to fine-tuned models such as a CNN.</p></li></ol><p>The authors propose using LLMs as an interface to connect different AI models and use the LLM as a brain to plan and execute the tasks required to complete the larger goal.</p><p></p><h2>Model Architecture</h2><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4Ut9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4Ut9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 424w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 848w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 1272w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4Ut9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png" width="962" height="576" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:576,&quot;width&quot;:962,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:304440,&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_!4Ut9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 424w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 848w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.png 1272w, https://substackcdn.com/image/fetch/$s_!4Ut9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe703161d-15cb-4ab9-917b-6c750f4e93e7_962x576.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></figure></div><p>The proposed model has 4 stages:</p><ul><li><p>Task Planning</p></li><li><p>Model Selection</p></li><li><p>Task Execution</p></li><li><p>Response Generation</p></li></ul><p></p><h3>Task Planning</h3><p>In this stage, the goal is divided into sub-tasks using LLMs such as ChatGPT.</p><p>Each task object contains the following attributes:</p><ul><li><p>Task ID: Unique Identifier</p></li><li><p>Task Dependencies: A list of task ids that must be completed stated before this task can be executed</p></li><li><p>Task Type: Type of current task. Here is an image showing the tasks supported by the model</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!LWcI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!LWcI!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 424w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 848w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 1272w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!LWcI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png" width="963" height="326" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:326,&quot;width&quot;:963,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:86790,&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_!LWcI!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 424w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 848w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.png 1272w, https://substackcdn.com/image/fetch/$s_!LWcI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0caea313-d792-45cd-998b-4e3e9cb01d18_963x326.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></figure></div></li><li><p>Task Arguments: The data required to execute the task, like params of a function.</p></li></ul><h3>Model Selection</h3><p>The model selection is done by using 3 things:</p><ul><li><p>The model description, given by the authors of AI models in HuggingFace.</p></li><li><p>The task type.</p></li><li><p>The original user query.</p></li></ul><p>The models are filtered out by task type and then by the number of downloads of the models. K top models are given to HuggigGPT. It uses these models to solve a single-choice problem based on the above parameters.</p><h3>Task Execution</h3><p>Tasks are executed according to dependencies and the results are stored in order.</p><p>The architecture also proposed using local models in addition to HuggingFace API to improve speed and efficiency.</p><h3>Response Generation</h3><p>HuggingGPT uses ChatGPT to generate a response using the output of the previous 3 stages. The Output shows all the steps taken by the model to get the final result.</p><p></p><h3>Example and Code</h3><p>Here is an example of the model in action:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!Pqzw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!Pqzw!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!Pqzw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg" width="656" height="652.8410914927769" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1240,&quot;width&quot;:1246,&quot;resizeWidth&quot;:656,&quot;bytes&quot;:1200796,&quot;alt&quot;:null,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpeg&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_!Pqzw!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 424w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 848w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 1272w, https://substackcdn.com/image/fetch/$s_!Pqzw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F06378ac0-ac1e-4c03-b3b1-e2d77de5d927_1246x1240.jpeg 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></figure></div><p>You can find the <a href="https://github.com/microsoft/JARVIS">complete code to an application called Jarvis here</a>. Let&#8217;s take look at the driver function that integrates all the steps we have seen.</p><pre><code>def chat_huggingface(messages, openaikey = None):
    start = time.time()

    #Get the messages parsed from user query
    context = messages[:-1]
    input = messages[-1]["content"]
    logger.info("*"*80)
    logger.info(f"input: {input}")
&#9;&#9;
&#9;&#9;
    task_str = parse_task(context, input, openaikey).strip()
    logger.info(task_str)

    if task_str == "[]":  # using LLM response for empty task
        record_case(success=False, **{"input": input, "task": [], "reason":   "task parsing fail: empty", "op": "chitchat"})
        response = chitchat(messages, openaikey)
        return {"message": response}
    try:
        #Get tasks STAGE 1
        tasks = json.loads(task_str)
    except Exception as e:
        logger.debug(e)
        response = chitchat(messages, openaikey)
        record_case(success=False, **{"input": input, "task": task_str, "reason": "task parsing fail", "op":"chitchat"})
        return {"message": response}
    

    tasks = unfold(tasks)
    tasks = fix_dep(tasks)
    logger.debug(tasks)

    results = {}
    processes = []
    tasks = tasks[:]
    with  multiprocessing.Manager() as manager:
        d = manager.dict()
        retry = 0
        while True:
            num_process = len(processes)
            #Start Task Execution
            for task in tasks:
                dep = task["dep"]
                if len(list(set(dep).intersection(d.keys()))) == len(dep) or dep[0] == -1:
                    tasks.remove(task)
                    #STAGE 2 and STAGE 3
                    #run_task function does actual model inference and task execution i.e
                    process = multiprocessing.Process(target=run_task, args=(input, task, d, openaikey))
                    process.start()
                    processes.append(process)
            if num_process == len(processes):
                time.sleep(0.5)
                retry += 1
            if retry &gt; 160:
                logger.debug("User has waited too long, Loop break.")
                break
            if len(tasks) == 0:
                break
        for process in processes:
            process.join()
        
        results = d.copy()
    logger.debug(results)

    #Generate Response STAGE 4
    response = response_results(input, results, openaikey).strip()

    end = time.time()
    during = end - start

    answer = {"message": response}
    record_case(success=True, **{"input": input, "task": task_str, "results": results, "response": response, "during": during, "op":"response"})
    logger.info(f"response: {response}")
    return answer

</code></pre><p>I have mentioned the different stages in the comments above. In this code, the tasks are taken from a predefined demo file. The run_task function checks the dependency array (deps) and selects a model to execute the tasks.</p><p>If you want to dive in deeper, the repo link is given above.</p><h3>Conclusion</h3><p>Even though programs like GitHub Co-Pilot have made good strides in AI programming, it still requires a lot of human input. To build truly autonomous coding bots we need systems that can not only write the code to the specification but also execute tasks such that they are sufficiently atomic and well coordinated.</p><p>Systems like HuggingGPT will help to make coding bots more efficient and help in rapid prototyping. Hence, at least in the short term, make programmers vastly more productive.</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/abs/2303.17580">HuggingGPT Paper</a></p></li><li><p><a href="https://github.com/microsoft/JARVIS">Jarvis GitHub Repo</a></p></li></ol><div><hr></div><p>PS: An official version might be available soon! &#128562;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!QN3O!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!QN3O!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 424w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 848w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 1272w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!QN3O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png" width="484" height="248.93315143246932" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:377,&quot;width&quot;:733,&quot;resizeWidth&quot;:484,&quot;bytes&quot;:260924,&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_!QN3O!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 424w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 848w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.png 1272w, https://substackcdn.com/image/fetch/$s_!QN3O!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4e91e2d2-aa00-42d3-ac1b-bbe9bb4cdff1_733x377.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></figure></div><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p>]]></content:encoded></item><item><title><![CDATA[Newsletter #7: Advanced Prompt Engineering]]></title><description><![CDATA[Learning Zero-shot, Few-shot and Chain-of-thought prompts]]></description><link>https://decodingcoding.substack.com/p/newsletter-7-advanced-prompt-engineering</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-7-advanced-prompt-engineering</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 30 Mar 2023 12:31:01 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!WrcC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p><a href="https://decodingcoding.substack.com/p/newsletter-6-prompt-engineering">In the last post</a>, we looked at some of the basic prompting types. In this post, we take a look at 3 advanced types of prompts. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!WrcC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!WrcC!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!WrcC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png" width="442" height="442" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:442,&quot;bytes&quot;:1501904,&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;: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_!WrcC!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!WrcC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F356a9da9-52c1-49ce-866f-25467253d375_1024x1024.png 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></figure></div><h2>Zero-Shot Prompting</h2><p>As the name suggests, zero-shot prompting is using the model to directly reason or analyse a given input. This means you do not provide any example in the input of what the desired output should be like. </p><p>For example, if we want to generate a poem about winter, we can give the model a prompt like "Explain AI." The model can then generate a poem based on its pre-existing knowledge about winter.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!xRez!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!xRez!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 424w, https://substackcdn.com/image/fetch/$s_!xRez!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 848w, https://substackcdn.com/image/fetch/$s_!xRez!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 1272w, https://substackcdn.com/image/fetch/$s_!xRez!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!xRez!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png" width="568" height="334.35460992907804" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:581,&quot;width&quot;:987,&quot;resizeWidth&quot;:568,&quot;bytes&quot;:95758,&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_!xRez!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 424w, https://substackcdn.com/image/fetch/$s_!xRez!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 848w, https://substackcdn.com/image/fetch/$s_!xRez!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.png 1272w, https://substackcdn.com/image/fetch/$s_!xRez!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F47ea1262-3181-438e-9ded-52f4cb64c852_987x581.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></figure></div><p>The model generates an output based on its pre-existing knowledge about the task at hand. This is useful when there is no specific training data available for a particular task.</p><h2>Few-shot prompting</h2><p>When zero-shot prompting fails, few-shot prompting can be used to improve the output. This was proposed by <a href="https://arxiv.org/pdf/2005.14165.pdf">Brown et. al.</a> and it involves giving a few examples of what the desired output should look like. </p><p>Here is an example given in the paper:<br><em><strong>Prompt:</strong> A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is: We were travelling in Africa and we saw these very cute whatpus. </em></p><p><em>To do a "farduddle" means to jump up and down really fast. An example of a sentence that uses the word farduddle is: </em></p><p><em><strong>Response:</strong> One day when I was playing tag with my little sister, she got really excited and she started doing these crazy farduddles.</em></p><p>Here&#8217;s the prompt fed into ChatGPT</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!5XbM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!5XbM!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 424w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 848w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 1272w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!5XbM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png" width="985" height="404" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:404,&quot;width&quot;:985,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:56411,&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_!5XbM!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 424w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 848w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.png 1272w, https://substackcdn.com/image/fetch/$s_!5XbM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51b31c94-32ee-4710-a529-66b6dc55a71e_985x404.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></figure></div><p><br>Even though the words are not part of the training data, few-shot prompting helped the LLM to reason about how the word should be used based on the context in which it appeared.</p><h2>Chain-of-thought prompting</h2><p>CoT prompting was introduced by <a href="https://arxiv.org/pdf/2201.11903.pdf">Wei et. al.</a> It involves prompting a complex series of steps to get to the desired output. Using the logic followed in the prompt, the LLM is able to solve similar problems. <br>For example,</p><p><em><strong>Prompt: </strong></em></p><p><em>Roger has 5 tennis balls. He buys 2 more cans of tennis balls. Each can have 3 tennis balls. How many tennis balls does he have now?  </em></p><p><em>Roger started with 5 balls. 2 cans of 3 tennis balls each is 6 tennis balls. 5 + 6 = 11. The answer is 11. </em></p><p><em>The cafeteria had 23 apples. If they used 20 to make lunch and bought 6 more, how many apples do they have?</em></p><p><em><strong>Output:</strong></em></p><p><em>The cafeteria had 23 apples originally. They used 20 to make lunch. So they had 23 - 20 = 3. They bought 6 more apples, so they have 3 + 6 = 9. The answer is 9.</em></p><p></p><p>In the prompt, we provide not only the correct answer but also how we got to it. Using similar reasoning, the LLM will respond to the next question. The early versions of GPT-3 used to fail to solve such problems without explicit CoT. <br></p><p>CoT helps to make the LLM model reason better on various tasks such as arithmetic reasoning, common sense reasoning, instruction and planning, etc. </p><p>One note here, the authors in the paper have mentioned,</p><p><em>&#8220;Through experiments on arithmetic, symbolic, and commonsense reasoning, we find that chain-of-thought reasoning is an emergent property of model scale that allows sufficiently large language models to perform reasoning tasks that otherwise have flat scaling curves.&#8220;</em></p><p>Hence CoT might not work on smaller LLMs.</p><h2>Conclusion </h2><p>Advanced prompting techniques like zero-shot prompting, few-shot prompting, and chain-of-thought prompting are powerful tools in the field of machine learning. These techniques enable models to generate outputs for tasks that they have never seen before and to generate complex outputs that require multiple steps.</p><p>Learning these will help us to use LLMs efficiently and get the most out of them.</p><div><hr></div><h3>&#128214;Resources</h3><ol><li><p><a href="https://arxiv.org/pdf/2005.14165.pdf">Few-shot prompting paper</a></p></li><li><p><a href="https://arxiv.org/pdf/2201.11903.pdf">Chain-Of-Thought prompting paper</a></p></li><li><p><a href="https://github.com/dair-ai/Prompt-Engineering-Guide/">Dair-ai: Prompt-Engineering-Guide</a></p></li></ol><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p><p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Newsletter #6: Prompt Engineering]]></title><description><![CDATA[Learning to write good prompts for ChatGPT]]></description><link>https://decodingcoding.substack.com/p/newsletter-6-prompt-engineering</link><guid isPermaLink="false">https://decodingcoding.substack.com/p/newsletter-6-prompt-engineering</guid><dc:creator><![CDATA[Prathmesh Deshpande]]></dc:creator><pubDate>Thu, 23 Mar 2023 12:30:13 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!j1xn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>With the rise of Large Language Models (LLMs) such as GPT, prompt engineering has become increasingly important in the field of natural language processing. Prompt engineering involves crafting high-quality prompts that can guide the behaviour of LLMs, improving their accuracy and relevance. In this post, let&#8217;s take a look at how to design prompts to get the most out of one of the most famous LLMs, ChatGPT.</p><p></p><h2>Intuition</h2><p>Large Language Models (LLMs) predict the probability of a sequence of words in a given context. In other words, given a sequence of words W0&#8230;.Wn, an LLM predicts the Wn+1.</p><p>Hence the quality of the prompt and subsequently the response depends on the context created by the prompt.</p><p>Let's take a straightforward example to understand why context matters:</p><p>We want to complete the sentence, &#8220;I want to [LLM RESPONSE]&#8221;</p><p>Now with absolutely no context, you can pretty much have millions of options to choose from (Basically, anything under the sun). However, adding a simple context, &#8220;I am hungry. I want to [LLM RESPONSE]&#8221; narrows it down to just a few options.</p><p>Now even though this example was very trivial, this pattern holds true for any prompt no matter how complex the thing it is trying to achieve. The better the context that can be inferred from your prompt, the better response the model will generate.</p><p></p><h2>Exploring different types of prompts</h2><h3>Summarization</h3><p>Text summarization is probably one of the most valuable applications of LLMs. You can quickly generate a short explanation for various concepts.</p><p>To get a good summary, give prompts that have quantifiable parameters. For example, instead of the input - summarize this text, prompts like Explain to me like I&#8217;m 5 or give me an N sentence summary work much better.</p><p>I tried this with ChatGPT for one of my blogs, and here are the outputs:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!j1xn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!j1xn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 424w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 848w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 1272w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!j1xn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png" width="576" height="245.70252572497662" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:456,&quot;width&quot;:1069,&quot;resizeWidth&quot;:576,&quot;bytes&quot;:74751,&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_!j1xn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 424w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 848w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.png 1272w, https://substackcdn.com/image/fetch/$s_!j1xn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F054f5f02-911a-477a-857f-d2172bc1b0a9_1069x456.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="https://substackcdn.com/image/fetch/$s_!yDg0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!yDg0!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 424w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 848w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 1272w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!yDg0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png" width="584" height="212.4637134778511" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:386,&quot;width&quot;:1061,&quot;resizeWidth&quot;:584,&quot;bytes&quot;:62288,&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_!yDg0!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 424w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 848w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 1272w, https://substackcdn.com/image/fetch/$s_!yDg0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a1a3ff7-05cd-41b4-a2af-10d38cf0f048_1061x386.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!_oW9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!_oW9!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 424w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 848w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 1272w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!_oW9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png" width="582" height="502.3371040723982" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:763,&quot;width&quot;:884,&quot;resizeWidth&quot;:582,&quot;bytes&quot;:76224,&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_!_oW9!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 424w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 848w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.png 1272w, https://substackcdn.com/image/fetch/$s_!_oW9!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1aa8210-f08a-4752-8ebd-eafbe3d042f3_884x763.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></figure></div><p></p><p>You can further experiment with other prompts or other parameters. For example, <a href="https://www.neatprompts.com/p/supercharge-your-learning">the author in this post claims</a>, 11 is a good age to get a good result from the &#8216;Explain to me like I&#8217;m _____ prompt&#8217;!</p><p></p><h3>Text generation with the writing style</h3><p>After summarization, writing quick drafts is another useful application for LLMs.</p><p>In addition to the topic of the draft, you can ask it to write a blog in a particular author&#8217;s style.</p><p>For example, write an essay in the style of X. As an example, here&#8217;s a short note on the meaning of life in the style of Elon Musk, APJ Abdul Kalam, and me!</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!PmGc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!PmGc!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 424w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 848w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 1272w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!PmGc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png" width="550" height="382.156368221942" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:551,&quot;width&quot;:793,&quot;resizeWidth&quot;:550,&quot;bytes&quot;:50868,&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_!PmGc!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 424w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 848w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.png 1272w, https://substackcdn.com/image/fetch/$s_!PmGc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff36b72e7-211d-4522-8c3d-dddff712ffb8_793x551.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!pFdV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!pFdV!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 424w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 848w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 1272w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!pFdV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png" width="560" height="398.70324189526184" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:571,&quot;width&quot;:802,&quot;resizeWidth&quot;:560,&quot;bytes&quot;:54093,&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_!pFdV!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 424w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 848w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.png 1272w, https://substackcdn.com/image/fetch/$s_!pFdV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4ee95c81-2a32-4205-9d35-99f255b8d789_802x571.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></figure></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!4539!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!4539!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 424w, https://substackcdn.com/image/fetch/$s_!4539!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 848w, https://substackcdn.com/image/fetch/$s_!4539!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 1272w, https://substackcdn.com/image/fetch/$s_!4539!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!4539!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png" width="560" height="484.6870838881491" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:650,&quot;width&quot;:751,&quot;resizeWidth&quot;:560,&quot;bytes&quot;:62180,&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_!4539!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 424w, https://substackcdn.com/image/fetch/$s_!4539!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 848w, https://substackcdn.com/image/fetch/$s_!4539!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.png 1272w, https://substackcdn.com/image/fetch/$s_!4539!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F23560fe6-fc87-4439-9072-f3d8fdc38c3d_751x650.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></figure></div><p>I think it does a pretty good job of detailing the aspects which it thinks are important for that individual. In addition, notice how the prompt for me is slightly different than for famous people. I can not give a concrete reason why a different prompt is required for me, however, experimenting more with this can help us to catch such behaviours. </p><p></p><p></p><h3>Testing your ideas</h3><p>In addition to using the styles for drafts, you can use them to test your ideas. For example, based on a position you take, you can see if you get a useful rebuttal by using the style of an expert.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!lRQL!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!lRQL!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 424w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 848w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 1272w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!lRQL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png" width="520" height="451.0843373493976" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:648,&quot;width&quot;:747,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:61499,&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_!lRQL!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 424w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 848w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.png 1272w, https://substackcdn.com/image/fetch/$s_!lRQL!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9b624db9-79ef-4618-a342-5b511c58c08e_747x648.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></figure></div><p>Now although this should not be taken as absolute truth, it does provide a useful way to find out opposing ideas that we might find difficult to come up with due to a position we have taken.</p><p></p><h2>Coding</h2><p>The most talked about and &#8220;scary&#8221; use case of ChatGPT. Even though a lot of doomsday scenarios have already been painted vividly, I feel that at least in the short term, ChatGPT is the best tool created for programmers yet.</p><p>My main use case is to quickly generate templates for whatever code I want to write and then add in the customization according to what I want to do. A word of caution here is to check the versions of the libraries that are being used in the code. I found that it will regularly use old versions even if the libraries were updated before the training cut-off.</p><p>Here&#8217;s an example of generating a simple CRUD API in NodeJS:</p><pre><code><code>/*
QUERY:
Write an API in NodeJS that has separate end points for each of the CRUD operations

The APIs take a dictionary as input and perform CRUD operations on MongoDB
*/

const express = require('express');
const bodyParser = require('body-parser');
const { MongoClient, ObjectID } = require('mongodb');

const app = express();
const port = process.env.PORT || 3000;
const url = 'mongodb://localhost:27017';
const dbName = 'mydatabase';
const collectionName = 'mycollection';

app.use(bodyParser.json());

// Create
app.post('/api', async (req, res) =&gt; {
  try {
    const client = await MongoClient.connect(url);
    const db = client.db(dbName);
    const result = await db.collection(collectionName).insertOne(req.body);
    res.send(result);
    client.close();
  } catch (err) {
    res.status(500).send(err);
  }
});

// Read
app.get('/api/:id', async (req, res) =&gt; {
  try {
    const client = await MongoClient.connect(url);
    const db = client.db(dbName);
    const result = await db.collection(collectionName).findOne({ _id: new ObjectID(req.params.id) });
    res.send(result);
    client.close();
  } catch (err) {
    res.status(500).send(err);
  }
});

// Update
app.put('/api/:id', async (req, res) =&gt; {
  try {
    const client = await MongoClient.connect(url);
    const db = client.db(dbName);
    const result = await db.collection(collectionName).updateOne({ _id: new ObjectID(req.params.id) }, { $set: req.body });
    res.send(result);
    client.close();
  } catch (err) {
    res.status(500).send(err);
  }
});

// Delete
app.delete('/api/:id', async (req, res) =&gt; {
  try {
    const client = await MongoClient.connect(url);
    const db = client.db(dbName);
    const result = await db.collection(collectionName).deleteOne({ _id: new ObjectID(req.params.id) });
    res.send(result);
    client.close();
  } catch (err) {
    res.status(500).send(err);
  }
});

app.listen(port, () =&gt; {
  console.log(`Server running on port ${port}`);
});
</code></code></pre><p>Another great use case is to quickly write and test regex.</p><pre><code><code>/*
QUERY:
Write a regex to match all the pages on the website "&lt;https://leetcode.com&gt;"
*/

^https:\\/\\/leetcode\\.com\\/.*$

/*
Explanation:

^ matches the beginning of the string
https:\\/\\/leetcode\\.com\\/ matches the protocol and domain of the website
.* matches any characters that appear after the domain (i.e. any path or query parameters)
$ matches the end of the string
*/
</code></code></pre><p>There are many more ways to program ChatGPT for coding. Here&#8217;s a <a href="https://rowancheung.gumroad.com/">useful link</a> that has many resources for the same.</p><p></p><h3>&#129534;TLDR Review</h3><p>Here is a compiled list of just the prompts that are explored in the article:</p><p><em><strong>&#128273; For Summarization use:</strong></em></p><ul><li><p><em>Explain to me like I&#8217;m 5/11 (Try other values)</em></p></li><li><p><em>Give me an N-point summary</em></p></li></ul><p><em><strong>&#128273; For Text generation in a particular style use:</strong></em></p><ul><li><p><em>Write [TYPE_OF_TEXT] on [TOPIC] as if written by [NAME_OF_PERSON]</em></p></li><li><p><em>[Links to your own blogs]. Write in a similar style to me</em></p></li></ul><p><em><strong>&#128273; For testing your ideas use:</strong></em></p><ul><li><p><em>[YOUR_VIEW] Respond as if you are [PERSON_NAME] responding to the position. </em></p></li></ul><p><em><strong>&#128273; For coding use:</strong></em></p><ul><li><p><em><strong>For Regex:</strong> Write a regex for [REQUIREMENT]</em></p></li><li><p><em><strong>For API templates:</strong> Write a [API_SPEC] for [API_FUNCTIONS] in [TECH_STACK_CHOICE] </em></p></li></ul><p></p><h2>Conclusion</h2><p>LLMs are here to stay. They will be integrated into a myriad of different applications that we use every day. Instead of complaining and trying to put them down, it&#8217;s much more productive to try and get better at using them to improve our output as well as save time. In addition to this, the more you play with it, the more you&#8217;ll realize that we still have a long way to go to get something that will replace humans in every task!</p><p>Until then, keep experimenting with different types of prompts and exploring the various ways to make ChatGPT and other LLMs your friend!</p><div><hr></div><h2>&#128226;Announcement</h2><p>I have enabled the chat feature for Decoding Coding. <a href="https://decodingcoding.substack.com/p/help-join-my-new-subscriber-chat">Click here for the details and join the chat to let me know what you would like me to cover next!</a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!N6sZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!N6sZ!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 424w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 848w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 1272w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!N6sZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png" width="520" height="344.9246231155779" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:528,&quot;width&quot;:796,&quot;resizeWidth&quot;:520,&quot;bytes&quot;:32986,&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_!N6sZ!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 424w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 848w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.png 1272w, https://substackcdn.com/image/fetch/$s_!N6sZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F08516420-21b8-48a4-bfaa-284e42600ba7_796x528.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">See the instructions to access the chat in the link above.</figcaption></figure></div><div><hr></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://substackcdn.com/image/fetch/$s_!BpJn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_webp,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1456w" sizes="100vw"><img src="https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png" width="362" height="362" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1024,&quot;width&quot;:1024,&quot;resizeWidth&quot;:362,&quot;bytes&quot;:1752314,&quot;alt&quot;:&quot;&quot;,&quot;title&quot;:&quot;&quot;,&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="" title="" srcset="https://substackcdn.com/image/fetch/$s_!BpJn!,w_424,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 424w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_848,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 848w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1272,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.png 1272w, https://substackcdn.com/image/fetch/$s_!BpJn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4019c06-cc90-4904-9257-3df51d37e96d_1024x1024.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></figure></div><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://decodingcoding.substack.com/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 Decoding Coding! Subscribe for free to receive new posts and support my work. If you know someone who likes to read deep dives like these, share it with them!</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><div><hr></div><p>That&#8217;s it for this issue. I hope you found this article interesting. Until next time!</p><div><hr></div><p>Let&#8217;s connect :)</p><p><a href="https://twitter.com/Prathmesh11235">Twitter</a> | <a href="https://www.instagram.com/prathmeshd__/">Instagram</a></p>]]></content:encoded></item></channel></rss>