<script data-pm-proxy="intercept"></script><?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[The Tech Buffet]]></title><description><![CDATA[A newsletter about practical machine learning and programming. Weekly insights to ship your products faster.]]></description><link>https://thetechbuffet.substack.com</link><image><url>https://substackcdn.com/image/fetch/$s_!lOpT!,w_256,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F69d45c09-f9a1-493b-8f6b-468f0c9e3e42_1024x1024.png</url><title>The Tech Buffet</title><link>https://thetechbuffet.substack.com</link></image><generator>Substack</generator><lastBuildDate>Fri, 04 Sep 2026 15:53:42 GMT</lastBuildDate><atom:link href="/__u/thetechbuffet.substack.com/feed" rel="self" type="application/rss+xml"/><copyright><![CDATA[Ahmed Besbes]]></copyright><language><![CDATA[en]]></language><webMaster><![CDATA[thetechbuffet@substack.com]]></webMaster><itunes:owner><itunes:email><![CDATA[thetechbuffet@substack.com]]></itunes:email><itunes:name><![CDATA[Ahmed Besbes]]></itunes:name></itunes:owner><itunes:author><![CDATA[Ahmed Besbes]]></itunes:author><googleplay:owner><![CDATA[thetechbuffet@substack.com]]></googleplay:owner><googleplay:email><![CDATA[thetechbuffet@substack.com]]></googleplay:email><googleplay:author><![CDATA[Ahmed Besbes]]></googleplay:author><itunes:block><![CDATA[Yes]]></itunes:block><item><title><![CDATA[The Tech Buffet #24: How I Use Claude Code on an Unfamiliar Codebase]]></title><description><![CDATA[Let&#8217;s use Claude Code on an application we didn&#8217;t build ourselves.]]></description><link>https://thetechbuffet.substack.com/p/claude-code-on-an-unfamiliar-codebase</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/claude-code-on-an-unfamiliar-codebase</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Sat, 29 Aug 2026 15:08:02 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!9AHq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Hello everyone &#128075; Ahmed here.</p><p>It&#8217;s been a while since the last article I published on The Tech Buffet.</p><blockquote><p>New here? The Tech Buffet is a newsletter about practical ML engineering and software, one hands-on issue at a time &#8212; subscribe below if you want the rest of this series landing in your inbox.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/subscribe?&quot;,&quot;text&quot;:&quot;Subscribe now&quot;,&quot;action&quot;:null,&quot;class&quot;:&quot;button-wrapper&quot;}" data-component-name="ButtonCreateButton"><a class="button primary button-wrapper" href="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>For this comeback, I wanted to start with a tool I&#8217;ve been spending quite a bit of time looking into lately: <strong>Claude Code</strong>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9AHq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 424w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 848w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9AHq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png" width="1456" height="765" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:765,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1863144,&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;:&quot;https://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 424w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 848w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9AHq!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F635d80b8-5468-4e97-b030-e1100b6e48e7_1731x909.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 aria-hidden="true" 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><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&#8217;ve probably already seen the demos.</p><p>Someone opens a terminal, types:</p><blockquote><p><code>Build me a SaaS for managing my personal finances.</code></p></blockquote><p>Claude creates 30 files, installs a bunch of packages, and, a few minutes later, there&#8217;s an application running.</p><p>Impressive stuff.</p><p>But it&#8217;s not the use case I&#8217;m most interested in.</p><p>In real software development, we rarely start from an empty directory.</p><p>We join existing projects. We navigate code written by other people. We investigate bugs. We try to understand why something was implemented a certain way before touching it.</p><blockquote><p><strong>That&#8217;s how we&#8217;re going to learn Claude Code today.</strong></p></blockquote><p>Instead of asking it to build another Todo app, we&#8217;re going to give Claude an <strong>existing FastAPI application that we didn&#8217;t write</strong> and see how useful it can be.</p><p>By the end of this article, we&#8217;ll use Claude Code to:</p><ul><li><p>Explore an unfamiliar repository</p></li><li><p>Understand its architecture</p></li><li><p>Trace how an existing feature works</p></li><li><p>Run commands and tests</p></li><li><p>Make a small code change</p></li><li><p>Review what Claude actually modified</p></li></ul><p>Nothing particularly advanced yet.</p><p>No MCP servers.</p><p>No subagents.</p><p>No Skills.</p><p>We&#8217;ll first get comfortable using one Claude on one real codebase. </p><div><hr></div><h2>The application we&#8217;ll use</h2><p>For this tutorial, we&#8217;ll use the open-source <code>fastapi-realworld-example-app</code> <a href="https://github.com/adr1enbe4udou1n/fastapi-realworld-example-app">repository</a>.</p><p>It&#8217;s an implementation of the <strong>RealWorld API specification</strong> built with FastAPI.</p><p>The application contains <a href="https://en.wikipedia.org/wiki/Create,_read,_update_and_delete">CRUD</a> operations, authentication, routing, pagination, PostgreSQL, SQLAlchemy, database migrations and a pytest test suite. Its source code is split across API routes, CRUD functions, database code, models and schemas.</p><p>In other words, there is enough code for Claude to actually have something to understand.</p><p>Let&#8217;s clone it:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;5e3faed1-bfff-4f47-84f9-97ab286c6057&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">git clone https://github.com/adr1enbe4udou1n/fastapi-realworld-example-app.git

cd fastapi-realworld-example-app</code></pre></div><p>Before doing anything with Claude, let&#8217;s have a quick look at the repository. By typing this command:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;7e095e33-0bf5-4e30-8ab0-1577de32fe43&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">ls -la</code></pre></div><p>You&#8217;ll see something roughly like:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Jh1J!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 424w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 848w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Jh1J!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png" width="1328" height="558" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:558,&quot;width&quot;:1328,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:198529,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 424w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 848w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Jh1J!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd544dc2b-bd07-413d-8204-0caa60aec4dd_1328x558.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 aria-hidden="true" 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><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>Inside <code>app/</code>, things become a little more interesting:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!h_c5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 424w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 848w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!h_c5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png" width="1264" height="518" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/af783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:518,&quot;width&quot;:1264,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:193147,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 424w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 848w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.png 1272w, /__u/substackcdn.com/image/fetch/$s_!h_c5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Faf783182-aeda-413f-8a54-9e69c2c3e0e1_1264x518.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 aria-hidden="true" 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><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>And inside the API routes:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!V2Rb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 424w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 848w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!V2Rb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png" width="1456" height="424" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:424,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:193749,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 424w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 848w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!V2Rb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28933d95-3247-42ec-bd4f-1a2c8d09bd27_1640x478.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 aria-hidden="true" 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><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 repository also includes a PostgreSQL setup, Alembic migrations, seed data and a full pytest suite.</p><p>You could now start opening those files one by one.</p><p>But that&#8217;s precisely what we&#8217;re going to ask Claude to do for us.</p><div><hr></div><h2>Installing Claude Code</h2><blockquote><p><em>In this section, I assume you have a working Claude Pro or Max subscription.</em></p></blockquote><p>If you haven&#8217;t installed Claude Code yet, the recommended native installation on macOS, Linux and WSL is currently:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;f96548f6-7950-4bd4-93e9-77a815eb7d5c&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">curl -fsSL https://claude.ai/install.sh | bash</code></pre></div><p>Once installed, you can type this command to check Claude&#8217;s version.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;0a30514b-d156-48aa-84f5-9fc4eab715d5&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">claude --version</code></pre></div><p>As I&#8217;m writing this post, my Claude version is <code>2.1.233</code>.</p><p>Now, from inside the repository, run:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;bash&quot;,&quot;nodeId&quot;:&quot;d5b35a10-2eb3-4c3e-af9c-7e409dba1251&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-bash">claude</code></pre></div><p>That&#8217;s basically all we need to start.</p><p>Claude Code is now running with our repository as its working directory and can inspect files, search the codebase and execute development commands from the terminal.</p><p>Claude starts by asking me if it should trust this folder.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8g1f!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 424w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 848w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8g1f!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png" width="1456" height="313" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:313,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:136451,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 424w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 848w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8g1f!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba00bedd-7a5a-471a-9d4f-fa0658a184d4_3022x650.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To which I&#8217;ll answer yes. And we&#8217;re good to go.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!C1b_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 424w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 848w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 1272w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!C1b_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png" width="1456" height="279" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:279,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:178664,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 424w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 848w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 1272w, /__u/substackcdn.com/image/fetch/$s_!C1b_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5869670a-9e24-49e6-bd9b-457773faa5d4_3004x576.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><div><hr></div><h1>Don&#8217;t ask Claude to write code yet</h1><p>The first thing I&#8217;m interested in here isn&#8217;t code generation.</p><p>It&#8217;s this:</p><blockquote><p>Can Claude understand an application it has never seen before?</p></blockquote><p>Let&#8217;s start with a very simple prompt.</p><pre><code><code>Explore this repository and explain what the application does.

Don't modify any files.</code></code></pre><p>Claude starts exploring the repository.</p><p>It starts by listing the files:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!EVnW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 424w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 848w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 1272w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!EVnW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png" width="1456" height="150" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:150,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:78142,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 424w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 848w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 1272w, /__u/substackcdn.com/image/fetch/$s_!EVnW!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb5ab5081-7b1a-45ff-be34-65df65f51c9e_2596x268.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>It might inspect things such as:</p><pre><code><code>README.md
pyproject.toml
app/main.py
app/api/
app/crud/
app/models/
tests/</code></code></pre><p>Claude Code starts by running multiple shell commands.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!8Stf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!8Stf!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png" width="1456" height="664" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:664,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:400315,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 424w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 848w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.png 1272w, /__u/substackcdn.com/image/fetch/$s_!8Stf!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5aec6fda-144b-4a41-a677-a85f0fa827f4_2834x1292.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 aria-hidden="true" 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><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>Then produces its answer (while identifying a tiny bug along the way).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!CFPV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 424w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 848w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!CFPV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png" width="1456" height="720" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:720,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:542460,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 424w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 848w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CFPV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0e76b748-2784-4069-a176-e87a0f31ef17_2994x1480.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 aria-hidden="true" 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><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>All this in 47s. </p><p>The interesting part here isn&#8217;t really the final explanation.</p><p>We could have read the README.</p><p>What&#8217;s more interesting is that <strong>we didn&#8217;t tell Claude which files to read</strong>.</p><p>Claude decided that itself.</p><p>You can also ask Claude to describe the core functionalities of the app in simple terms. This helps me validate my understanding. This is also useful for non-technical users.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wnBi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 424w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 848w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wnBi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png" width="1456" height="873" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:873,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:389281,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 424w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 848w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wnBi!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe73fb2f4-7839-4cd3-9063-f0997f287a8c_2248x1348.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 aria-hidden="true" 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><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>OK, now let&#8217;s push Claude a little further and have it dig into the codebase.</p><div><hr></div><h1>Ask Claude to explain the architecture</h1><p>When we join an existing project, we may first not be interested in the implementation details of every function and class. </p><p>We&#8217;d rather have a high-level picture of the architecture, how files are organized and how data flows between the layers.</p><p>Let&#8217;s ask Claude that:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;dbd83912-e1b9-476c-b9f1-64f6f8082b07&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">Explain the architecture of this application.

Identify the main layers, their responsibilities and how they
interact with each other.

Mention the most important files and directories.

Don't modify anything.</code></pre></div><p>Now Claude has to go beyond the README.</p><p>It needs to understand how things like:</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;04486021-082e-49b3-8a03-57c17f6f2f15&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext">app/api
app/crud
app/db
app/models
app/schemas</code></pre></div><p>fit together.</p><p>When it&#8217;s done analyzing, it first gives a mental model organized in a diagram.</p><div class="highlighted_code_block" data-attrs="{&quot;language&quot;:&quot;plaintext&quot;,&quot;nodeId&quot;:&quot;e428626e-033c-418e-ac8b-9e34b3e972eb&quot;}" data-component-name="HighlightedCodeBlockToDOM"><pre class="shiki"><code class="language-plaintext"> HTTP request
     &#9474;
     &#9660;
  app/main.py            &#8211; ASGI app assembly, mounting, CORS
     &#9474;
     &#9660;
  app/api/api.py         &#8211; top-level router, prefixes/tags per resource
     &#9474;
     &#9660;
  app/api/routes/*.py      &#8211; endpoint functions (path ops, request validation via Pydantic)
     
     &#9660;
  app/api/deps.py          &#8211; auth (JWT&#8594;User), DB session injection, repository factories

     &#9660;
  app/crud/crud_*.py       &#8211; repository classes: SQLAlchemy queries, writes, transactions
     &#9474;                       reads/writes
     &#9660;
  app/models/*.py          &#8211; SQLAlchemy ORM entities (tables, relationships)
     &#9474;
     &#9660;
  app/schemas/*.py         &#8211; Pydantic DTOs returned to the client</code></pre></div><p>Then, it details each component separately.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LIM0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 424w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 848w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LIM0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png" width="1456" height="1114" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1114,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:416581,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 424w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 848w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LIM0!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01940b5e-0f07-493c-80ae-1c6660e0512f_1748x1338.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 aria-hidden="true" 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><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>There are multiple questions I often find myself asking when working on a new codebase:</p><pre><code><code>Where is the FastAPI application initialized?</code></code></pre><p>or:</p><pre><code><code>How is the database connection configured?</code></code></pre><p>or:</p><pre><code><code>Where are request and response schemas defined?</code></code></pre><p>or:</p><pre><code><code>Where are the API routes registered?</code></code></pre><p>Claude can drastically shorten that exploration phase.</p><p>These are simple questions. But on a large repository, they can save a surprising amount of time.</p><div><hr></div><h1>Let&#8217;s trace a real feature</h1><p>Understanding folders is useful.</p><p>Understanding <strong>execution paths</strong> is much more useful.</p><p>Our application lets users create articles.</p><p>Instead of manually searching for the endpoint, let&#8217;s ask Claude:</p><pre><code><code>Trace what happens when an authenticated user creates a new article.

Start from the incoming HTTP request and follow the execution
until the article is persisted in the database.

Mention the relevant files and functions along the way.

Don't modify anything.
</code></code></pre><p>Now Claude has to connect several pieces of the codebase together.</p><p>It should discover the article routes, schemas, authentication dependencies, CRUD logic and database models involved in the operation.</p><p>When it&#8217;s done, you see that it detailed what exactly happened at each step.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Q1jP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 424w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 848w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Q1jP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png" width="1456" height="652" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:652,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:642154,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 424w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 848w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Q1jP!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb0ffd89c-160b-4d1a-bf88-fbcc348c6bc2_3012x1348.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 aria-hidden="true" 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><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>If you&#8217;re a bit reluctant to read a lot of text, you can also ask Claude to create a simple diagram. Again, it&#8217;s a better mental model.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!WH7s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 424w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 848w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!WH7s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png" width="1188" height="1424" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1424,&quot;width&quot;:1188,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:241148,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 424w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 848w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.png 1272w, /__u/substackcdn.com/image/fetch/$s_!WH7s!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c66a0c-510b-4888-8f0f-cdd1b5e1aa8f_1188x1424.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 aria-hidden="true" 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><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 where Claude Code starts becoming much more interesting to me.</p><p>Without it, investigating an unfamiliar flow often looks something like:</p><pre><code><code>find route
   &#8595;
open file
   &#8595;
follow import
   &#8595;
open dependency
   &#8595;
follow function
   &#8595;
find model
   &#8595;
inspect tests</code></code></pre><p>Claude can perform much of that navigation before we even open an editor.</p><p>We&#8217;re still responsible for understanding the code.</p><p>But Claude can help us get to the right code much faster.</p><div><hr></div><h1>What about authentication?</h1><p>Let&#8217;s say you&#8217;re new to authentication. Having Claude Code as a developer companion can help you learn about this topic.</p><p>Let&#8217;s try something like this:</p><pre><code><code>Explain how authentication works in this application.

I specifically want to understand:

1. how a user logs in
2. where the access token is created
3. how the token is validated on subsequent requests
4. how an authenticated request is associated with a user

Give me the relevant files and functions.</code></code></pre><p>Notice something important about this prompt.</p><p>I didn&#8217;t ask:</p><pre><code><code>Explain auth.py.</code></code></pre><p>I&#8217;m describing the <strong>thing I want to understand</strong>, not the files I think contain the answer.</p><p>That&#8217;s an important difference.</p><p>In the following screenshot, Claude explains, step by step how authentication is performed when a user queries the /articles endpoint to create a post.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JRbI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 424w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 848w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JRbI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png" width="1456" height="413" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:413,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:319084,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 424w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 848w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JRbI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55fca68d-b45e-456f-a7bb-fa049102841b_2966x842.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 aria-hidden="true" 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><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>If I already knew exactly where the implementation lived, I probably wouldn&#8217;t need Claude to explore it for me.</p><p>You can use the same pattern for almost anything:</p><pre><code><code>Explain how article favorites work.</code></code></pre><pre><code><code>Trace how comments are created and deleted.</code></code></pre><pre><code><code>Explain how pagination is implemented for article listing.</code></code></pre><pre><code><code>Show me how database sessions are created and injected into routes.</code></code></pre><p>This turns Claude Code into something more useful than a code generator.</p><p>It becomes a way to <strong>interrogate your codebase</strong>.</p><div><hr></div><h1>Let Claude run commands</h1><p>So far Claude has only been reading code.</p><p>Let&#8217;s let it interact with the project.</p><p>The repository uses PostgreSQL and provides a Docker Compose setup. Its README also includes commands for installing dependencies with <code>uv</code>, running migrations, adding seed data and launching the application.</p><p>We could execute everything manually.</p><p>Or we could ask:</p><pre><code><code>Set up this application locally following the repository instructions.

Before running commands, explain what you intend to do.</code></code></pre><p>Claude can inspect the README and determine the steps.</p><p>You&#8217;ll still see the commands it wants to execute.</p><p>For example, the repository setup includes commands along these lines:</p><pre><code><code>docker compose up -d

uv sync

cp .env.example .env

uv run alembic upgrade head

uv run app/seed.py

uv run uvicorn app.main:app --reload</code></code></pre><p>Depending on your permissions, Claude may ask you before executing certain commands.</p><p>This is something I like about the terminal workflow.</p><p>Claude proposes an action.</p><p>You can inspect it.</p><p>Then decide whether it should actually happen.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Dnt0!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 424w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 848w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Dnt0!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png" width="1456" height="399" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:399,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:293946,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 424w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 848w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Dnt0!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F697776d9-8ea5-4a9b-afc0-ab5dc51a40ba_2926x802.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 aria-hidden="true" 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><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>Once the application is running, its OpenAPI interface is available at <code>/api</code>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9XmE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 424w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 848w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9XmE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png" width="1456" height="897" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:897,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:245396,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 424w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 848w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9XmE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F29b66868-c2eb-43a1-b014-8a1322c42b1d_2400x1478.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 aria-hidden="true" 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><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><h1>Let&#8217;s see whether the tests pass</h1><p>Before modifying an unfamiliar repository, it&#8217;s usually useful to know whether you&#8217;re starting from a healthy state.</p><p>Ask:</p><pre><code><code>Run the existing test suite.

Don't change anything.

If anything fails, explain why before attempting to fix it.</code></code></pre><p>The project includes a pytest suite, and the repository explicitly documents pytest as its test runner.</p><p>Claude can execute the tests and inspect their results.</p><p>This gives us something very important before we touch the code:</p><p><strong>a baseline.</strong></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!yj3s!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 424w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 848w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!yj3s!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png" width="1456" height="518" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:518,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:144908,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 424w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 848w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yj3s!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F28ff90eb-10f7-4413-aa68-64f0dc56e4fc_2204x784.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 aria-hidden="true" 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><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>If the tests pass now and fail after our modification, we know we&#8217;ve probably introduced a regression.</p><p>That feedback loop is going to become increasingly important throughout this series.</p><div><hr></div><h1>Our first change</h1><p>We&#8217;ve spent most of this tutorial asking Claude to <strong>read</strong> code.</p><p>Let&#8217;s finally make it write some.</p><p>But we&#8217;ll keep the task deliberately small.</p><p>Let&#8217;s add a health-check endpoint to the API:</p><pre><code><code>GET /health</code></code></pre><p>which returns:</p><pre><code><code>{
  "status": "ok"
}</code></code></pre><p>Instead of telling Claude which file to modify, let&#8217;s give it the requirement:</p><pre><code><code>Add a health-check endpoint to this application.

Requirements:

- GET /health
- return HTTP 200
- return {"status": "ok"}
- follow the existing project structure and conventions
- add an automated test

Before modifying anything, inspect the repository and tell me
where you intend to implement it.</code></code></pre><p>There are two things I like about this prompt.</p><p>First, we&#8217;re giving Claude a <strong>requirement</strong>, rather than implementation instructions.</p><p>We don&#8217;t say:</p><pre><code><code>Create health.py inside this folder and import it here.</code></code></pre><p>We let Claude inspect the project and determine how the change should fit into the existing architecture.</p><p>Second, we&#8217;re giving it a way to know when it has succeeded:</p><pre><code><code>add an automated test</code></code></pre><p>Claude should first explain its approach.</p><p>You can review it.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!FptM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 424w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 848w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 1272w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!FptM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png" width="1456" height="429" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:429,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:236329,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 424w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 848w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.png 1272w, /__u/substackcdn.com/image/fetch/$s_!FptM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F82535c3b-7505-49ef-ac2f-40b07f3a3b3b_3004x886.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 aria-hidden="true" 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><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>Then let it make the changes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!4XbG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 424w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 848w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!4XbG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png" width="1456" height="801" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:801,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:227575,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 424w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 848w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.png 1272w, /__u/substackcdn.com/image/fetch/$s_!4XbG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7dc51b2b-7853-4d5a-a158-f20f185a8ac4_2182x1200.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 aria-hidden="true" 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><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><h1>Review the code, not just Claude&#8217;s message</h1><p>Once Claude finishes, don&#8217;t stop at:</p><blockquote><p>Done! The health endpoint has been implemented.</p></blockquote><p>Ask:</p><pre><code><code>Show me the git diff and explain every change you made.</code></code></pre><p>Now inspect the result.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lWIv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 424w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 848w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lWIv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png" width="1456" height="481" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:481,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:274721,&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://thetechbuffet.substack.com/i/211542909?img=https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png&quot;,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 424w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 848w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lWIv!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03d6aad0-2764-496a-835f-1fb8388dcdbf_3018x996.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 aria-hidden="true" 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><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 also ask:</p><pre><code><code>Did you make any changes that were not required by my request?</code></code></pre><p>And then:</p><pre><code><code>Run the tests relevant to this change.</code></code></pre><p>Finally:</p><pre><code><code>Run the full test suite and confirm that the existing behavior
still works.</code></code></pre><p>Our workflow now looks something like:</p><pre><code><code>Requirement
    &#8595;
Claude explores repository
    &#8595;
Claude proposes implementation
    &#8595;
Developer reviews
    &#8595;
Claude modifies code
    &#8595;
Tests
    &#8595;
Developer reviews diff</code></code></pre><p>This is very different from:</p><pre><code><code>prompt
  &#8595;
code
  &#8595;
copy/paste</code></code></pre><p>And I think that&#8217;s the important thing to understand about Claude Code.</p><div><hr></div><h1>The prompts matter less than the workflow</h1><p>You may have noticed that none of the prompts in this tutorial were particularly sophisticated.</p><p>There was no:</p><blockquote><p>You are a world-class senior software engineer with 25 years of experience...</p></blockquote><p>We mostly asked simple questions.</p><h3>Explore</h3><pre><code><code>Explain the architecture of this application.</code></code></pre><h3>Trace</h3><pre><code><code>Trace what happens when an authenticated user creates an article.</code></code></pre><h3>Understand</h3><pre><code><code>Explain how authentication works.</code></code></pre><h3>Execute</h3><pre><code><code>Run the existing test suite.</code></code></pre><h3>Modify</h3><pre><code><code>Add this feature while following the existing project conventions.</code></code></pre><h3>Review</h3><pre><code><code>Show me the diff and explain every change.</code></code></pre><p>That&#8217;s already enough to start getting value from Claude Code.</p><p>The important part isn&#8217;t finding the perfect magic prompt.</p><p>It&#8217;s getting used to a workflow where Claude can:</p><p><strong>inspect &#8594; reason &#8594; act &#8594; verify</strong></p><p>inside the same development environment.</p><div><hr></div><h1>One thing I would avoid</h1><p>After your first successful task, there is a temptation to immediately ask:</p><pre><code><code>Now refactor the entire architecture.</code></code></pre><p>I wouldn&#8217;t.</p><p>At least not yet.</p><p>Claude Code becomes much easier to use once you understand how it behaves on <strong>small, verifiable tasks</strong>.</p><p>Start with changes where you can easily answer:</p><blockquote><p>Did Claude actually do what I asked?</p></blockquote><p>A health endpoint is trivial.</p><p>That&#8217;s intentional.</p><p>Once you&#8217;re comfortable with the mechanics, you can give Claude bigger tasks.</p><p>And that&#8217;s when planning becomes much more important.</p><div><hr></div><h2>What&#8217;s next?</h2><p>So far, Claude has been able to understand the repository, trace existing features, run commands and make a small change.</p><p>But every time you open a new Claude Code session, it starts with the repository in front of it &#8212; not with everything you already explained in the previous one.</p><p>That means you can quickly find yourself repeating things like:</p><pre><code><code>Use uv.

Run tests before finishing.

Keep database access out of route handlers.

Follow the existing repository patterns.

Don't add a dependency unless it's really needed.</code></code></pre><p>Some of these instructions are worth repeating. Most aren&#8217;t.</p><p>Claude Code has a built-in way to make project-specific instructions persistent across sessions: <code>CLAUDE.md</code>.</p><p>You can even generate a first version automatically with:</p><pre><code><code>/init</code></code></pre><p>The interesting question isn&#8217;t how to create the file, though.</p><p>It&#8217;s:</p><blockquote><p><strong>What information actually belongs in </strong><code>CLAUDE.md</code><strong>, and what is just noise that Claude could rediscover by reading the repository?</strong></p></blockquote><p>That&#8217;s what we&#8217;ll look at in the next issue. We&#8217;ll generate a real <code>CLAUDE.md</code>, criticize its output, cut the parts that don&#8217;t change its behavior, and keep only the instructions that are actually useful.</p><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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">The Tech Buffet is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.</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><p></p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #23: What Nobody Tells You About RAGs]]></title><description><![CDATA[A deep dive into why RAG doesn't always work as expected: an overview of the business value, the data, and the technology behind it.]]></description><link>https://thetechbuffet.substack.com/p/what-nobody-tells-you-about-rags</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/what-nobody-tells-you-about-rags</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Thu, 22 Aug 2024 17:41:10 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="5184" height="3456" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3456,&quot;width&quot;:5184,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;a woman sitting in front of a newspaper stand&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="a woman sitting in front of a newspaper stand" title="a woman sitting in front of a newspaper stand" srcset="https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1641751392604-e449a2acf4e4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw0NXx8bmV3c3BhcGVyc3xlbnwwfHx8fDE3MjQzNDgyNjB8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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">Photo by <a href="/__u/thetechbuffet.substack.com/true">Lisa Boonaerts</a> on <a href="https://unsplash.com">Unsplash</a></figcaption></figure></div><blockquote><p><strong>The Tech Buffet provides in-depth tutorials and technical reviews of topics in ML and programming. Consider supporting it by subsribing.</strong></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>Building a RAG to &#171;chat with your data&#187; is easy: install a popular LLM orchestrator like <a href="https://python.langchain.com/v0.2/docs/tutorials/rag/">LangChain</a> or <a href="https://docs.llamaindex.ai/en/stable/examples/low_level/oss_ingestion_retrieval/">LlamaIndex</a>, turn your data into vectors, index those in a vector database, and quickly set up a pipeline with a default prompt.</p><p>A few lines of code and you call it a day.&nbsp;</p><p>Or so you&#8217;d think.</p><p>The reality is more complex than that. Vanilla RAG implementations, purposely made for 5-minute demos, don&#8217;t work well for real business scenarios.</p><p>Don&#8217;t get me wrong, those quick-and-dirty demos are great for understanding the basics. But in practice, getting a RAG system production-ready is about more than just stringing together some code. It&#8217;s about navigating the realities of messy data, unforeseen user queries, and the ever-present pressure to deliver tangible business value.</p><blockquote><p><em>In this issue, we&#8217;ll first explore the <strong>business imperatives that make or break a RAG-based project</strong>. Then, we&#8217;ll dive into the common technical hurdles&#8202;&#8212;&#8202;from <strong>data handling </strong>to<strong> performance optimization</strong>&#8202;&#8212;&#8202;and discuss <strong>strategies</strong> to overcome them.</em></p></blockquote><p><strong>Disclaimer</strong>: The insights shared here don&#8217;t represent my employer and come from my personal experiences, research, and more than a few late-night coding sessions.</p><div><hr></div><h3>1&#8202;&#8212;&#8202;Clarify the business value from the start: the context, the users, and the&nbsp;data</h3><p><em>&#8220;Why should we bother building a RAG in the first place?&#8221;</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!033e!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!033e!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg" width="1456" height="971" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:971,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&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="/__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!033e!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc9485f86-c61f-42c8-88ea-0ab110c37891_1920x1280.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 aria-hidden="true" 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><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">Photo by <a href="https://unsplash.com/@wrishi2004m?utm_source=medium&amp;utm_medium=referral">Mayukh Karmakar</a> on&nbsp;<a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure></div><p>Before writing a single line of code, it&#8217;s critical to understand why a RAG (Retrieval-Augmented Generation) is even needed from a business perspective. This might seem obvious, but many developers neglect this part, rushing into implementation headfirst without clearly defining long-term objectives.&nbsp;</p><p>Let&#8217;s keep you from losing time in the future. Here are some business requirements to consider before starting a RAG/LLM-based project. These principles also apply to general ML projects:</p><p>&#8594; <strong>Clarify the context:</strong> Know your users and what they do. Formulate their main business issue in simple terms, put yourself in their shoes, dissect what they do, and then discuss how RAGs and LLMs can help. Take sample questions and simulate how the system would handle them.</p><p>&#8594; <strong>Educate non-technical users</strong> on the capabilities and limitations of generative AI. Since this is a new field, this is very helpful. This can be achieved through workshops, training sessions, and practical demonstrations that use RAG systems. For example, I&#8217;ve seen that internally crafted prompting guides are often helpful for getting started with interacting with LLMs.</p><p>&#8594; <strong>Understand the user journey:</strong> What types of questions will they answer with the RAG? What are the outputs to expect from such a system? How will the generated answers be used down the line?&nbsp;<br>Most importantly, you must know how your RAG will integrate into an existing workflow. This foresight will anticipate further developments, such as whether the RAG will be embedded into a browser extension, an API endpoint, or a Word plugin.<br>Generating an answer using a RAG system is simple. What&#8217;s complex, however, is driving practical value from it.</p><blockquote><p><em><strong>Keep this in mind: the business won&#8217;t come to you and play with your fancy models unless those change and improve their ways of working.</strong></em></p></blockquote><p>&#8594; <strong>Anticipate the data to be indexed:</strong> Qualify it, map it to the users, and understand why and how it will be used to form a good answer when the RAG pipeline is triggered. This will determine what processing and metadata should be implemented. After qualification, you&#8217;ll eventually need to set up a data acquisition strategy: purchasing, leveraging internal data, discarding unnecessary data, or sourcing from open resources (open data, GitHub repos, etc.).</p><p>If a process heavily relies on business requirements, it must be identified early on at this step.</p><p>&#8594; <strong>Define success criteria:</strong> What is a correct answer? What are the key success factors? How can we establish a clear way to compute the ROI? These metrics should not be evaluated only when the project is done. They should be iterated continuously throughout the project to catch early mistakes, easy bugs, and inconsistencies.</p><div><hr></div><blockquote><p>Personal note: If the business asks you to build a RAG, one possible reason could be they&#8217;ve seen the competition doing it, (FOMO is a real thing, my friend). My advice to you in this situation is to challenge this request first. Very often, what the business needs can be less complex than we think.</p></blockquote><h3>2&#8202;&#8212;&#8202;Understand what you&#8217;re&nbsp;indexing</h3><p>After mapping and qualifying the data sources needed to build a RAG, you&#8217;ll quickly identify different kinds of modalities that will be indexed upon further discussion with the business.</p><ul><li><p>text</p></li><li><p>images and diagrams</p></li><li><p>tables</p></li><li><p>code snippets</p></li></ul><p>Each of these modalities will be processed differently, turned into vectors, and used in retrieval.</p><p>There are different approaches to combining multimodal data: here&#8217;s a common one that deals with <strong>text</strong>, <strong>tables,</strong> and <strong>images</strong>:</p><ul><li><p>text data is chunked and embedded with an embedding model</p></li><li><p>tables are summarized with an LLM and their descriptions are embedded and used for indexing. After it&#8217;s retrieved, a table is used as-is, in its raw tabular format.</p></li><li><p>code snippets are chunked in a special way (to avoid inconsistencies) and embedded using a text embedding model</p></li><li><p>images are converted into embeddings using a multi-modal vision and language model&#8202;&#8212;&#8202;When retrieval is performed, the same multimodal LLM will take in your text query convert it to a vector and search related images in the vector db.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Mfkk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 424w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 848w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Mfkk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png" width="1456" height="626" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:626,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&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="/__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 424w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 848w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Mfkk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3867e754-971f-4531-b643-2a0a8bf1b71c_1920x826.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 aria-hidden="true" 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><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">Diagram by the&nbsp;author</figcaption></figure></div><p>Additional notes:</p><ul><li><p>The vectors you index are not necessarily the vectors you retrieve: you can do things differently: For example, you can index sentences by the paragraphs they occur into, by the questions they answer, or by their summary. Check this <a href="https://medium.com/towards-data-science/3-advanced-document-retrieval-techniques-to-improve-rag-systems-0703a2375e1c">post</a> to learn more.</p></li><li><p>There are a lot of great resources on multimodal RAGs. Check this <a href="https://docs.llamaindex.ai/en/v0.10.17/examples/multi_modal/multi_modal_pdf_tables.html">blog</a> from LlamaIndex for a deep dive.</p></li></ul><h3>3&#8202;&#8212;&#8202;Improve chunk quality&#8202;&#8212;&#8202;garbage in, garbage&nbsp;out</h3><p>Before indexing text data, you need to break it into smaller pieces called chunks. Chunks are the text snippets the vector database retrieves and passes to the LLM as a context to generate an answer.</p><p>So it&#8217;s obvious that the chunks' quality impacts the answer.</p><p>If the chunks:</p><ul><li><p>are pulled out of their surrounding context (if cut in the middle for example)</p></li><li><p>include irrelevant data that doesn&#8217;t answer the question</p></li><li><p>contradict each other</p></li></ul><p>they&#8217;ll provide a poor answer.</p><p>There are different chunking techniques that you can explore <a href="https://www.mongodb.com/developer/products/atlas/choosing-chunking-strategy-rag/">here</a> and <a href="https://antematter.io/blogs/optimizing-rag-advanced-chunking-techniques-study">here</a>.</p><p>Other <a href="https://python.langchain.com/v0.1/docs/modules/data_connection/document_transformers/">techniques</a> depend on the data type (raw text, markdown, code).&nbsp;</p><p>However, what works best in general is to analyze the data precisely and come up with a chunking rule that makes sense from a business perspective:</p><p>Here are some tips:</p><ul><li><p>Leverage document metadata like table of contents, titles, or headers to provide contextually relevant chunks. For example, a chunk that overlaps between an introduction and the first chapters is not consistent and rarely makes sense</p></li><li><p>There&#8217;s no rule of thumb regarding chunk size. If your documents are wordy and express a single idea in relatively long paragraphs, the chunk size would be longer than documents that are written in bullet points</p></li><li><p>Some data don&#8217;t need chunking because it&#8217;s relatively short and self-contained. Imagine building a RAG-based system on JIRA tickets: you won&#8217;t need chunking for that.</p></li></ul><blockquote><p><em>Note on semantic <a href="https://python.langchain.com/v0.2/docs/how_to/semantic-chunker/">chunking</a>: this method generates chunks that are semantically relevant. It&#8217;s however time consuming since it relies on embedding models underneath.</em></p></blockquote><p>Resources about chunking:</p><ul><li><p><a href="https://towardsdatascience.com/the-art-of-chunking-boosting-ai-performance-in-rag-architectures-acdbdb8bdc2b">https://towardsdatascience.com/the-art-of-chunking-boosting-ai-performance-in-rag-architectures-acdbdb8bdc2b</a></p></li></ul><h3>4&#8202;&#8212;&#8202;Improve pre-retrieval</h3><p>Before your query reaches the RAG system, you can refine it with additional processing steps.</p><p>These steps are called pre-retrieval: they optimize the input query, ensuring the system retrieves the most relevant and high-quality documents.</p><p>Here are some key pre-retrieval steps to consider &#10549;&#65039;</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/what-nobody-tells-you-about-rags">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #22: Why You Should Consider Weaviate As Your Ultimate Vector Database]]></title><description><![CDATA[Some insights from a 9-month project building RAGs for pharma]]></description><link>https://thetechbuffet.substack.com/p/weaviate-search-features</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/weaviate-search-features</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Tue, 23 Apr 2024 08:55:09 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!EPn1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p><em>Hello everyone, Ahmed here. I write The Tech Buffet to deliver practical insights in machine learning and system design. This is based on my experience as an ML engineer, blogger and open source contributor.</em></p><p><em>In today&#8217;s issue, I explain my current motivations of selecting Weaviate as a production-ready vector database to power RAG systems.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!EPn1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!EPn1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg" width="1456" height="1048" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1048,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:626579,&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="/__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!EPn1!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe58d0bc6-d2d2-45ae-800e-79cde33e97d2_1456x1048.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 aria-hidden="true" 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><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>A vector database is a critical component in Retrieval Augmented Generation (RAG) applications: besides storing the vectors and the metadata, it efficiently computes similarity measures and powers semantic search.</p><p>But picking the right vector database when building production-ready RAG applications is no easy task: this requires a close evaluation of the cost, the query performance, and the scalability. This is even more important when you process millions of vectors or expect real-time use.</p><p>I'm currently working at a pharma company and I've gone through this decision process. So, in this issue, I'll share with you why I think Weaviate is a good option for managing your vector data and building RAGs, especially if you're a developer with no particular experience in LLMs.</p><p>To make this tutorial easy to follow, I'll first load some data from a public API, index it in Weaviate, and experiment with some of its cool features.</p><p>Here's the agenda</p><ol><li><p>Load research papers from the Papers With Code public API</p></li><li><p>Setup Weaviate locally</p></li><li><p>Index the data in batches</p></li><li><p>Overview of Weaviate search functionalities:</p><ul><li><p>vector search</p></li><li><p>keyword search</p></li><li><p>hybrid search</p></li><li><p>re-ranking</p></li><li><p>advanced filtering</p></li></ul></li><li><p>Generative search: turning your database into a RAG system</p></li></ol><div><hr></div><h3>1&#8212;Load research papers from the Papers With Code public API &#128268;</h3><p>To experiment with Weaviate features, we first need to ingest some data. Many datasets are available out there.</p><p>The one we'll experiment today with consists of research papers about Large Language Models.</p><p>We'll extract this dataset from the public API of <a href="https://paperswithcode.com/">paperswithcode</a>.</p><p>To collect this dataset, you need to run the following function:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xbl9!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 424w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 848w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xbl9!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png" width="1200" height="781.3186813186813" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:948,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:234131,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 424w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 848w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xbl9!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8127d14b-3fc9-45f2-bc93-29412c585bcd_1904x1240.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 aria-hidden="true" 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><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 dataset contains ~11K paper abstracts with the following attributes and metadata:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!J8L7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 424w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 848w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 1272w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!J8L7!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png" width="1200" height="393.95604395604397" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/de9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:478,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:224964,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 424w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 848w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.png 1272w, /__u/substackcdn.com/image/fetch/$s_!J8L7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fde9043e8-935b-4f23-b1c3-67a8940d5a73_2064x678.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 aria-hidden="true" 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><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>2&#8212;Setup Weaviate locally &#9881;&#65039;</h3><p><a href="https://weaviate.io/">Weaviate</a> is an open-source, AI-native vector database that helps developers create intuitive and reliable AI-powered applications.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RBP-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 424w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 848w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RBP-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png" width="610" height="305.41895604395603" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:729,&quot;width&quot;:1456,&quot;resizeWidth&quot;:610,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;GitHub - weaviate/weaviate: Weaviate is an open-source vector database that  stores both objects and vectors, allowing for the combination of vector  search with structured filtering with the fault tolerance and scalability of&quot;,&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="GitHub - weaviate/weaviate: Weaviate is an open-source vector database that  stores both objects and vectors, allowing for the combination of vector  search with structured filtering with the fault tolerance and scalability of" title="GitHub - weaviate/weaviate: Weaviate is an open-source vector database that  stores both objects and vectors, allowing for the combination of vector  search with structured filtering with the fault tolerance and scalability of" srcset="/__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 424w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 848w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RBP-!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F195a1f19-91b2-42f0-bd9a-587e7e8db909_2400x1201.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 aria-hidden="true" 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><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 use Weaviate in different ways:</p><ul><li><p>Via a <a href="https://weaviate.io/developers/weaviate/installation/docker-compose">docker-compose</a> locally</p></li><li><p>Via <a href="https://weaviate.io/developers/weaviate/installation/kubernetes">Kubernetes</a> by deploying it on cluster</p></li><li><p>Via Weaviate Cloud Services (<a href="https://weaviate.io/developers/weaviate/installation/weaviate-cloud-services">WCS</a>), the managed offering</p></li></ul><p>At my company, we deployed Weaviate on Kubernetes but in this tutorial, we&#8217;ll  use docker-compose for demo purposes.</p><p>The setup is straightforward.</p><ol><li><p>Create an empty <code>weaviate_data</code> folder to store Weaviate data on the host</p></li><li><p>Create a docker-compose file with this configuration:</p><ul><li><p>Enabled modules: <code>text2vec-palm,reranker-cohere,generative-palm</code></p></li><li><p>AUTHENTICATION_APIKEY_ALLOWED_KEYS: 'admin'</p></li><li><p>AUTHENTICATION_APIKEY_USERS: 'ahmed'</p></li></ul></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LNAM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 424w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 848w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LNAM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png" width="1456" height="1416" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1416,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:233726,&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="/__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 424w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 848w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LNAM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4cb8df62-d403-4b74-9ac9-eb896fc71fb2_1668x1622.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 aria-hidden="true" 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><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 start="3"><li><p>Run this command: </p><pre><code>docker-compose up</code></pre></li></ol><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RRAU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 424w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 848w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RRAU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png" width="1430" height="1144" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1144,&quot;width&quot;:1430,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:394202,&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="/__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 424w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 848w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RRAU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6025756-a6f7-439f-86ca-55013f1e3235_1430x1144.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 aria-hidden="true" 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><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>To check that Weaviate started successfully, you can hit this <a href="http://localhost:8080/">URL</a> </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Az-p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 424w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 848w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Az-p!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png" width="1200" height="212.63736263736263" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:258,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:228352,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 424w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 848w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Az-p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7c66af53-5a8b-4e41-b9cc-e119352cfcdd_2880x510.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>After launching Weaviate, you must create a client to interact with it.</p><p>This client can have additional credentials to connect to other third-party cloud services like OpenAI, VertexAI, or Cohere.</p><blockquote><p><em>Why would a vector database need these connections?</em></p></blockquote><p>Weaviate can take care of other things than storing your vectors and computing similarities. </p><ul><li><p>It can embed the data while indexing it</p></li><li><p>It can perform document reranking after retrieval</p></li><li><p>It can perform a RAG operation by answering questions based on search results</p></li><li><p>and more&#8230;</p></li></ul><p>In this tutorial, I'll connect Weaviate to VertexAI to power text embedding and generation and connect it to the Cohere API for the reranking task.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!YyBJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 424w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 848w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!YyBJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png" width="1456" height="1262" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1262,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:293952,&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="/__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 424w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 848w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.png 1272w, /__u/substackcdn.com/image/fetch/$s_!YyBJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd1aefb3e-6072-44cb-af5b-8677c8a6ec3d_2060x1786.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 aria-hidden="true" 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><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>3&#8212;Index the data in batches &#128450;&#65039;</h3><p>Before indexing the data into Weaviate, we must create a collection and define the schema.</p><p>This is done via the <code>create</code> method that defines:</p><ul><li><p>The collection name: MLPapers</p></li></ul><ul><li><p>The properties (or fields)</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RYRs!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 424w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 848w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RYRs!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png" width="1456" height="1271" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1271,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:208094,&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="/__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 424w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 848w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RYRs!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbd9ea9ca-fda3-4ea6-977a-bf476316b15d_1546x1350.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 aria-hidden="true" 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><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>The vectorizer that'll be used to embed the data while indexing it</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!OmrG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!OmrG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png" width="1456" height="446" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:446,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:68837,&quot;alt&quot;:&quot;&quot;,&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="" title="" srcset="/__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OmrG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85efa923-6b0b-43ef-811d-68bf3849479c_1546x474.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 aria-hidden="true" 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><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>The generator that'll be used to generate answers based on retrieved documents (To perform RAG directly in Weaviate)</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7nqK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7nqK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png" width="1456" height="431" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.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;:null,&quot;bytes&quot;:64766,&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="/__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7nqK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb968b45-d696-42c6-8ccf-20cc6158df75_1602x474.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 aria-hidden="true" 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><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&#8217;s the full code:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!W6XJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 424w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 848w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 1272w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!W6XJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png" width="1456" height="3414" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3414,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:656222,&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="/__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 424w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 848w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.png 1272w, /__u/substackcdn.com/image/fetch/$s_!W6XJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F98c08fa8-6761-4526-a56b-6aba3492058b_1602x3756.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 aria-hidden="true" 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><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>After the collection is created, you can index the data in batches. This is another useful functionality of Weaviate that speeds up the indexing process.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!G2TS!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 424w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 848w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 1272w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!G2TS!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png" width="1456" height="729" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1cded435-b022-4ff3-b804-520087afe04f_1602x802.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:729,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:128708,&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="/__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 424w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 848w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.png 1272w, /__u/substackcdn.com/image/fetch/$s_!G2TS!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1cded435-b022-4ff3-b804-520087afe04f_1602x802.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 aria-hidden="true" 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><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>Once the indexing is complete, we can check the number of vectors using the <code>aggregate</code> method:</p><pre><code>collection.aggregate.over_all(total_count=True)
# AggregateReturn(properties={}, total_count=10592)</code></pre><h3>4&#8212;Weaviate search functionalities &#128269;</h3><p>Weaviate has multiple search options. We&#8217;ll review some of them in this section.</p><h4>1. Vector Search </h4><p>The obvious search method is based on vector similarities. Here's how to do it:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xnIw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 424w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 848w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xnIw!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png" width="1456" height="680" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:680,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:102158,&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="/__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 424w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 848w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xnIw!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F640fc4c2-386f-4290-bee9-6b1b6e436638_1602x748.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 aria-hidden="true" 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><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><blockquote><p>Behind the scenes, Weaviate first embeds the text query using the vectorizer, then fetches the similar results from the collection.</p></blockquote><p>The response contains a list of objects and each one has the following structure.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!v_IB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 424w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 848w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 1272w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!v_IB!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png" width="1200" height="265.38461538461536" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:322,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:252601,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 424w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 848w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 1272w, /__u/substackcdn.com/image/fetch/$s_!v_IB!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F45d3ba2b-0537-4a90-b8c6-2249db8e41ee_1962x434.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>By inspecting the three retrieved documents, we notice that they match the query accurately.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JBc8!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 424w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 848w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JBc8!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png" width="1200" height="571.1538461538462" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:693,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:488812,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 424w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 848w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JBc8!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3f55783f-c0ae-468d-88c2-f5397240397a_1978x942.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 aria-hidden="true" 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><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>2. Keyword Search</h4><p>Weaviate handles the keyword search by using the BM25 algorithm.</p><p>Keyword search is a simple technique that relies on string matching only.</p><p>You can run a keyword search in Weaviate by calling the <code>bm25</code> method.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!0OEh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!0OEh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png" width="1456" height="431" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.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;:null,&quot;bytes&quot;:53708,&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="/__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!0OEh!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2291ccb7-2e85-4546-bd31-2c43685210b7_1602x474.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 aria-hidden="true" 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><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 gives the following results:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Zkvw!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Zkvw!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png" width="1200" height="570.3296703296703" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:692,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:490739,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 424w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 848w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Zkvw!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F71763b57-56d2-4d2e-949d-61522efdeccf_2006x954.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 aria-hidden="true" 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><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>After reading these documents, they appear less relevant than the previous ones. They mention the words &#8220;fine-tuning&#8221; or &#8220;LLMs&#8221; but don&#8217;t necessarily discuss the process of model fine-tuning.</p><blockquote><p>Keyword search is a useufl functionality when you need to match specific terms that an embedding model doesn&#8217;t necessarily know or represent well (e.g. a drug nomenclature or an e-commerce product name)</p></blockquote><h4>3. Hybrid Search</h4><p>One feature that I find particularly useful in Weaviate is hybrid search. </p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/weaviate-search-features">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #21: Deploy A Production-Ready Streamlit App with Cloud Run and Cloud Build]]></title><description><![CDATA[How to ship containerized applications on a serverless architecture and over a CICD pipeline.]]></description><link>https://thetechbuffet.substack.com/p/deploy-streamlit-with-cloudrun-and-cloudbuild</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/deploy-streamlit-with-cloudrun-and-cloudbuild</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Fri, 22 Mar 2024 09:50:20 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%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hi &#128075; Ahmed here, your host at The Tech Buffet. This issue covers app deployment, an important skill to make your work accessible to the world.</p><p>Subscribe to access exclusive content. </p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>In this issue, you&#8217;ll learn how to deploy a <a href="https://streamlit.io/">Streamlit</a> application quickly and cost-effectively on the Google Cloud Platform.</p><p>To do that, you&#8217;ll need:</p><ul><li><p>A GCP account with a valid credit card (although following this tutorial won&#8217;t cost you a cent)</p></li><li><p><a href="https://www.pulumi.com/docs/">Pulumi</a>: an Infrastructure as Code (IaC) tool to provision the cloud resources needed to deploy the app</p></li><li><p>Some knowledge of Google Cloud services (Cloud Run), Docker and Poetry</p></li><li><p>A Github account to trigger automatic deployment with the Cloud Build CI/CD platform</p></li></ul><p>If you&#8217;re unfamiliar with some of these tools, everything will be covered below, and links will be provided to learn more.</p><p>Without further ado, let&#8217;s have a look &#128071; .</p><div><hr></div><h3>What is Cloud Run? &#9729;&#65039;</h3><p>Cloud Run is a Google Cloud service that provides a fully managed platform to run your code in a container. </p><p>Whether you&#8217;re building a web server, an API, or running processing jobs, Cloud Run automatically scales your containers up and down from zero. </p><p>This means <strong>you only pay when your code is running</strong>.</p><p>With Cloud Run, the workflow is simple. You write your code in your favorite programming language (Python, Go, NodeJS, or Java), package it into a container, and push it for deployment.</p><p>Then, Google Cloud provides everything the app needs to run in production.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!idn5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 424w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 848w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 1272w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!idn5!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png" width="1200" height="632.967032967033" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:768,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:673896,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 424w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 848w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.png 1272w, /__u/substackcdn.com/image/fetch/$s_!idn5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb6549a2f-6b85-4994-99d0-e7ce3c5f66c8_5435x2866.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 aria-hidden="true" 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><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>What does an app need in production? Here are some benefits:</p><ul><li><p><strong>Auto-scaling</strong>: Cloud Run scales up and down your containers depending on the load. When the CPU usage exceeds 60% in a container, Cloud Run starts another one and splits the traffic</p></li></ul><ul><li><p><strong>HTTPS</strong> &#128274;: when your app is deployed on Cloud Run, it gets a secure endpoint with a TLS termination (even on a custom domain)</p></li><li><p><strong>Native integration with other GCP services</strong>: Cloud Run conveniently integrates with other services from the GCP suite. One of these services is Cloud Build, a CI/CD platform that streamlines the development process (we&#8217;ll see that in the last section)</p></li><li><p><strong>Traffic management</strong>: Cloud Run allows you to split your app&#8217;s traffic across multiple versions already deployed. This is particularly helpful for AB testing.</p></li></ul><p>If you&#8217;re interested in learning more about Cloud Run, check out this link &#11015;&#65039;.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://cloud.google.com/run/docs/overview/what-is-cloud-run&quot;,&quot;text&quot;:&quot;Learn more about Cloud Run&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://cloud.google.com/run/docs/overview/what-is-cloud-run"><span>Learn more about Cloud Run</span></a></p><div><hr></div><h3>Configure Pulumi and start an initial Deployment &#128736;&#65039;</h3><p>In the previous <a href="/__u/thetechbuffet.substack.com/p/summarize-youtube-videos-with-cloud-functions">issue</a>, I covered the process of deploying a cloud function on GCP using an infrastructure-as-code (IaC) tool called <a href="https://www.pulumi.com/">Pulumi</a>.</p><blockquote><p>With IaC, you don&#8217;t need to manipulate the UI. Instead, you define the resources in imperative code (e.g. in Python or TypeScript) and hit a special command to launch the deployment. This automates manual operations, versions the state of the infrastructure in a repo and increases collaboration.</p></blockquote><p>We&#8217;ll use Pulumi again today to provision everything the Cloud Run instance needs.</p><p>Let&#8217;s go over some preliminary steps to Pulumi up and running.</p><h4>&#9881;&#65039; Initial setup</h4><p>&#9654;&#65039; Install Docker and start it</p><p>&#9654;&#65039; Install Pulumi with <a href="https://brew.sh/">Homebrew</a><code> </code>if you&#8217;re on Mac. (Check this <a href="https://www.pulumi.com/docs/install/">link</a> if you&#8217;re on another OS.)</p><pre><code><strong>brew install pulumi/tap/pulumi</strong></code></pre><p>&#9654;&#65039; Assuming you have a GCP account with the Cloud Run API activated, install the <a href="https://cloud.google.com/sdk/docs/install-sdk">gcloud</a> CLI if you haven&#8217;t already</p><p>&#9654;&#65039; Authenticate <code>gcloud</code> with your GCP account</p><pre><code><strong>gcloud auth application-default login</strong></code></pre><p>&#9654;&#65039; Create a new folder and run <code>pulumi new </code>inside. Then pick the <code>container-gcp-python</code> template. This will bootstrap a project architecture suited to Cloud Run.</p><p>In this step, you&#8217;ll be asked to provide some settings about the project. Then, Pulumi will create a virtual environment.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!arWG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 424w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 848w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 1272w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!arWG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png" width="1456" height="889" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:889,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:275006,&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="/__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 424w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 848w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.png 1272w, /__u/substackcdn.com/image/fetch/$s_!arWG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F25b5b37d-0390-48e3-9697-711dee160faf_1730x1056.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 aria-hidden="true" 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><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>When the installation is completed, you&#8217;ll get the following structure:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!n3Dk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 424w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 848w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!n3Dk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png" width="360" height="262.3343848580442" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/edab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:462,&quot;width&quot;:634,&quot;resizeWidth&quot;:360,&quot;bytes&quot;:39354,&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="/__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 424w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 848w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.png 1272w, /__u/substackcdn.com/image/fetch/$s_!n3Dk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fedab2700-e947-432a-a6d7-c7bcf8729a36_634x462.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 aria-hidden="true" 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><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>&#9654;&#65039; Change the <code>Pulumi.yaml </code>file by specifying a backend on GCS. This will tell Pulumi to store the remote state of the architecture in your bucket*. (Mine is <code>pulumi-gcp-state</code>, so you need to create your own if you&#8217;re following the tutorial.)</p><p><em>PS: Note that other backends are possible to use.*</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!L9vV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 424w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 848w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 1272w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!L9vV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png" width="1456" height="596" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:596,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:98110,&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="/__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 424w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 848w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.png 1272w, /__u/substackcdn.com/image/fetch/$s_!L9vV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F229448b8-95cf-42bd-8262-d60e2c21e05d_1476x604.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 aria-hidden="true" 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><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>&#9654;&#65039; Pin the <code>pulumi-gcp</code> dependency version to <code>7.11.2</code></p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!oXQr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 424w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 848w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 1272w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!oXQr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png" width="514" height="189.2992327365729" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:288,&quot;width&quot;:782,&quot;resizeWidth&quot;:514,&quot;bytes&quot;:43266,&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="/__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 424w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 848w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 1272w, /__u/substackcdn.com/image/fetch/$s_!oXQr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa319b067-8ed1-48e1-9f36-011c583fc53a_782x288.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>and reinstall the dependencies.</p><pre><code><strong>source venv/bin/activate
pip install -r requirements.txt</strong></code></pre><p>&#9654;&#65039; Now perform an initial deployment to check everything is working: </p><pre><code>pulumi up</code></pre><p>Pulumi first previews the updates:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-siO!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 424w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 848w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-siO!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png" width="1386" height="512" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:512,&quot;width&quot;:1386,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:132243,&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="/__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 424w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 848w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.png 1272w, /__u/substackcdn.com/image/fetch/$s_!-siO!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7ab9f5f4-0b84-4302-b835-8eb61fae28b0_1386x512.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 aria-hidden="true" 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><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>Then it creates the resources:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!E-ZG!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 424w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 848w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!E-ZG!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png" width="1456" height="774" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:774,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:182402,&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="/__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 424w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 848w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E-ZG!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F99a5ac3f-e732-4f82-a418-ee9c60cc6c5d_1468x780.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 aria-hidden="true" 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><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>If we click on the output URL, we&#8217;ll get this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Kghr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 424w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 848w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Kghr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png" width="536" height="212.7461430575035" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:566,&quot;width&quot;:1426,&quot;resizeWidth&quot;:536,&quot;bytes&quot;:53220,&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="/__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 424w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 848w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Kghr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff026ac8b-5291-4d37-8c4e-82dbe091ef4b_1426x566.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Our endpoint is deployed! For now, it&#8217;s a simple REST API that returns a cute &#8220;Hello, World!&#8221;.</p><p>Ok, let&#8217;s now modify the code a bit:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UZt_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 424w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 848w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UZt_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png" width="496" height="284.8878718535469" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:502,&quot;width&quot;:874,&quot;resizeWidth&quot;:496,&quot;bytes&quot;:61014,&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="/__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 424w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 848w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UZt_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F02bc45a1-fc1b-43b6-992c-85eada87c1e5_874x502.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 aria-hidden="true" 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><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>And run <code>pulumi up</code> again:</p><p>This time, Pulumi only previews the updates because everything else is already created.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!M7KW!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!M7KW!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png" width="1398" height="350" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:350,&quot;width&quot;:1398,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:92981,&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="/__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 424w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 848w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M7KW!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b93e17b-d2da-422d-a471-2fcd267656c6_1398x350.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 aria-hidden="true" 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><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>If we hit the URL again, we will see our changes!</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!5v98!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 424w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 848w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!5v98!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png" width="566" height="220.8021978021978" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:426,&quot;width&quot;:1092,&quot;resizeWidth&quot;:566,&quot;bytes&quot;:48786,&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="/__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 424w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 848w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 1272w, /__u/substackcdn.com/image/fetch/$s_!5v98!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe345f81a-4067-4c5e-95a2-603993775ad1_1092x426.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Pretty cool, right?</p><div><hr></div><h3>Deploy a Streamlit application &#127880;</h3><p>To deploy a Streamlit application on Cloud Run by using Pulumi, we&#8217;ll need to modify some files:</p><p><strong>&#9654;&#65039; </strong>Change the requirements.txt in the app folder to:</p><pre><code>streamlit</code></pre><p><strong>&#9654;&#65039; </strong>Change the app.py file to:</p><pre><code>import streamlit as st


st.header("Hello from Cloud Run !")
st.balloons()</code></pre><p><strong>&#9654;&#65039; </strong>Update the Dockerfile by changing the base image and the entry point</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ndfB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ndfB!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png" width="1456" height="394" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:394,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:85944,&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="/__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 424w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 848w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ndfB!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe8d0ff5b-a347-46c9-af5a-b7fa1452f32e_1750x474.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 aria-hidden="true" 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><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><strong>&#9654;&#65039; </strong>Then deploy!</p><p>Ta-da! &#129345; </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!UaFQ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 424w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 848w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!UaFQ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png" width="566" height="259.6758241758242" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:668,&quot;width&quot;:1456,&quot;resizeWidth&quot;:566,&quot;bytes&quot;:147667,&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="/__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 424w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 848w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.png 1272w, /__u/substackcdn.com/image/fetch/$s_!UaFQ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7731ae58-a2ca-4aac-ab35-1fe51c565746_2076x952.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 aria-hidden="true" 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><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><h3>What exactly happens here?</h3><p>We looked at the deployment output without understanding how Pulumi does it under the hood. </p><p>To understand how Pulumi defines the resources, let&#8217;s have a look at the <code>__main__.py </code>file.</p><p>Let&#8217;s go over it step by step:</p><p><strong>&#9654;&#65039; </strong>We start by loading the configuration settings:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!j1_Z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 424w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 848w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 1272w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!j1_Z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png" width="1406" height="1020" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1020,&quot;width&quot;:1406,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:219197,&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="/__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 424w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 848w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.png 1272w, /__u/substackcdn.com/image/fetch/$s_!j1_Z!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F79b7c673-d6af-4d2b-a426-f23a9d721ca7_1406x1020.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 aria-hidden="true" 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><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><strong>&#9654;&#65039; </strong>We create a unique repo on Artifact Registry to store the Docker image</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Gc48!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 424w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 848w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Gc48!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png" width="1406" height="1148" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1148,&quot;width&quot;:1406,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:162008,&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="/__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 424w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 848w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Gc48!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5799fa0c-8c86-467f-9c4e-7a6a0e6f4602_1406x1148.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 aria-hidden="true" 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><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><strong>&#9654;&#65039;</strong> We create a container image for the service</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!NZKn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 424w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 848w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 1272w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!NZKn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png" width="1406" height="978" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:978,&quot;width&quot;:1406,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:137600,&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="/__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 424w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 848w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.png 1272w, /__u/substackcdn.com/image/fetch/$s_!NZKn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc682899a-b054-4432-83cf-dd19c5f1a140_1406x978.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 aria-hidden="true" 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><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><strong>&#9654;&#65039;</strong> We define the service by supplying the needed configurations: image URL, resource limits, ports, environment variables, etc. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!E4YM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 424w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 848w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!E4YM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png" width="1456" height="1416" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1416,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:222818,&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="/__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 424w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 848w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!E4YM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77f6bbbb-8fc7-44b1-bb27-00abb7d62c52_1748x1700.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 aria-hidden="true" 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><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><strong>&#9654;&#65039;</strong>  Finally, we add the <code>run.invoker</code> role to the Cloud Run service and apply it to all users so that the app can be invoked by anyone</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Sekm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 424w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 848w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Sekm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png" width="1456" height="601" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:601,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93996,&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="/__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 424w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 848w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Sekm!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16da751c-dd9c-4821-ae9a-0d93bfecbcc6_1748x722.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 aria-hidden="true" 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><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><blockquote><p>Pulumi integrates well with many Cloud providers and services, check out the <a href="https://www.pulumi.com/docs/">documentation</a> and the <a href="https://github.com/pulumi/examples">examples</a> to learn more.</p><p>Don&#8217;t hesitate to check the documentations of the functions and classes used in the code: Pulumi provides a deep level of customization.</p></blockquote><div><hr></div><h3>Automate the deployment with a CICD pipeline &#9881;&#65039;</h3><p>We&#8217;ve seen that to deploy the app, you needed to run <code>pulumi up.</code> </p><p>But this would be tedious to repeat each time we modify the source code, wouldn&#8217;t it?</p><p>Instead, it&#8217;s more convenient to trigger the deployment automatically as we push modifications to a remote repository. </p><p>That&#8217;s where <strong>Cloud Build</strong> comes into play. </p><p>Cloud Build is a serverless CI/CD platform designed to build, test, and deploy code.</p><p>The good news is that it also integrates perfectly well with Cloud Run!</p><p>Let&#8217;s see how. </p><p><strong>&#9654;&#65039; </strong>Go to the GCP console, under Cloud Run, select the service you&#8217;ve just deployed, and hit the <strong>EDIT CONTINUOUS DEPLOYMENT</strong> button.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xRT2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 424w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 848w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xRT2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png" width="1053" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/871f430d-5197-4f6a-823d-866312461ff7_1053x501.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1053,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:65921,&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="/__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 424w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 848w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xRT2!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F871f430d-5197-4f6a-823d-866312461ff7_1053x501.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 aria-hidden="true" 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><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>&#9654;&#65039; Set up the source repository (You may probably need to connect your Github or GitLab account to GCP before), and select the repository where you pushed your code</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_yh4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 424w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 848w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_yh4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png" width="394" height="329.25174825174827" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:478,&quot;width&quot;:572,&quot;resizeWidth&quot;:394,&quot;bytes&quot;:55650,&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="/__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 424w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 848w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_yh4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F59b4b9ee-7a3d-4dce-8838-7c4e0523dbb7_572x478.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 aria-hidden="true" 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><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>&#9654;&#65039; Update the build configuration: the branch that triggers the build, the build type (Dockerfile), and the path to the Dockerfile in the repository.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!j5SD!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 424w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 848w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 1272w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!j5SD!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png" width="475" height="296.9835466179159" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/d8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:342,&quot;width&quot;:547,&quot;resizeWidth&quot;:475,&quot;bytes&quot;:39471,&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="/__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 424w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 848w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.png 1272w, /__u/substackcdn.com/image/fetch/$s_!j5SD!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fd8bd2396-ec42-4767-992c-94972d1be8f6_547x342.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 aria-hidden="true" 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><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><blockquote><p>Before triggering the CI/CD, you may also need to activate the IAM API.</p></blockquote><p>Let&#8217;s now see how modifications trigger automatic deployment:</p><p>&#9654;&#65039; Go to your project locally and make some modifications:</p><pre><code>import streamlit as st

st.header("Hello from Cloud Run !")

button = st.button("Show balloons!")

if button:
    st.balloons()
</code></pre><p>&#9654;&#65039; Now push your code on the main branch. (This would be a feature branch in real life)</p><p>This will immediately trigger the build and the deployment.</p><p>And we can monitor it on the Cloud Build interface&#128071;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mzcM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 424w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 848w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mzcM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png" width="1456" height="808" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:808,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:229590,&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="/__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 424w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 848w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mzcM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7bc7d93-5eaf-491f-a606-22d9d7a62a9b_1568x870.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 aria-hidden="true" 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><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>After ~2 minutes the modifications are deployed.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!alhj!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 424w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 848w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 1272w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!alhj!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png" width="558" height="207.71703296703296" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:542,&quot;width&quot;:1456,&quot;resizeWidth&quot;:558,&quot;bytes&quot;:62188,&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="/__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 424w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 848w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 1272w, /__u/substackcdn.com/image/fetch/$s_!alhj!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb821f5aa-5995-4122-b6dd-9c788d0ea707_1602x596.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>How great is that?</p><p>Imaging doing this on a complex codebase: this would be a great time-saving.</p><h3>Thanks for reading! &#128591;</h3><p>I hope you&#8217;ve learned a few things about Cloud Run today. To me, this is the go-to solution to deploy Streamlit applications quickly and cost-effectively.</p><p>I&#8217;ve been using Cloud Run to deploy generative AI applications, and it&#8217;s been working great for my client.</p><p>Maybe you should give it a try too: you could use Cloud Run to deploy RAG applications or Chatbots.</p><p>That&#8217;d be all for today. Until next time! &#128075; </p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #20: How To deploy a Cloud Function That Summarizes Youtube Videos]]></title><description><![CDATA[A practical guide on industrializing a serverless LLM app with an infrastructure-as-code (IaC) framework]]></description><link>https://thetechbuffet.substack.com/p/summarize-youtube-videos-with-cloud-functions</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/summarize-youtube-videos-with-cloud-functions</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Mon, 11 Mar 2024 12:56:41 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%2F1f03377f-18a9-4767-88a0-cf1c0b6bc1fc_1421x760.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello everyone &#128075; Ahmed here. I&#8217;m the editor of <strong>The Tech Buffet</strong>, a newsletter that delivers practical insights on shipping production-ready ML applications.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="3200" height="2400" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2400,&quot;width&quot;:3200,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;red and white square illustration&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="red and white square illustration" title="red and white square illustration" srcset="https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1611162616475-46b635cb6868?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHx5b3V0dWJlfGVufDB8fHx8MTcxMDAxMjk4MHww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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 issue, you will learn how to automate the deployment of a serverless Cloud Function on Google Cloud.</p><p>This application will do something that I always wanted to prototype: summarizing YouTube videos &#128249;. </p><p>With the powerful LLMs that are currently available, the scalable cloud architectures, and the efficient developer tools, bringing this idea to life is now possible.</p><p>So here&#8217;s what we&#8217;ll cover to build this project:</p><ul><li><p>A Brief Introduction to Cloud Functions</p></li></ul><ul><li><p>How to develop and test a Cloud Function locally</p></li><li><p>How to design the infrastructure on GCP and deploy the Cloud Function on it</p></li></ul><p>In the last step, we will use Python code only to provision the infrastructure and deploy the Cloud Function. We won&#8217;t be manipulating the GCP UI or using an Infrastructure as Code (IaC) tool that requires another syntax.</p><blockquote><p><strong>If you&#8217;re interested in DevOps or MLOps and how to ship ML applications at scale, it might be useful to stick to the end &#128071;</strong></p></blockquote><p>Let&#8217;s have a look. </p><div><hr></div><h3>What are Cloud Functions?</h3><blockquote><p><em><strong>If you come from the AWS world, Cloud Functions are the equivalent of <a href="https://aws.amazon.com/fr/lambda/">Lambda</a>.</strong></em>.</p></blockquote><p>Cloud Functions is a Google Cloud service that allows you to run your code in the cloud with no servers or containers to manage and in a scalable and cost-efficient way.</p><p>That&#8217;s why Cloud Functions are called serverless.</p><p>With Cloud Functions, the developer experience is simple: you write and test your code locally then send it to Google Cloud to deploy and handle the operational infrastructure. </p><p>The second great feature of Cloud Functions is the cost: you only pay for what you use. Specifically, you&#8217;re billed for your function&#8217;s execution time, metered to 100 milliseconds. And when your function is idle, you pay nothing!</p><p>Cloud Functions are primarily designed to process short-lived, event-based actions triggered from other systems such as Cloud Storage or PubSub.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cqcE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cqcE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg" width="1456" height="827" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:827,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;https://storage.googleapis.com/gweb-cloudblog-publish/images/GCFGlue.max-1800x1800.jpg&quot;,&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="https://storage.googleapis.com/gweb-cloudblog-publish/images/GCFGlue.max-1800x1800.jpg" title="https://storage.googleapis.com/gweb-cloudblog-publish/images/GCFGlue.max-1800x1800.jpg" srcset="/__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!cqcE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb15d9b26-0cbc-4365-924e-ca9a0b3488a0_1800x1022.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 aria-hidden="true" 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><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>For example, you can build a Cloud Function that gets triggered when a file is saved under a bucket or when a row is inserted in BigQuery.</p><p>I also see Cloud Functions being used for sending notifications or triggering other systems.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://cloud.google.com/functions?hl=en&quot;,&quot;text&quot;:&quot;Learn more about Cloud Functions&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="https://cloud.google.com/functions?hl=en"><span>Learn more about Cloud Functions</span></a></p><div><hr></div><h3>Develop and Test the Cloud Function locally</h3><p>In this small project, the Cloud Function we&#8217;ll build will act as a REST API. It&#8217;ll receive user inputs consisting of YouTube URLs and send back the summary. </p><p>Before going through the deployment on GCP, let&#8217;s first build and test this function locally.</p><p>To summarize YouTube videos, we will need these Python libraries:</p><ul><li><p><code>youtube-transcript-api</code>: to extract transcripts from a YouTube video</p></li><li><p><code>langchain </code>and<code> langchain-openai</code>: to interact with OpenAI LLMs and generate the summary</p></li><li><p><code>python-dotenv</code>: to load OpenAI credentials as environment variables</p></li><li><p><code>functions-framework</code>: a FaaS (Function as a Service) framework for writing portable Python functions and testing them locally</p></li></ul><p>The simplest thing to get started is to create a virtual environment:</p><pre><code><strong>python -m venv ./venv
source venv/bin/activate
pip install -r function/requirements.txt</strong></code></pre><p>Then, the function&#8217;s code will be defined in <code>function/main.py</code>:</p><p>Here&#8217;s the main function that&#8217;ll summarize the video (for more details check the remaining code in the <a href="https://github.com/ahmedbesbes/yt-serverless-summarizer">repo</a>):</p><p>&#8594; It first extracts the video transcript and the title, initializes an LLM, builds a prompt, and sends it to the LLM for summarization.</p><pre><code>
def summarize_youtube_video(url, additional_instructions):
    transcript = get_youtube_video_transcript(url)
    title = get_youtube_video_title(url)
    llm = OpenAI(api_key=os.environ.get("OPENAI_API_KEY"))
    prompt = get_prompt(title, transcript, additional_instructions)
    summary = llm.predict(prompt)
    <strong>data = {
        "url": url,
        "title": title,
        "summary": summary,
        "transcript": transcript,
    }</strong>
    return data</code></pre><p>To wrap  this logic in a REST API, we&#8217;ll use the <code>functions_framework</code> package. This allows us to define the Cloud Function handler (or entry point) that will be called once an HTTP request is sent:</p><pre><code>@functions_framework.http
def main(request: flask.Request):
    if request.method == "POST":
        url = request.form.get("url")
        additional_instructions = request.form.get("instructions")
        data = summarize_youtube_video(url, additional_instructions)
        return flask.jsonify(data)
    else:
        return "Method Not Allowed", 400</code></pre><p>The full Cloud Function code is available <a href="https://github.com/ahmedbesbes/yt-serverless-summarizer/blob/main/function/main.py">here</a>.</p><p>To test the Cloud Function locally, run the following command:</p><pre><code>functions-framework --target=main --source=function/main.py --debug</code></pre><p>Running the command will start a local web server. So let&#8217;s open Postman to send it some requests:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!7Pkb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 424w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 848w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!7Pkb!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png" width="1456" height="432" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:432,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:171097,&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="/__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 424w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 848w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.png 1272w, /__u/substackcdn.com/image/fetch/$s_!7Pkb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F75f11b31-2b24-49ba-8650-d155d22fb2e8_1908x566.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 aria-hidden="true" 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><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 send this video that discusses the differences between Terraform and Pulumi:</p><div id="youtube2-Pl5_lP7xwJc" class="youtube-wrap" data-attrs="{&quot;videoId&quot;:&quot;Pl5_lP7xwJc&quot;,&quot;startTime&quot;:null,&quot;endTime&quot;:null}" data-component-name="Youtube2ToDOM"><div class="youtube-inner"><iframe src="https://www.youtube-nocookie.com/embed/Pl5_lP7xwJc?rel=0&amp;autoplay=0&amp;showinfo=0&amp;enablejsapi=0" frameborder="0" loading="lazy" gesture="media" allow="autoplay; fullscreen" allowautoplay="true" allowfullscreen="true" width="728" height="409"></iframe></div></div><p>By filling in the form data with the URL and hitting the Send button, we get the following result: a JSON response with the following keys:</p><ul><li><p><code>summary</code></p></li><li><p><code>title</code></p></li><li><p><code>transcript</code> (the full text)</p></li><li><p><code>url</code></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!rCHk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 424w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 848w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!rCHk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png" width="1456" height="694" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:694,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:521499,&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="/__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 424w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 848w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.png 1272w, /__u/substackcdn.com/image/fetch/$s_!rCHk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb1ce277f-9ab4-4ceb-baf8-386c5df6da48_2672x1274.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 aria-hidden="true" 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><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&#8217;s a closer look at the summary:</p><pre><code>Terraform and Pulumi are two tools that are often compared in the world of DevOps. Terraform is known for its consistency in defining state, while Pulumi offers a more fluid approach using imperative programming languages such as Python and C#. However, this can also lead to potential issues when working in a team or switching organizations.\n\nTerraform, on the other hand, uses HCL (Hashicorp Configuration Language) to define state in a more limited and consistent manner. This allows for easier collaboration and a more secure way of managing state files. Additionally, Terraform is not a SaaS product, meaning your state is not automatically pushed to a remote network. This can be a concern when handling sensitive information.\n\nOverall, the speaker strongly prefers Terraform over Pulumi due to its simplicity and consistency. They also mention that Terraform has a community of nearly 2,000 members who can offer support and answer any questions. In the end, the speaker urges viewers to use Terraform in its simplest form and avoid overcomplicating things.</code></pre><blockquote><p>Pretty cool, right? Imagine doing this for 30-minute world news reports every day. This would be a huge time saving!</p></blockquote><p>If you reproduce this tutorial, you can play with the Postman client, try different videos, and even add a custom instruction to the LLM. </p><p>In the following example, you can ask the LLM to answer in French. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mIzJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 424w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 848w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mIzJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png" width="1456" height="753" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:753,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:555916,&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="/__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 424w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 848w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mIzJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4831384-71a5-4a01-bf88-85745180aee7_2694x1394.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 aria-hidden="true" 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><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 Cloud Function is tested locally. </p><p>We&#8217;re now ready to deploy.</p><div><hr></div><h3>Provision an infrastructure for the Cloud Function</h3><p>If you asked me to deploy a Cloud Function a few years ago, I would happily log into the GCP console, put the source code into a bucket, create the Cloud Function from the UI, add a secret in Google Secret Manager,  connect it to the app, and hit the deploy button.</p><p>If we were to perform these steps every time we make a change to the source code, this would be:</p><ul><li><p>tedious</p></li><li><p>prone to errors</p></li><li><p>untraceable in a codebase</p></li><li><p>difficult to collaborate on</p></li></ul><h4>Enter Pulumi &#128640;</h4>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/summarize-youtube-videos-with-cloud-functions">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #19: How To Build and Deploy an LLM-Powered App To Chat with PapersWithCode]]></title><description><![CDATA[Keep up with the latest ML research]]></description><link>https://thetechbuffet.substack.com/p/chat-with-papers-with-code</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/chat-with-papers-with-code</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Sat, 03 Feb 2024 09:55:44 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hey there &#128075; Happy to have you here. Today&#8217;s issue is a practical end-to-end tutorial that&#8217;ll teach you how to build and deploy a personal assistant to digest the recent ML research.</p></blockquote><div class="pullquote"><p>Subscribe to access the full material of this issue</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></div><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="5472" height="3648" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3648,&quot;width&quot;:5472,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;open book lot&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="open book lot" title="open book lot" srcset="https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1457369804613-52c61a468e7d?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNnx8cGFwZXJzfGVufDB8fHx8MTcwNjk1Mjc0Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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>Do you find it difficult to keep up with the latest ML research? Are you overwhelmed with the massive amount of papers about LLMs, vector databases, or RAGs?</p><p>In this issue, I will show how to build an AI assistant that mines this large amount of information easily. You&#8217;ll ask it your questions in natural language and it&#8217;ll answer according to relevant papers it finds on <a href="https://paperswithcode.com/">Papers With Code</a>.</p><p>&#9881;&#65039; On the backend side, this assistant will be powered with a Retrieval Augmented Generation (RAG) framework that relies on a scalable serverless vector database, an embedding model from VertexAI, and an LLM from OpenAI.</p><p>&#128187; On the front-end side, this assistant will be integrated into an interactive web application built with <a href="https://streamlit.io/">Streamlit</a> and deployed on <a href="https://cloud.google.com/run?hl=en">Google Cloud Run</a>.</p><p>Every step of this process will be detailed below with an accompanying source code that you can reuse and adapt&#128071;.</p><p>Before we start, here&#8217;s the global app workflow:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!B6al!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 424w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 848w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 1272w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!B6al!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png" width="1200" height="943.6813186813187" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:1145,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:1730343,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 424w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 848w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.png 1272w, /__u/substackcdn.com/image/fetch/$s_!B6al!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F431c2af8-1610-41c7-a7f8-7be13ec20381_6166x4851.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 aria-hidden="true" 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><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>And here&#8217;s the agenda:</p><h5><strong>1. Collect data from Papers With Code</strong></h5><h5><strong>2. Create an index on Upstash</strong></h5><h5><strong>3. Embed the chunks and index them</strong></h5><h5><strong>4. Ask questions about the indexed papers</strong></h5><h5><strong>5. Build a Streamlit application</strong></h5><h5><strong>6. Deploy the Streamlit application on Google Cloud Run</strong></h5><p></p><p><em>PS: You can reuse every piece of code shared in this issue and adapt it to your personal or professional projects.</em></p><p>Ready? Let&#8217;s dive in &#128269;.</p><div><hr></div><h3><strong>1. Collect data from Papers With Code</strong></h3><p><a href="https://paperswithcode.com/">Papers With Code</a> (a.k.a PWC) is a free website for researchers and practitioners to find and follow the latest state-of-the-art ML papers, source code, and datasets.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Civn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 424w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 848w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Civn!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png" width="678" height="406.8" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:600,&quot;width&quot;:1000,&quot;resizeWidth&quot;:678,&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="/__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 424w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 848w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Civn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2e757f4d-6686-44be-a4cf-6e6fbe6a43e1_1000x600.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 aria-hidden="true" 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><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>It&#8217;s also possible to interact with PWC through an API to programmatically retrieve research papers. If you look at this <a href="https://paperswithcode.com/api/v1/docs/">Swagger UI</a>, you can find all the available endpoints and try them out.</p><p>Let&#8217;s, for example, search papers on a specific keyword.</p><p>Here&#8217;s how to do it from the interface: you locate the <code>papers/</code> endpoint, fill in the query ( <code>q</code> ) argument.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!NlcM!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 424w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 848w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!NlcM!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png" width="1456" height="679" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f0a95912-7638-48d6-91b5-255941615c45_1500x700.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:679,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&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="/__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 424w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 848w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.png 1272w, /__u/substackcdn.com/image/fetch/$s_!NlcM!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff0a95912-7638-48d6-91b5-255941615c45_1500x700.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 aria-hidden="true" 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><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>and hit the execute button.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!M4Y4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 424w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 848w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!M4Y4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png" width="1456" height="724" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:724,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;&quot;,&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="" title="" srcset="/__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 424w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 848w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.png 1272w, /__u/substackcdn.com/image/fetch/$s_!M4Y4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F94737884-4948-44d7-9585-e219d9a41a3c_1500x746.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 aria-hidden="true" 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><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>Equivalently, you can perform this same search by hitting this <a href="https://paperswithcode.com/api/v1/papers/?q=Large+Language+Models">URL</a>.</p><p>The output response shows the first page of results only. The following pages are available by accessing the <code>next</code> key.</p><p>By exploiting this structure, we can retrieve 7200 papers matching &#8220;Large Language Models&#8221;. This can be done with a function that requests the URL and loops over all the pages.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Di3b!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 424w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 848w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Di3b!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png" width="1456" height="1279" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1279,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:323020,&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="/__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 424w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 848w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Di3b!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F996838e9-3b26-428d-a255-d013f144aafe_1928x1694.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 aria-hidden="true" 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><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://github.com/ahmedbesbes/chat-with-papers/blob/main/src/paperswithcode.py">source</a></figcaption></figure></div><p>Once the results are extracted, we convert them from their raw JSON format into LangChain Documents to simplify chunking and indexing.</p><p>Document objects have two parameters:</p><ul><li><p><strong>page_content</strong> (str): to store the text of the paper&#8217;s abstract</p></li><li><p><strong>metadata</strong> (dict): to store additional information. In our use case, we&#8217;ll keep: <strong>id, arxiv_id, url_pdf, title, authors, published</strong></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!gkup!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 424w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 848w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!gkup!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png" width="1456" height="825" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:825,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:178581,&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="/__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 424w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 848w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.png 1272w, /__u/substackcdn.com/image/fetch/$s_!gkup!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F49707a21-3eb5-4c4b-96bc-eba6a3dd13a9_1928x1092.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 aria-hidden="true" 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><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>Before embedding the documents, we need to chunk them into smaller pieces. This helps overcome LLMs&#8217; limitations in terms of input tokens and provides fine-grained information per chunk.</p><p>After chunking the documents with a <strong>chunk_size</strong> of 1200 characters and a <strong>chunk_overlap</strong> of 200, we end up with over 11K splits.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!XqtR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 424w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 848w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 1272w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!XqtR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png" width="1456" height="535" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:535,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:87827,&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="/__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 424w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 848w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.png 1272w, /__u/substackcdn.com/image/fetch/$s_!XqtR!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe68936a3-4390-467e-a1c5-9498e80a42a0_1928x708.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 aria-hidden="true" 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><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="/__u/substackcdn.com/image/fetch/$s_!GH-n!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 424w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 848w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!GH-n!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png" width="472" height="551.0989010989011" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/03106815-af15-4408-b465-2b90a673c221_1500x1751.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1700,&quot;width&quot;:1456,&quot;resizeWidth&quot;:472,&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="/__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 424w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 848w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.png 1272w, /__u/substackcdn.com/image/fetch/$s_!GH-n!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F03106815-af15-4408-b465-2b90a673c221_1500x1751.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 aria-hidden="true" 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><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><strong>2 &#8212; Create an index on Upstash</strong></h3><p>To store document embeddings (and metadata) somewhere, we first have to create an index.</p><p>In this tutorial, we&#8217;ll use <a href="http://upstash.com/?utm_source=Ahmed1">Upstash</a>, a serverless database that is very <strong>cost-efficient.</strong></p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/chat-with-papers-with-code">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[RAG Glossary]]></title><description><![CDATA[A one stop shop to learn about Retrieval Augmented Generation.]]></description><link>https://thetechbuffet.substack.com/p/rag-glossary</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/rag-glossary</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Sun, 21 Jan 2024 19:04:49 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello everyone &#128075; Ahmed here. I&#8217;m the author of <strong>The Tech Buffet</strong>, a newsletter that demystifies complex topics in programming and ML from an engineering perspective.</p><p>Consider subscribing to access exclusive content.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="5275" height="3517" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3517,&quot;width&quot;:5275,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;assorted-title book lot placed on white wooden shelf&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="assorted-title book lot placed on white wooden shelf" title="assorted-title book lot placed on white wooden shelf" srcset="https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1524578271613-d550eacf6090?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8Ym9va3N8ZW58MHx8fHwxNzA1ODYzMTYxfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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 issue, I list the previous articles I wrote on Retrieval Augmented Generation. </p><p>If you&#8217;re new to The Tech Buffet, this might be useful to catch up on the content you missed: explaining RAG mechanisms and unraveling their pitfalls, applying RAGs to SQL generation, getting RAGs to work well in production, different indexing and retrieval methods, etc.</p><p>These posts provide my perspective. After spending several months deploying RAGs in production for my clients, I came to know their ins and outs.</p><p>Expect this list to be regularly updated, serving as an evolving glossary for easy reference.</p><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;af09f8aa-da0e-4c8e-a915-65dcbe82f78e&quot;,&quot;caption&quot;:&quot;Step-by-step tutorial to understand the high-level picture behind RAG: what components are involved and how do they interact with each other?&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #1: How To Design a System To Chat With Your Private Data&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-09-04T09:37:43.566Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3fc84884-35e0-46dc-8bff-0db2bee7a59b_1600x1068.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/design-a-document-qa-system&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:136434403,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:5,&quot;comment_count&quot;:2,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:false,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;560e9472-e7ed-4fd4-aba6-1eff1c287a58&quot;,&quot;caption&quot;:&quot;How to use LangChain to build a simple RAG that connects the different pieces: data loaders, text splitters, embedding model, vector store, LLM.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #2: How To Use LangChain to Perform Question Answering Over Documents&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-09-06T09:00:13.548Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0530f6c4-3f6b-4c34-b7ae-b81c216694a6_2828x1551.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/build-a-document-qa-system-with-langchain&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:136528894,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:3,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;5bc0a7a5-3471-447a-a9da-885bdfd1db36&quot;,&quot;caption&quot;:&quot;RAGs are typically used to answer questions over documents. In this issue, we explore another application that RAGs handle particularly well too: generating SQL queries from plain English instructions.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #4: Turn Complex English Instructions Into Executable SQL With LLMs&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-09-16T09:25:03.547Z&quot;,&quot;cover_image&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a406243f-f37a-427e-a83a-2c3cb605eebe_1238x532.png&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/turn-complex-english-instructions-into-sql&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:137091942,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:4,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;9214d4dd-790f-4f4e-89ca-77b0eedf9912&quot;,&quot;caption&quot;:&quot;We&#8217;ve all seen those demos of chatbots conversing with PDFs or emails.<br />While these systems are certainly impressive, they might not be reliable in production without tweaking and experimentation.<br />In this issue, we explore the problems behind the RAG framework and go over some tips to improve its performance.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #6: Why Your RAG is Not Reliable in Production&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-10-10T06:26:50.905Z&quot;,&quot;cover_image&quot;:&quot;https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/the-probelms-behind-rag&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:137762504,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:7,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;c90c4c62-fde8-409f-bcc8-d9b498787d8a&quot;,&quot;caption&quot;:&quot;In RAGs, the documents you retrieve are not necessarily the documents you index. <br />For example, you can index a paragraph by the question it answers.<br />Discover how you can index data differently to meet your needs.<br />&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #12: Improve RAG Pipelines With These 3 Indexing Methods&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-11-06T09:00:47.091Z&quot;,&quot;cover_image&quot;:&quot;https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/rag-indexing-methods&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:138612438,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:3,&quot;comment_count&quot;:1,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;5c028217-cb35-4bf2-bba4-8052529fcbac&quot;,&quot;caption&quot;:&quot;The RAG literature is flourishing. In this issue, discover 5 industry-driven blog posts that explain how RAGs are implemented in companies to scale and solve business needs.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #13: Getting a RAG To Work Well Is Hard - 5 Blog Posts To Become a RAG Master&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-11-13T09:14:52.238Z&quot;,&quot;cover_image&quot;:&quot;https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/5-curated-rag-blog-posts&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:138444414,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:2,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;735a3afd-70a6-4fbc-96ce-336cd2e8584c&quot;,&quot;caption&quot;:&quot;Evaluating a RAG-based system is hard: this requires manually labeling a test set, some human expertise, and computing complex metrics.<br />This issue presents a solution to evaluate RAGs without any human intervention.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #16: Quickly Evaluate your RAG Without Manually Labeling Test Data&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2023-12-18T16:13:58.889Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/evaluate-rag-with-synthetic-data&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:139825883,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:3,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;3181721d-6746-4828-9ae3-49c2e0881292&quot;,&quot;caption&quot;:&quot;In this issue, we explore this paper: Retrieval-Augmented Generation for Large Language Models<br />It covers everything you need to know about the RAG framework and its limitations. It also lists modern techniques to boost its performance in retrieval, augmentation, and generation.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #17: 9 Effective Techniques To Boost Retrieval Augmented Generation (RAG) Systems&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-01-02T10:11:22.596Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/9-techniques-to-boost-rags&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:140111290,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:5,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><div class="digest-post-embed" data-attrs="{&quot;nodeId&quot;:&quot;9da86430-47fa-402b-858b-00e48959d372&quot;,&quot;caption&quot;:&quot;The documents you retrieve from the vector store are not always relevant to the intention behind the user's query. They might also be redundant or missing crucial information. <br />To improve document retrieval, we explore 3 techniques: query expansion, cross-encoder re-ranking, and embedding adaptors.&quot;,&quot;cta&quot;:null,&quot;showBylines&quot;:true,&quot;showDescription&quot;:true,&quot;showImage&quot;:true,&quot;size&quot;:&quot;md&quot;,&quot;isEditorNode&quot;:true,&quot;title&quot;:&quot;The Tech Buffet #18: Advanced Retrieval Techniques for RAG&quot;,&quot;publishedBylines&quot;:[{&quot;id&quot;:16860229,&quot;name&quot;:&quot;Ahmed Besbes&quot;,&quot;bio&quot;:&quot;Senior ML Engineer by day, content creator by night.\nPassionate about code, design, and automation. \nI write to document my learning and demystify complex topics.&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/784a429d-0a7c-44fa-a87b-bc58650a5aac_1125x1115.jpeg&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:null}],&quot;post_date&quot;:&quot;2024-01-08T09:05:10.248Z&quot;,&quot;cover_image&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg&quot;,&quot;cover_image_alt&quot;:null,&quot;canonical_url&quot;:&quot;https://thetechbuffet.substack.com/p/advanced-retrieval-techniques-for-rag&quot;,&quot;section_name&quot;:null,&quot;video_upload_id&quot;:null,&quot;id&quot;:140451945,&quot;type&quot;:&quot;newsletter&quot;,&quot;reaction_count&quot;:4,&quot;comment_count&quot;:0,&quot;publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Tech Buffet&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F4a242a39-6d49-44d0-b54b-8454dbbaa048_512x512.png&quot;,&quot;belowTheFold&quot;:true,&quot;youtube_url&quot;:null,&quot;show_links&quot;:null,&quot;feed_url&quot;:null}"></div><div><hr></div><p>I hope you&#8217;ll find something that interests you in this list. If you have any questions regarding one of the issues, don&#8217;t hesitate to send me a message or drop a comment here. If you also have another topic in mind about RAGs, let me know.</p><p>In future issues, The Tech Buffet will cover practical tutorials on programming and DevOps. The goal is to help you build ML solutions (like RAGs) that scale in a production environment. </p><p>There&#8217;s already a backlog of posts, but if you&#8217;re interested in a particular topic, I&#8217;d love to hear your suggestions. </p><p>Until next time &#128075;</p><p>Ahmed</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/p/rag-glossary?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/thetechbuffet.substack.com/p/rag-glossary?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #18: Advanced Retrieval Techniques for RAG]]></title><description><![CDATA[Query expansion, cross-encoder re-ranking and embedding adaptors]]></description><link>https://thetechbuffet.substack.com/p/advanced-retrieval-techniques-for-rag</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/advanced-retrieval-techniques-for-rag</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Mon, 08 Jan 2024 09:05:10 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!zkeI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>The Tech Buffet demystifies complex topics in programming and ML and delivers practical tips from the industry.</p><p>100% bulsh** free, 0% ChatGPT content.</p><p>Subscribe for the good stuff &#128071;</p></blockquote><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!zkeI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!zkeI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg" width="1456" height="1048" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1048,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:848841,&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="/__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!zkeI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d8e4584-2628-4870-8d84-c861b5c823e3_1456x1048.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 aria-hidden="true" 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><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>Today&#8217;s issue will cover 3 powerful techniques that efficiently improve document retrieval in RAG-based applications. </p><ol><li><p>Query expansion</p></li><li><p>Cross-encoder re-ranking</p></li><li><p>Embedding adaptors</p></li></ol><p>By implementing them, you will retrieve more relevant documents that better align with the user query, thus making the generated answer more impactful.</p><div><hr></div><h3>1&#8212; Query expansion</h3><p>Query expansion refers to a set of techniques that rephrase the original query. </p><p>We&#8217;ll look at two methods:</p><h4>&#128073; Query expansion with a generated answer</h4><p>Given an input query, this method first instructs an LLM to provide a hypothetical answer, whatever its correctness.</p><p>Then, the query and the generated answer are combined in a prompt and sent to the retrieval system. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!RU8p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 424w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 848w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!RU8p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png" width="493" height="477.1200585651537" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:661,&quot;width&quot;:683,&quot;resizeWidth&quot;:493,&quot;bytes&quot;:118151,&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="/__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 424w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 848w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.png 1272w, /__u/substackcdn.com/image/fetch/$s_!RU8p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fac06b3c5-b0b2-44aa-aad0-6f107df1a578_683x661.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 aria-hidden="true" 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><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><blockquote><p>This technique <strong>surprisingly works well</strong>. Check the findings of this <a href="https://arxiv.org/abs/2212.10496">paper</a> to learn more about it.</p></blockquote><p>The rationale behind this method is that we want to retrieve documents that look more like an answer. The correctness of the hypothetical answer doesn&#8217;t matter much because what we&#8217;re really interested in is its structure and formulation.</p><p>At best, you could consider the hypothetical answer as a template that helps identify a relevant neighborhood in the embedding space.</p><p>Here&#8217;s an example of a prompt I used to augment the query for a RAG that answers questions about financial reports.</p><pre><code>You are a helpful expert financial research assistant. 

Provide an example answer to the given question, that might be found in a document like an annual report.</code></pre><h4>&#128073; Query expansion with multiple related questions</h4><p>This second method instructs an LLM to generate N questions related to the original query and then sends them all (+ the original query) to the retrieval system.</p><p>By doing this, more documents will be retrieved from the vectorstore. However, some of them will be duplicates which is why you need to perform post-processing.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AM6p!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 424w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 848w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AM6p!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png" width="507" height="500.39652677279304" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/64e67f47-4dde-4646-8e78-19847022386b_691x682.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:682,&quot;width&quot;:691,&quot;resizeWidth&quot;:507,&quot;bytes&quot;:120872,&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="/__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 424w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 848w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AM6p!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F64e67f47-4dde-4646-8e78-19847022386b_691x682.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 aria-hidden="true" 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><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 idea behind this method is that you extend the initial query that may be incomplete and incorporate related aspects that can be eventually relevant and complementary.</p><p>Here&#8217;s a prompt I used to generate related questions:</p><pre><code><code>You are a helpful expert financial research assistant. 
Your users are asking questions about an annual report.
Suggest up to five additional related questions to help them find the information they need, for the provided question.
Suggest only short questions without compound sentences. Suggest a variety of questions that cover different aspects of the topic.
Make sure they are complete questions, and that they are related to the original question.
Output one question per line. Do not number the questions."</code></code></pre><p>The downside of this method is that we end up with a lot more documents that may distract the LLM from generating a useful answer. </p><p><strong>That&#8217;s where re-ranking comes into play.</strong></p><blockquote><p>To learn more about different query expansion techniques, check this <a href="https://arxiv.org/abs/2305.03653">paper</a> for Google.</p></blockquote><h3>2&#8212;Cross encoder re-ranking</h3><p>This method re-ranks the retrieved documents according to a score that quantifies their relevancy with the input query.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!p2_2!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!p2_2!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png" width="526" height="534.065717415115" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/496bd9af-490d-4428-9029-391002ba98f8_913x927.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:927,&quot;width&quot;:913,&quot;resizeWidth&quot;:526,&quot;bytes&quot;:202466,&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="/__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 424w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 848w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.png 1272w, /__u/substackcdn.com/image/fetch/$s_!p2_2!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F496bd9af-490d-4428-9029-391002ba98f8_913x927.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 aria-hidden="true" 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><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>To compute this score, we will use a <em>cross-encoder.</em> </p><p>A cross-encoder is a deep neural network that processes two input sequences together as a single input. This allows the model to directly compare and contrast the inputs, understanding their relationship in a more integrated and nuanced way.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SR_5!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 424w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 848w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SR_5!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png" width="313" height="345" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:345,&quot;width&quot;:313,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:28486,&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="/__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 424w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 848w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SR_5!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F11023a3a-557b-4926-b1f3-3c905bb58382_313x345.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 aria-hidden="true" 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><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>Cross-encoders  can be used for Information Retrieval: given a query, encode the query with all retrieved documents. Then, sort them in a decreasing order. The high-scored documents are the most relevant ones.</p><blockquote><p>See <strong><a href="https://www.sbert.net/examples/applications/retrieve_rerank/README.html">SBERT.net Retrieve &amp; Re-rank</a></strong> for more details.</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!nI5I!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 424w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 848w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 1272w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!nI5I!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png" width="645" height="479" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:479,&quot;width&quot;:645,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:64236,&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="/__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 424w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 848w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.png 1272w, /__u/substackcdn.com/image/fetch/$s_!nI5I!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F77b480c8-6b41-481b-ab50-e63b205eb2be_645x479.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 aria-hidden="true" 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><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&#8217;s how to quickly get started with re-ranking using cross-encoders:</p><ul><li><p>Install sentence-transformers:</p><pre><code>pip install -U sentence-transformers</code></pre></li><li><p>Import the cross-encoder and load it:</p><pre><code>from sentence_transformers import CrossEncoder
cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2')</code></pre></li><li><p>Score each pair of (query, document):</p><pre><code><code>pairs = [[query, doc] for doc in retrieved_documents]
scores = cross_encoder.predict(pairs)
print("Scores:")
for score in scores:
    print(score)

Scores:
0.98693466
2.644579
-0.26802942
-10.73159
-7.7066045
-5.6469955
-4.297035
-10.933233
-7.0384283
-7.3246956</code></code></pre></li><li><p>Reorder the documents:</p><pre><code><code>print("New Ordering:")
for o in np.argsort(scores)[::-1]:
    print(o+1)</code></code></pre></li></ul><blockquote><p>Cross-encoder re-ranking can be used with query expansion: after you generate multiple related questions and retrieve the corresponding documents (say you end up with M documents),  you re-rank them and pick the top K (K &lt; M).<br>That way, you reduce the context size while selecting the most important pieces.</p></blockquote><p>In the next section, we&#8217;re going to dive into adaptors, a powerful yet simple-to-implement technique to scale embeddings to better align with the user&#8217;s task.</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/advanced-retrieval-techniques-for-rag">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #17: 9 Effective Techniques To Boost Retrieval Augmented Generation (RAG) Systems]]></title><description><![CDATA[ReRank, Hybrid Search, Query Expansion, Leveraging Metadata and more...]]></description><link>https://thetechbuffet.substack.com/p/9-techniques-to-boost-rags</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/9-techniques-to-boost-rags</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Tue, 02 Jan 2024 10:11:22 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!-J8-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello everyone &#128075; Ahmed here. I&#8217;m the author of The Tech Buffet, a newsletter that demystifies complex topics in programming and AI. Subscribe for exclusive content.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!-J8-!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!-J8-!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg" width="1456" height="1047" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1047,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:680102,&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="/__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!-J8-!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F13f46ee0-3232-4555-bfca-6ba709371825_1458x1048.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 aria-hidden="true" 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><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>2023 was, by far, the most prolific year in the history of NLP. This period saw the emergence of ChatGPT alongside numerous other Large Language Models, both open-source and proprietary. </p><p>At the same time, fine-tuning LLMs became way easier and the competition among cloud providers for the GenAI offering intensified significantly. </p><p>Interestingly, the demand for personalized and fully operational RAGs also skyrocketed across various industries, with each client eager to have their own tailored solution.</p><p><strong>Speaking of this last point, creating fully functioning RAGs, in today&#8217;s issue we will discuss a <a href="https://arxiv.org/pdf/2312.10997.pdf">paper</a> that reviews the current state of the art of building those systems.</strong></p><div><hr></div><p>I started reading this piece during my vacation</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_g-M!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_g-M!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg" width="518" height="690.6666666666666" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1600,&quot;width&quot;:1200,&quot;resizeWidth&quot;:518,&quot;bytes&quot;:219959,&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="/__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!_g-M!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F16d371f4-dd14-4d57-8a76-ff55e2768ddc_1200x1600.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 aria-hidden="true" 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><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">Retrieval-Augmented Generation for Large Language Models: A Survey</figcaption></figure></div><p>and it&#8217;s a must.</p><p>It covers everything you need to know about the RAG framework and its limitations. It also lists modern techniques to boost its performance in retrieval, augmentation, and generation.</p><p>The ultimate goal behind these techniques is to make this framework ready for scalability and production use, especially for use cases and industries where answer quality matters <strong>*a lot*.</strong><br><br>I won&#8217;t discuss everything in this paper, but here are the key ideas that, in my opinion, would make your RAG more efficient.</p><h3>1&#8212;&#128451;&#65039; <strong>Enhance the quality of indexed data</strong></h3><p>As the data we index determines the quality of the RAG&#8217;s answers, the first task is to curate it as much as possible before ingesting it. <em>(Garbage in, garbage out still applies here)<br></em>You can do this by removing duplicate/redundant information, spotting irrelevant documents, and checking for fact accuracy (if possible).<br>If the maintainability of the RAG matters, you also need to add mechanisms to refresh outdated documents.<br><br>Cleaning the data is a step that is often neglected when building RAGs, as we usually tend to pour in all the documents we have without verifying their quality.</p><p>Here are some quick fixes that I suggest you go through:</p><ul><li><p>Remove text noise by cleaning special characters, weird encodings, unnecessary HTML tags&#8230; Remember that old NLP techniques using regex? You can reuse them.</p></li><li><p>Spot document outliers that are irrelevant to the main topics and remove them. You can do this by implementing some topic extraction, dimensionality reduction techniques, and data visualization.</p></li><li><p>Remove redundant documents by using similarity metrics</p><p></p></li></ul><h3>2&#8212;&#128736;&#65039; <strong>Optimize index structure</strong> </h3><p>When constructing your RAG, the chunk size is a key parameter. It determines the length of the documents we retrieve from the vector store. <br>A small chunk size might result in documents that miss some crucial information while a large chunk size can introduce irrelevant noise.</p><p>Coming up with the optimal chunk size is about finding the right balance.<br><br>How to do that efficiently? Trial and error. </p><p>However, this doesn&#8217;t mean that you have to make some random guesses and perform qualitative assessments for every experience.</p><p>You can find that optimal chunk size by running evaluations on a test set and computing metrics. LlamaIndex has interesting features to do this. You can read more about that in their <a href="https://blog.llamaindex.ai/evaluating-the-ideal-chunk-size-for-a-rag-system-using-llamaindex-6207e5d3fec5">blog</a>.</p><h3><strong>3&#8212;&#127991;&#65039; Add metadata</strong> </h3><p>Incorporating metadata with the indexed vectors helps better structure them while improving search relevance.</p><p>Here are some scenarios where metadata is useful:</p><ul><li><p>If you search for items and recency is a criterion, you can sort over a date metadata </p></li><li><p>If you search over scientific papers and you know in advance that the information you&#8217;re looking for is always located in a specific section, say the experiment section for example, you can add the article section as metadata for each chunk and filter on it to match experiments only</p></li></ul><p>Metadata is useful because it brings an additional layer of  structured search on top vector search.</p><h3>4&#8212;&#8596;&#65039; Align the input query with the documents </h3><p>LLMs and RAGs are powerful because they offer the flexibility of expressing your query in natural language, thus lowering the entry barrier for data exploration and more complex tasks. (Learn <a href="/__u/thetechbuffet.substack.com/p/turn-complex-english-instructions-into-sql">here</a> how RAGs can help generate SQL code from plain English instructions).</p><p>Sometimes, however, a misalignment appears between the input query the user formulates in the form of a few words or a short sentence, and the indexed documents, which are often written in the form of longer sentences or even paragraphs.</p><p>Let&#8217;s go through an example to understand this.</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/9-techniques-to-boost-rags">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #16: Quickly Evaluate your RAG Without Manually Labeling Test Data]]></title><description><![CDATA[Automate the evaluation process of your Retrieval Augment Generation apps without any human intervention]]></description><link>https://thetechbuffet.substack.com/p/evaluate-rag-with-synthetic-data</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/evaluate-rag-with-synthetic-data</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Mon, 18 Dec 2023 16:13:58 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!cKRC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello everyone &#128075; Ahmed here. I&#8217;m the author of The Tech Buffet, a newsletter that demystifies complex topics in programming and AI. Subscribe for exclusive content.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cKRC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cKRC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg" width="1024" height="627" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/ba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:627,&quot;width&quot;:1024,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:147863,&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="/__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 424w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 848w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.jpeg 1272w, /__u/substackcdn.com/image/fetch/$s_!cKRC!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fba4ebc00-1f89-4fae-9474-b61828cc11cd_1024x627.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 aria-hidden="true" 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><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>Today&#8217;s topic is evaluating your RAG without manually labeling test data.</p><p>Measuring the performance of your RAG is something you should care about especially if you&#8217;re building such systems and serving them in production. </p><p>Besides giving you a rough idea of how your application behaves, evaluating your RAG provides quantitative feedback that guides experimentations and the appropriate selection of parameters (LLMs, embedding models, chunk size, top K, etc.)</p><p>Evaluating your RAG is also important for your client or stakeholders because they are <em><strong>always </strong></em>expecting performance metrics to validate your project.<em><br><br></em>Here&#8217;s what this issue covers:</p><ol><li><p>Automatically generating a synthetic test set from your RAG&#8217;s data</p></li><li><p>Overview of popular RAG metrics</p></li><li><p>Computing RAG metrics on the synthetic dataset using the Ragas package</p></li></ol><p><em>PS*: The full code is accessible on a Colab notebook.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/p/notebooks-and-in-depth-coding-tutorials&quot;,&quot;text&quot;:&quot;Get the notebook&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/thetechbuffet.substack.com/p/notebooks-and-in-depth-coding-tutorials"><span>Get the notebook</span></a></p><p><em>PS**: To learn more about RAGs, you can check my previous articles <a href="/__u/thetechbuffet.substack.com/t/llms">here</a>.</em></p><div><hr></div><h3>1&#8212;Generate a synthetic test set &#129514;</h3><p>Let&#8217;s say you&#8217;ve just built a RAG and now want to evaluate its performance. </p><p>To do that, you need an evaluation dataset that has the following columns:</p><ul><li><p><strong>question</strong> (str): to evaluate the RAG on</p></li><li><p><strong>ground_truths</strong> (list): the reference (i.e. true) answers to the questions</p></li><li><p><strong>answer</strong> (str): the answers predicted by the RAG</p></li><li><p><strong>contexts</strong> (list): the list of relevant contexts the RAG used for each question to generate the answer</p></li></ul><blockquote><p><strong>&#8594; the first two columns represent ground-truth data and the last two columns represent the RAG predictions.</strong></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SckE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 424w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 848w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SckE!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png" width="1200" height="279.3956043956044" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:339,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:179341,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 424w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 848w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SckE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2d167bfe-c009-413b-ad71-932f4351f82e_1555x362.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To build such a dataset, we first need to generate tuples of questions and corresponding answers.</p><p>Then, in the next step, we need to run the RAG over these questions to make the predictions.</p><h4><strong>&#128073; Generate questions and ground-truth answers (the theory)</strong></h4><p>To generate tuples of (question, answer), we first need to prepare the RAG data, split it into chunks, and embed it into a vector database.<br>Once the splits are created and embedded, we will instruct an LLM to generate <code>N_q</code> questions from <code>N_c</code> topics to finally obtain <code>N_q x N_c</code> tuples of questions and answers.</p><p>To generate questions and answers from a given context, we need to go through the following steps:</p><ol><li><p>Sample a random split and use it as a root context</p></li><li><p>Fetch K similar contexts from the vector database</p></li><li><p>Concatenate the texts of the root context with its K neighbors to build a larger context</p></li><li><p>Use the large <code>context</code> and <code>num_questions</code> in the following prompt template to generate questions and answers</p><pre><code>"""\
Your task is to formulate exactly {num_questions} questions from given context and provide the answer to each one.

End each question with a '?' character and then in a newline write the answer to that question using only 
the context provided.
Separate each question/answer pair by "XXX"
Each question must start with "question:".
Each answer must start with "answer:".

The question must satisfy the rules given below:
1.The question should make sense to humans even when read without the given context.
2.The question should be fully answered from the given context.
3.The question should be framed from a part of context that contains important information. It can also be from tables,code,etc.
4.The answer to the question should not contain any links.
5.The question should be of moderate difficulty.
6.The question must be reasonable and must be understood and responded by humans.
7.Do no use phrases like 'provided context',etc in the question
8.Avoid framing question using word "and" that can be decomposed into more than one question.
9.The question should not contain more than 10 words, make of use of abbreviation wherever possible.
    
context: {context}
"""</code></pre></li><li><p>Repeat steps 1 to 4 <code>N_c </code>times to vary the context and generate different questions</p></li></ol><p>I&#8217;ve used this workflow to produce questions and answers on Python programming and here&#8217;s a sample of the results I got.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!vVik!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 424w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 848w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!vVik!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png" width="1342" height="210.6058394160584" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:215,&quot;width&quot;:1370,&quot;resizeWidth&quot;:1342,&quot;bytes&quot;:49877,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 424w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 848w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 1272w, /__u/substackcdn.com/image/fetch/$s_!vVik!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F61c1389e-fafa-4ac4-a18c-54ee1241b2c2_1370x215.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Pretty neat, right? no manual intervention.</p><h4>&#128073; Python implementation  &#128187;</h4><p>Let&#8217;s first start by building a vectorstore that includes the data used by the RAG. </p><p>We can load that from Wikipedia (but if you have any interesting PDF on Python programming, you can load that too)</p><pre><code>from langchain.document_loaders import WikipediaLoader

topic = "python programming"

wikipedia_loader = WikipediaLoader(
    query=topic,
    load_max_docs=1,
    doc_content_chars_max=100000,
)
docs = wikipedia_loader.load()
doc = docs[0]</code></pre><p>After loading the data, we split it into chunks.</p><pre><code>from langchain.text_splitter import RecursiveCharacterTextSplitter

CHUNK_SIZE = 512
CHUNK_OVERLAP = 128

splitter = RecursiveCharacterTextSplitter(
    chunk_size=CHUNK_SIZE,
    chunk_overlap=CHUNK_OVERLAP,
    separators=[". "],
)

splits = splitter.split_documents([doc])</code></pre><p>Then, we create an index in Pinecone:</p><pre><code>import pinecone

pinecone.init(
    api_key=os.environ.get("PINECONE_API_KEY"),
    environment=os.environ.get("PINECONE_ENV"),
)

index_name = topic.replace(" ", "-")
pinecone.init(
    api_key=os.environ.get("PINECONE_API_KEY"),
    environment=os.environ.get("PINECONE_ENV"),
)

if index_name in pinecone.list_indexes():
    pinecone.delete_index(index_name)

pinecone.create_index(index_name, dimension=768)</code></pre><p>and use a LangChain wrapper to index the splits&#8217; embeddings in it.</p><pre><code>from langchain.vectorstores import Pinecone

docsearch = Pinecone.from_documents(
    splits,
    embedding_model,
    index_name=index_name,
)</code></pre><p>Now comes the interesting part: generating the synthetic dataset.</p><p>To do that, we initialize an object from a <code>TestsetGenerator </code>class using an LLM, the document splits, an embedding model, and the name of the Pinecone index.</p><pre><code>from langchain.embeddings import VertexAIEmbeddings
from langchain.llms import VertexAI
from testset_generator import TestsetGenerator

generator_llm = VertexAI(
    location="europe-west3",
    max_output_tokens=256,
    max_retries=20,
)
embedding_model = VertexAIEmbeddings()

testset_generator = TestsetGenerator(
    generator_llm=generator_llm,
    documents=splits,
    embedding_model=embedding_model,
    index_name=index_name,
    key="text",
)</code></pre><p>Then, we call the <code>generate</code> method by passing two parameters: </p><pre><code>synthetic_dataset = testset_generator.generate(
    num_contexts=10,
    num_questions_per_context=2,
)</code></pre><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!q2qK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 424w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 848w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!q2qK!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png" width="1200" height="382.4175824175824" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:464,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 424w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 848w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.png 1272w, /__u/substackcdn.com/image/fetch/$s_!q2qK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6f13a767-9d59-4695-9210-fe52fc240b24_2154x686.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 aria-hidden="true" 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><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>Pretty simple, right?</p><p><strong>If you&#8217;re interested in the implementation details, you can find them in the <a href="https://colab.research.google.com/drive/1Qr3fUfBvJbDLZ0k6al_axlmFrArlm9-u?usp=sharing">notebook</a>.</strong></p><p>We&#8217;re only halfway through it. Now, we need to use the RAG to predict the answers for each question and provide the context list used to ground the response.</p><p>The RAG is defined in a RAG class, so let&#8217;s initialize it first:</p><pre><code>from rag import RAG

rag = RAG(
    index_name,
    "text-bison",
    embedding_model,
    "text",
)</code></pre><p>Then, we iterate over the synthetic dataset by calling the <code>predict</code> method over each question and collect the predictions.</p><pre><code>rag_answers = []
contexts = []

for i, row in synthetic_dataset.iterrows():
    question = row["question"]
    prediction = rag.predict(question)

    rag_answer = prediction["answer"]
    rag_answers.append(rag_answer)
    source_documents = prediction["source_documents"]
    contexts.append([s.page_content for s in source_documents])

synthetic_dataset_rag = synthetic_dataset.copy()
synthetic_dataset_rag["answer"] = rag_answers
synthetic_dataset_rag["contexts"] = contexts</code></pre><p>and here&#8217;s what the final result looks like:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1Pfn!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 424w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 848w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1Pfn!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png" width="1200" height="399.72527472527474" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/51e6fb03-9436-41c0-a993-445247743486_2156x718.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:485,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:346325,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 424w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 848w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1Pfn!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F51e6fb03-9436-41c0-a993-445247743486_2156x718.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 aria-hidden="true" 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><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>&#127942; Congratulations if you&#8217;ve made it this far, now you&#8217;re ready to evaluate your RAG.</p><h3>2&#8212;Popular RAG metrics &#128202;</h3><p>Before jumping into the code, let&#8217;s cover the <strong>four</strong> basic metrics we&#8217;ll use to evaluate our RAG. </p><p>Each metric examines a different facet. Therefore, when evaluating your application, it is crucial to consider multiple metrics for a comprehensive perspective.</p><ol><li><p><strong>Answer Relevancy</strong>:<br>The answer relevance metric is designed to <strong>evaluate the pertinence of the generated answer in relation to the provided prompt</strong>. Answers that lack completeness or include redundant information receive lower scores. This metric utilizes both the question and the answer, generating values between 0 and 1. Higher scores signify better relevance.<br><br><strong>Example</strong></p><p>&#10067;<em>Question: What are the key features of a healthy diet?</em></p><p>&#11015;&#65039; <em>Low relevance answer</em>: A healthy diet is important for overall well-being.</p><p>&#11014;&#65039;<em> High relevance answer</em>: A healthy diet should include a variety of fruits, vegetables, whole grains, lean proteins, and dairy products, providing essential nutrients for optimal health.<br></p></li><li><p><strong>Faithfulness</strong> </p><p>This metric evaluates <strong>the factual consistency of the generated answer within the provided context</strong>. The calculation involves both the answer and the retrieved context, with the answer scaled to a range between 0 and 1, where higher values indicate better faithfulness.</p><p>For an answer to be deemed faithful, all claims made in the response must be inferable from the given context.<br></p><p><strong>Example:</strong> <br>&#10067;<em>Question: What are the main accomplishments of Marie Curie?</em> <br>&#128209; <em>Context</em>: Marie Curie (1867&#8211;1934) was a pioneering physicist and chemist, the first woman to win a Nobel Prize and the only woman to win Nobel Prizes in two different fields.</p><p>&#11014;&#65039; <em>High faithfulness answer</em>: Marie Curie won Nobel Prizes in both physics and chemistry, making her the first woman to achieve this feat.</p><p>&#11015;&#65039; <em>Low faithfulness answer:</em> Marie Curie won Nobel Prizes only in physics.<br></p></li><li><p><strong>Context precision</strong><br>Context Precision is a metric that evaluates whether all of the ground-truth relevant items present in the <code>contexts</code> are ranked higher or not. Ideally, all the relevant chunks must appear at the top ranks. This metric is computed using  <code>question</code> and the <code>contexts</code>, with values ranging between 0 and 1, where higher scores indicate better precision.<br></p></li><li><p><strong>Answer correctness</strong></p><p>This metric measures the accuracy of the generated answer in comparison to the ground truth. This assessment utilizes both the ground truth and the answer, assigning scores within the 0 to 1 range. A higher score indicates a more accurate alignment between the generated answer and the ground truth, indicative of superior correctness.<br></p><p><strong>Example:</strong> <br>&#128994; <em>Ground Truth: The Eiffel Tower was completed in 1889 Paris, France.</em></p><p>&#11014;&#65039; <em>High answer correctness</em>: The construction of the Eiffel Tower concluded in 1889 in Paris, France.</p><p>&#11015;&#65039; <em>Low answer correctness</em>: Completed in 1889, the Eiffel Tower stands in London, England.</p></li></ol><h3>3&#8212;Evaluate RAGs with RAGAS &#128207;</h3><p>To evaluate the RAG and compute the four metrics, we can use <a href="https://github.com/explodinggradients/ragas">Ragas</a>. </p><p>Ragas (for Rag Assessment), is a framework that helps you evaluate your RAG pipelines.</p><p>It also provides a bunch of <a href="https://docs.ragas.io/en/latest/concepts/metrics/index.html">metrics</a> and utility <a href="https://docs.ragas.io/en/latest/concepts/testset_generation.html">functions</a> to generate synthetic datasets.</p><p>To run Ragas over our dataset, you first need to import the metrics and convert the dataframe of synthetic data to a Dataset object.</p><pre><code>from datasets import Dataset
from ragas.llms import LangchainLLM
from ragas.metrics import (
    answer_correctness,
    answer_relevancy,
    answer_similarity,
    context_precision,
    context_recall,
    context_relevancy,
    faithfulness,
)

synthetic_ds_rag = Dataset.from_pandas(synthetic_dataset_rag)</code></pre><p>Then we need to configure Ragas to use VertexAI LLMs and embeddings.</p><p>This step is important since Ragas is configured to use OpenAI by default.</p><pre><code>metrics = [
    answer_relevancy,
    context_precision,
    faithfulness,
    answer_correctness,
    answer_similarity,
]

for m in metrics:
    m.__setattr__("llm", ragas_vertexai_llm)
    if hasattr(m, "embeddings"):
        m.__setattr__("embeddings", vertexai_embeddings)

answer_correctness.faithfulness = faithfulness
answer_correctness.answer_similarity = answer_similarity</code></pre><p>Finally, we call the <code>evaluate</code> function on the synthetic dataset and specify the metrics we want to compute:</p><pre><code>from ragas import evaluate

results_rag = evaluate(
    synthetic_ds_rag,
    metrics=[
        answer_relevancy,
        context_precision,
        faithfulness,
        answer_correctness,
    ],
)</code></pre><p>Once the evaluation is done, you can print the result directly. </p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!e9Zf!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 424w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 848w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!e9Zf!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png" width="1200" height="86.53846153846153" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:105,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:34790,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 424w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 848w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!e9Zf!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F38b54389-ada9-4768-9daa-65eeba24ae60_2052x148.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>or you can convert it to a dataframe to inspect each of these metrics for every question.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cOFb!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 424w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 848w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cOFb!,w_2400,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png" width="1200" height="445.8791208791209" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:false,&quot;imageSize&quot;:&quot;large&quot;,&quot;height&quot;:541,&quot;width&quot;:1456,&quot;resizeWidth&quot;:1200,&quot;bytes&quot;:223471,&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-large" alt="" srcset="/__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 424w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 848w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cOFb!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb5e4660-1eb9-4d80-8b4f-f6fe81daa36a_2120x788.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 aria-hidden="true" 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><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>Conclusion</h3><p>Generating a synthetic dataset to evaluate your RAG is a good start, especially when you don&#8217;t have access to labeled data.</p><p>However, this solution also comes with its problems.</p><p>Some of the generated answers:</p><ul><li><p>May lack diversity</p></li><li><p>Are redundant</p></li><li><p>Are plain rephrasing of the original text and need more complexity to reflect real questions that need reasoning</p></li><li><p>Can be too generic (especially in very technical domains)</p></li></ul><p>To tackle these issues, you can adjust and tune your prompts, filter irrelevant questions, create synthetic questions on specific topics, and use Ragas as well for dataset generation.</p><h3>What to read on Substack?</h3><div class="embedded-post-wrap" data-attrs="{&quot;id&quot;:139691016,&quot;url&quot;:&quot;https://kaitchup.substack.com/p/mixtral-8x7b-understanding-and-running&quot;,&quot;publication_id&quot;:1783977,&quot;embedding_publication_id&quot;:null,&quot;publication_name&quot;:&quot;The Kaitchup &#8211; AI on a Budget&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6b01060-0f1f-4900-b129-f7338526dcbf_128x128.png&quot;,&quot;title&quot;:&quot;Mixtral-8x7B: Understanding and Running the Sparse Mixture of Experts by Mistral AI&quot;,&quot;truncated_body_text&quot;:&quot;Mistral AI released this week their new LLM: mistralai/Mixtral-8x7B-v0.1 (Apache 2.0 license) Mixtral-8x7B is a sparse mixture of 8 expert models. In total, it contains 46.7B parameters and occupies 96.8 GB on the hard drive. Yet, thanks to this architecture, Mixtral-8x7B can efficiently run on consumer hardware. Inference with Mixtral-8x7B is indeed sign&#8230;&quot;,&quot;date&quot;:&quot;2023-12-12T18:46:27.284Z&quot;,&quot;like_count&quot;:9,&quot;comment_count&quot;:0,&quot;bylines&quot;:[{&quot;id&quot;:155699076,&quot;name&quot;:&quot;Benjamin Marie, PhD&quot;,&quot;handle&quot;:&quot;bnjmnmarie&quot;,&quot;previous_name&quot;:&quot;Benjamin Marie&quot;,&quot;photo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b8eb85e0-870b-4e36-a650-6a5a24e23297_75x75.jpeg&quot;,&quot;bio&quot;:&quot;Research scientist in NLP/AI.&quot;,&quot;profile_set_up_at&quot;:&quot;2023-07-06T21:08:12.028Z&quot;,&quot;publicationUsers&quot;:[{&quot;id&quot;:1766855,&quot;user_id&quot;:155699076,&quot;publication_id&quot;:1783977,&quot;role&quot;:&quot;admin&quot;,&quot;public&quot;:true,&quot;is_primary&quot;:false,&quot;publication&quot;:{&quot;id&quot;:1783977,&quot;name&quot;:&quot;The Kaitchup &#8211; AI on a Budget&quot;,&quot;subdomain&quot;:&quot;kaitchup&quot;,&quot;custom_domain&quot;:null,&quot;custom_domain_optional&quot;:false,&quot;hero_text&quot;:&quot;Weekly news, tips, and tutorials on fine-tuning, running, and serving large language models on your computer. Each tutorial is published along with a notebook ready to run.&quot;,&quot;logo_url&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e6b01060-0f1f-4900-b129-f7338526dcbf_128x128.png&quot;,&quot;author_id&quot;:155699076,&quot;theme_var_background_pop&quot;:&quot;#2096FF&quot;,&quot;created_at&quot;:&quot;2023-07-06T21:08:26.883Z&quot;,&quot;rss_website_url&quot;:null,&quot;email_from_name&quot;:&quot;The Kaitchup&quot;,&quot;copyright&quot;:&quot;The Kaitchup&quot;,&quot;founding_plan_name&quot;:&quot;Founding Member&quot;,&quot;community_enabled&quot;:true,&quot;invite_only&quot;:false,&quot;payments_state&quot;:&quot;enabled&quot;,&quot;language&quot;:null,&quot;explicit&quot;:false}}],&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:100}],&quot;utm_campaign&quot;:null,&quot;belowTheFold&quot;:true,&quot;type&quot;:&quot;newsletter&quot;,&quot;language&quot;:&quot;en&quot;,&quot;source&quot;:null}" data-component-name="EmbeddedPostToDOM"><a class="embedded-post" native="true" href="/__u/kaitchup.substack.com/p/mixtral-8x7b-understanding-and-running?utm_source=substack&amp;utm_campaign=post_embed&amp;utm_medium=web"><div class="embedded-post-header"><img class="embedded-post-publication-logo" src="/__u/substackcdn.com/image/fetch/$s_!6qDB!,w_56,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6b01060-0f1f-4900-b129-f7338526dcbf_128x128.png" loading="lazy"><span class="embedded-post-publication-name">The Kaitchup &#8211; AI on a Budget</span></div><div class="embedded-post-title-wrapper"><div class="embedded-post-title">Mixtral-8x7B: Understanding and Running the Sparse Mixture of Experts by Mistral AI</div></div><div class="embedded-post-body">Mistral AI released this week their new LLM: mistralai/Mixtral-8x7B-v0.1 (Apache 2.0 license) Mixtral-8x7B is a sparse mixture of 8 expert models. In total, it contains 46.7B parameters and occupies 96.8 GB on the hard drive. Yet, thanks to this architecture, Mixtral-8x7B can efficiently run on consumer hardware. Inference with Mixtral-8x7B is indeed sign&#8230;</div><div class="embedded-post-cta-wrapper"><span class="embedded-post-cta">Read more</span></div><div class="embedded-post-meta">3 years ago &#183; 9 likes &#183; Benjamin Marie, PhD</div></a></div><div class="embedded-post-wrap" data-attrs="{&quot;id&quot;:115060492,&quot;url&quot;:&quot;https://magazine.sebastianraschka.com/p/understanding-large-language-models&quot;,&quot;publication_id&quot;:1174659,&quot;embedding_publication_id&quot;:null,&quot;publication_name&quot;:&quot;Ahead of AI&quot;,&quot;publication_logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dcbe6f-2617-404f-8368-9bc428272016_1280x1280.png&quot;,&quot;title&quot;:&quot;Understanding Large Language Models&quot;,&quot;truncated_body_text&quot;:&quot;Note: Next to the monthly Ahead of AI series that discusses the latest research and trends, I plan to post some additional articles related to machine learning and AI once in a while. I am curious to hear what you think &#8212; do you like this idea, or should I stick to the main newsletter series? Please let me know in the comments!&quot;,&quot;date&quot;:&quot;2023-04-16T12:33:46.854Z&quot;,&quot;like_count&quot;:592,&quot;comment_count&quot;:27,&quot;bylines&quot;:[{&quot;id&quot;:27393275,&quot;name&quot;:&quot;Sebastian Raschka, PhD&quot;,&quot;handle&quot;:&quot;rasbt&quot;,&quot;previous_name&quot;:&quot;Sebastian Raschka&quot;,&quot;photo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/61f4c017-506f-4e9b-a24f-76340dad0309_800x800.jpeg&quot;,&quot;bio&quot;:&quot;Sebastian is a machine learning and AI researcher with over a decade of experience in the field. He is very passionate about explaining complex technical concepts and \&quot;taking the magic out of AI.\&quot;&quot;,&quot;profile_set_up_at&quot;:&quot;2022-10-09T16:19:59.744Z&quot;,&quot;publicationUsers&quot;:[{&quot;id&quot;:1127862,&quot;user_id&quot;:27393275,&quot;publication_id&quot;:1174659,&quot;role&quot;:&quot;admin&quot;,&quot;public&quot;:true,&quot;is_primary&quot;:false,&quot;publication&quot;:{&quot;id&quot;:1174659,&quot;name&quot;:&quot;Ahead of AI&quot;,&quot;subdomain&quot;:&quot;sebastianraschka&quot;,&quot;custom_domain&quot;:&quot;magazine.sebastianraschka.com&quot;,&quot;custom_domain_optional&quot;:false,&quot;hero_text&quot;:&quot;Ahead AI specializes in Machine Learning &amp; AI research and is read by tens of thousands of researchers and practitioners who want to stay ahead in the ever-evolving field.&quot;,&quot;logo_url&quot;:&quot;https://bucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com/public/images/d4dcbe6f-2617-404f-8368-9bc428272016_1280x1280.png&quot;,&quot;author_id&quot;:27393275,&quot;theme_var_background_pop&quot;:&quot;#2096FF&quot;,&quot;created_at&quot;:&quot;2022-11-04T18:30:05.218Z&quot;,&quot;rss_website_url&quot;:null,&quot;email_from_name&quot;:null,&quot;copyright&quot;:&quot;Sebastian Raschka&quot;,&quot;founding_plan_name&quot;:&quot;\&quot;I Can Expense It\&quot; Tier&quot;,&quot;community_enabled&quot;:true,&quot;invite_only&quot;:false,&quot;payments_state&quot;:&quot;enabled&quot;,&quot;language&quot;:null,&quot;explicit&quot;:false}}],&quot;twitter_screen_name&quot;:&quot;rasbt&quot;,&quot;is_guest&quot;:false,&quot;bestseller_tier&quot;:100}],&quot;utm_campaign&quot;:null,&quot;belowTheFold&quot;:true,&quot;type&quot;:&quot;newsletter&quot;,&quot;language&quot;:&quot;en&quot;,&quot;source&quot;:null}" data-component-name="EmbeddedPostToDOM"><a class="embedded-post" native="true" href="https://magazine.sebastianraschka.com/p/understanding-large-language-models?utm_source=substack&amp;utm_campaign=post_embed&amp;utm_medium=web"><div class="embedded-post-header"><img class="embedded-post-publication-logo" src="/__u/substackcdn.com/image/fetch/$s_!AEiF!,w_56,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dcbe6f-2617-404f-8368-9bc428272016_1280x1280.png" loading="lazy"><span class="embedded-post-publication-name">Ahead of AI</span></div><div class="embedded-post-title-wrapper"><div class="embedded-post-title">Understanding Large Language Models</div></div><div class="embedded-post-body">Note: Next to the monthly Ahead of AI series that discusses the latest research and trends, I plan to post some additional articles related to machine learning and AI once in a while. I am curious to hear what you think &#8212; do you like this idea, or should I stick to the main newsletter series? Please let me know in the comments&#8230;</div><div class="embedded-post-cta-wrapper"><span class="embedded-post-cta">Read more</span></div><div class="embedded-post-meta">3 years ago &#183; 592 likes &#183; 27 comments &#183; Sebastian Raschka, PhD</div></a></div><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share&quot;,&quot;text&quot;:&quot;Share The Tech Buffet&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/thetechbuffet.substack.com/?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share The Tech Buffet</span></a></p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #15: Build and Evaluate LLM Applications with TruLens]]></title><description><![CDATA[Understand why your LLMs responded that way and take actions to prevent hallucinations]]></description><link>https://thetechbuffet.substack.com/p/evaluate-llms-with-trulens</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/evaluate-llms-with-trulens</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Sun, 03 Dec 2023 11:02:58 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="712" height="474.6666666666667" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4000,&quot;width&quot;:6000,&quot;resizeWidth&quot;:712,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;person using magnifying glass to see gold and white device gear&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="person using magnifying glass to see gold and white device gear" title="person using magnifying glass to see gold and white device gear" srcset="https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1520500807606-4ac9ae633574?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMHx8bWFnbmlmeWluZ3xlbnwwfHx8fDE3MDE1OTk5NTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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><blockquote><p><em>Hello &#128075;  this is Ahmed, your host at The Tech Buffet. If you&#8217;re new to this newsletter, it&#8217;s your go-to place for ML engineering insights, coding best practices and tool reviews.<br>You&#8217;ll also see a lot of content about LLMs here. No hype, no BS. I promise.</em></p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>This issue is about a tool I started using recently to track the performance of RAG-based applications. It&#8217;s called <a href="https://www.trulens.org/">TruLens</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Wxk7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 424w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 848w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Wxk7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png" width="1311" height="417" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:417,&quot;width&quot;:1311,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:189560,&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="/__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 424w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 848w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Wxk7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6303963c-6694-4781-aac2-9e8f5d9515df_1311x417.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 aria-hidden="true" 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><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>TruLens is an open-source package that helps you evaluate and monitor your LLM applications. </p><p>It comes particularly in handy if you build RAGs and struggle to find their optimal parameters. </p><p>To help with this, TruLens tracks your RAG experiments, compares them with custom metrics, diagnoses errors, and allows you to land on an optimal configuration.</p><p>In this issue, we&#8217;ll see how this works for a simple and practical use case: <strong>Answering questions about Albert Einstein given a short text about him.</strong></p><p>This is a practical tutorial that you can follow step by step. (it&#8217;s also best read on a wide screen like a laptop or a tablet).</p><p>Let&#8217;s dive in.</p><blockquote><p><em>Disclaimer: I&#8217;m not affiliated with TruLens and this is not a sponsored post.</em></p></blockquote><div><hr></div><p>This issue is broken into 5 sections.</p><h3>1&#65039;&#8419; Setup</h3><p>To prepare the environment and the data needed to build the RAG, we must go over some preliminary steps.</p><ul><li><p>We first install these libraries:</p></li></ul><pre><code>!pip install <strong>trulens_eval</strong>==0.18.1 <strong>chromadb</strong>==0.4.18 <strong>openai</strong>==1.3.1</code></pre><ul><li><p>We set an OpenAI key as an environment variable to be able to use GPT-3.5 as LLM.</p></li></ul><pre><code>import os
os.environ["OPENAI_API_KEY"] = &lt;key&gt;</code></pre><p>&#128073; You can also plug in any open-source LLM from HuggingFace. Learn more about that <a href="https://www.trulens.org/trulens_eval/groundedness_smoke_tests/#groundedness-evaluations">here</a>.</p><ul><li><p>We define a simple text about Albert Einstein to build our RAG on:</p></li></ul><pre><code>einstein_info = """
Albert Einstein (/&#712;a&#618;nsta&#618;n/ EYEN-styne;[4] German: [&#712;alb&#603;&#592;t &#712;&#660;a&#618;n&#643;ta&#618;n] &#9432;; 14 March 1879 &#8211; 18 April 1955) 
was a German-born theoretical physicist who is widely held to be one of the greatest and most influential
scientists of all time. Best known for developing the theory of relativity, Einstein also made important 
contributions to quantum mechanics, and was thus a central figure in the revolutionary reshaping of the 
scientific understanding of nature that modern physics accomplished in the first decades of the twentieth century.[1][5] 
His mass&#8211;energy equivalence formula E = mc2, which arises from relativity theory, has been called "the world's 
most famous equation".[6] He received the 1921 Nobel Prize in Physics "for his services to theoretical physics, 
and especially for his discovery of the law of the photoelectric effect",[7] a pivotal step in the development 
of quantum theory. His work is also known for its influence on the philosophy of science.[8][9] In a 1999 poll 
of 130 leading physicists worldwide by the British journal Physics World, Einstein was ranked the greatest 
physicist of all time.[10] His intellectual achievements and originality have made the word Einstein 
broadly synonymous with genius.[11]
"""</code></pre><ul><li><p>And finally, we create a chromadb vector store in memory to store the embedding of the previous text.</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!BQjo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 424w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 848w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!BQjo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png" width="1456" height="1032" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/b73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1032,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:171999,&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="/__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 424w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 848w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BQjo!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fb73f4d73-a97d-448d-b7c6-6f9c851f6e6a_1724x1222.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 aria-hidden="true" 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><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>2&#65039;&#8419; Build a custom RAG with instrumentation</h3><p>In this step, we define a custom RAG in a Python class and add TruLens instrumentation to each of its methods. <br><br>TruLens provides different instrumentation frameworks to allow you to inspect and evaluate the internals of your application and its associated records. This helps you track a wide variety of usage metrics and metadata along with the inputs and outputs of the application.</p><p>Let&#8217;s first look at the RAG implementation.<br><br>We will define three methods:</p><ol><li><p><code>retrieve</code>: to extract relevant texts as context from the vector store given an input query. (we have one text in our chromadb since this is a simple demo, but you get the idea)</p></li><li><p><code>generate_completion</code>: to generate an answer given the query and the retrieved context.</p></li><li><p><code>query</code>: to combine the two previous methods and provide the RAG&#8217;s final answer.<br></p></li></ol><p>For each of these methods, we will add the <strong>@instrument</strong> decorator to track usage metrics and analyze the input and output.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!yV-6!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 424w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 848w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!yV-6!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png" width="1456" height="1695" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1695,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:328319,&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="/__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 424w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 848w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!yV-6!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8d618cf8-1e7f-49cc-a89d-c54c19123445_1818x2116.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 aria-hidden="true" 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><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>3&#65039;&#8419; Create feedback functions</h3><p>Now that the RAG is created, we need to define the feedback functions that evaluate it. <br><br>Feedback functions score the output of the LLM application by analyzing the generated text. <br><br>TruLens provides different feedback functions designed for different purposes, but in our case, we&#8217;ll only use the three following ones:<br><br><strong>&#9989; Response relevance</strong>: to measure the relationship of the final answer to the input question<br><strong>&#9989; Context relevance</strong>: to measure the relationship between the provided context and the input question.<br><strong>&#9989; Groundedness:</strong> to check if the answer is grounded in its supplied context<br><br>You can learn more about TruLens feedback functions <a href="https://www.trulens.org/trulens_eval/function_definitions/">here</a>.</p><p>Back to code.<br><br>To define the three feedback functions, we first need an LLM. This one can be different from the one we used in the RAG to generate the answer. (We can, for example, pick GPT-4 for evaluation tasks since it&#8217;s bigger than GPT-3.5 and shows better reasoning capabilities).</p><pre><code>from trulens_eval.feedback.provider.openai import OpenAI as fOpenAI

fopenai = fOpenAI()</code></pre><p>Each feedback function is then defined separately.</p><p><strong>&#128073; Question / Answer relevance between the overall question (the </strong><code>query </code><strong>argument) and answer (the output):</strong></p><pre><code>from trulens_eval import Feedback, Select
from trulens_eval.feedback import Groundedness

f_qa_relevance = (
    Feedback(
        fopenai.relevance_with_cot_reasons,
        name="Answer Relevance",
    )
    .on(Select.RecordCalls.retrieve.args.query)
    .on_output()
)</code></pre><blockquote><p>&#9888;&#65039; Notice that the input question is referenced here as the query argument of the retrieve method defined in the RAG class. If you named this method <code>fetch </code>for example, the feedback function would be written as following: </p><pre><code>f_qa_relevance = (
    Feedback(
        fopenai.relevance_with_cot_reasons,
        name="Answer Relevance",
    )
    .on(Select.RecordCalls.<strong>fetch</strong>.args.query)
    .on_output()
)</code></pre></blockquote><p><strong>&#128073; Question / Statement relevance between the question (the </strong><code>query </code><strong>argument) and each context chunk:</strong></p><pre><code>f_context_relevance = (
    Feedback(
        fopenai.qs_relevance_with_cot_reasons,
        name="Context Relevance",
    )
    .on(Select.RecordCalls.retrieve.args.query)
    .on(Select.RecordCalls.retrieve.rets.collect())
    .aggregate(np.mean)
)</code></pre><p>In this example, the context is defined as the returned value of the <code>retrieve</code> method, or simply, with the <code>rets</code> argument.</p><p><strong>&#128073;Groundedness:</strong></p><pre><code>grounded = Groundedness(groundedness_provider=fopenai)

# Define a groundedness feedback function
f_groundedness = (
    Feedback(
        grounded.groundedness_measure_with_cot_reasons,
        name="Groundedness",
    )
    .on(Select.RecordCalls.retrieve.rets.collect())
    .on_output()
    .aggregate(grounded.grounded_statements_aggregator)
)</code></pre><p>Here&#8217;s the full code &#128071;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!OMuT!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 424w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 848w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!OMuT!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png" width="1456" height="1422" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1422,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:356408,&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="/__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 424w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 848w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OMuT!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F1a4ba94f-3088-4a87-a525-3f3417f7d2ac_1818x1776.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 aria-hidden="true" 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><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, we wrap the custom RAG with TruCustomApp and add the list of feedback functions for evaluation.</p><pre><code>from trulens_eval import TruCustomApp

tru_rag = TruCustomApp(
    rag,
    app_id="RAG-einstein:v1",
    feedbacks=[
        f_groundedness,
        f_qa_relevance,
        f_context_relevance,
    ],
)</code></pre><h3>4&#65039;&#8419; Run the RAG and track metrics</h3><p>We&#8217;re ready to run some questions over the RAG. </p><p>To make sure instrumentation is enabled, you must call the <code>query</code> method with the <code>tru_rag</code> context manager.</p><pre><code>with tru_rag as recording:
    rag.query("Who is Albert Einstein?")</code></pre><p>Upon running this query, feedback functions and usage metrics are computed. You can visualize them by calling the get_leaderboard method.</p><pre><code>tru.get_leaderboard(app_ids=["RAG-einstein:v1"])</code></pre><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bf6K!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 424w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 848w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bf6K!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png" width="795" height="116" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:116,&quot;width&quot;:795,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16696,&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="/__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 424w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 848w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bf6K!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0d995ec9-ea4a-4fb6-9119-1ecf964074c7_795x116.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>We got 1 for every feedback metric. No surprise, our question was easy.<br><br>Let&#8217;s try another question that goes a bit beyond the provided context.</p><pre><code>with tru_rag as recording:
    rag.query("Did Einstein contribue to the development of the atomic bomb?")</code></pre><p>If we display the metrics again, we notice a drop in the average groundedness and the context relevance. That&#8217;s normal because the context we&#8217;re retrieving for the second query is irrelevant to the question and the answer.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!igLU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 424w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 848w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!igLU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png" width="781" height="116" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:116,&quot;width&quot;:781,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:16999,&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="/__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 424w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 848w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 1272w, /__u/substackcdn.com/image/fetch/$s_!igLU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc11d7479-4140-4b47-b194-54bbb3bf65db_781x116.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><h3><strong>5&#65039;&#8419; Visualize metrics and metadata in the TruLens dashboard</strong></h3><p>How about diving into the RAG answers individually to diagnose precisely what happened and understand why metrics were computed as such? </p><p>This is where it&#8217;s useful to run the <code>run_dashboard</code> method.</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!aDZ1!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 424w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 848w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!aDZ1!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png" width="797" height="185" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/bb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:185,&quot;width&quot;:797,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:32354,&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="/__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 424w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 848w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aDZ1!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fbb73becc-f0bc-45b4-a6a6-6b5958d736b1_797x185.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>If you visit the provided URL, you&#8217;ll see a Streamlit app that summarizes your RAG (<code>RAG-einstein:v1</code>).</p><p>In the first tab, you&#8217;ll see a leaderboard with global averaged metrics:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!aOTU!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!aOTU!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png" width="1456" height="405" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:405,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:79584,&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="/__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 424w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 848w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.png 1272w, /__u/substackcdn.com/image/fetch/$s_!aOTU!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe19d98e3-4b8d-4f7f-b385-050e7f0c7be8_1797x500.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 aria-hidden="true" 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><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 the evaluations tab, you&#8217;ll get more interesting details: the feedback scores for each query and the corresponding LLM&#8217;s answer and reasoning.<br><br>Let&#8217;s monitor what happened for the second query:</p><ul><li><p>We can first see the RAG&#8217;s answer: </p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!OOxE!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 424w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 848w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!OOxE!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png" width="1456" height="312" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:312,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:76051,&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="/__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 424w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 848w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 1272w, /__u/substackcdn.com/image/fetch/$s_!OOxE!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F85c9f2ad-32e5-4f95-a896-4c9d6949f05f_1494x320.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>Then, we can go over each feedback metric to understand why it got its score:<br></p><ul><li><p>&#128073; <strong>Answer relevance =1</strong><br>reason:<em> The response directly addresses the prompt by stating that Einstein did contribute to the development of the atomic bomb. It provides specific details about his indirect contribution through his scientific work and theories, as well as his involvement in urging the United States to develop the bomb.</em></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cRJV!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 424w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 848w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cRJV!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png" width="1430" height="186" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:186,&quot;width&quot;:1430,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:54026,&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="/__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 424w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 848w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cRJV!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2bb6dde5-ea9d-4b11-8dc7-91d782b930a5_1430x186.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p>&#128073; <strong>Context Relevance = 0.2</strong><br>reason: <em>The statement provides information about Albert Einstein's contributions to science, including his work on the theory of relativity and quantum mechanics. It also mentions his Nobel Prize in Physics for his discovery of the law of the photoelectric effect. However, it does not specifically mention his contribution to the development of the atomic bomb.</em></p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!_6VI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 424w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 848w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!_6VI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png" width="1456" height="209" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:209,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:67621,&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="/__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 424w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 848w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 1272w, /__u/substackcdn.com/image/fetch/$s_!_6VI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa4bc0502-e263-4226-b482-01d7ec46a361_1498x215.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><ul><li><p>&#128073; <strong>Groundednes = 0</strong></p></li></ul><p><em>Statement Sentence: Yes, Einstein did contribute to the development of the atomic bomb., </em></p><p><em>Supporting Evidence: NOTHING FOUND</em></p><p><em>Score: 0</em></p><p><em>Statement Sentence: Although he did not directly work on the Manhattan Project, which was the U.S. government's secret research project to develop atomic weapons during World War II, his scientific work and theories, particularly his equation E=mc2, laid the foundation for understanding nuclear energy and the potential for atomic weapons., </em></p><p><em>Supporting Evidence: NOTHING FOUND</em></p><p><em>Score: 0</em></p><p><em>Statement Sentence: Einstein signed a letter to President Franklin D. Roosevelt in 1939, urging the United States to develop an atomic bomb before Nazi Germany could., </em></p><p><em>Supporting Evidence: NOTHING FOUND</em></p><p><em>Score: 0</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!uZSr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 424w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 848w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!uZSr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png" width="1456" height="381" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:381,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:121535,&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="/__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 424w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 848w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.png 1272w, /__u/substackcdn.com/image/fetch/$s_!uZSr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc6cb3d5b-e716-4b0f-9c3e-73a2edb9b8be_1475x386.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 aria-hidden="true" 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><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>Pretty neat, right?</p><h3>Conclusion</h3><p>TruLens is an interesting tool to monitor and diagnose LLM&#8217;s behavior. It personally saved me a lot of hassle going through evaluations myself.</p><p>Additionally, it provides a useful dashboard that can be deployed and shared with colleagues and stakeholders. </p><p>If you found the RAG example we went through quite simple, note that TruLens also integrates with <a href="https://www.trulens.org/trulens_eval/langchain_instrumentation/">LangChain</a> and <a href="https://www.trulens.org/trulens_eval/llama_index_instrumentation/">LlamIndex</a> when building more complex workflows.</p><p>That being said, it&#8217;d be all for me today.</p><p>Thanks for reading &#128591; </p><p>Ahmed</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #14: A 3-Step Approach To Evaluate Your LLM-based Applications]]></title><description><![CDATA[Stop selecting the parameters of your RAG randomly]]></description><link>https://thetechbuffet.substack.com/p/rag-evaluation</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/rag-evaluation</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Sun, 19 Nov 2023 10:13:34 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="5944" height="3430" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3430,&quot;width&quot;:5944,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;gray audio mixer close-up photo&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="gray audio mixer close-up photo" title="gray audio mixer close-up photo" srcset="https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1562403681-c1e256fdc27b?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyNHx8a25vYnN8ZW58MHx8fHwxNzAwMzg3OTgyfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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><blockquote><p>Hello everyone &#128075;, Ahmed here. Welcome to The Tech Buffet, where I share practical insights to build industry-ready ML (and LLM) applications.</p></blockquote><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p><p>Tuning your RAG to get optimal performance takes time as this depends on various  interdependent parameters: <strong>chunk size, overlap, top K retrieved docs, embedding models, LLM, etc.</strong></p><p>The best combination often depends on your data and your use case: you can&#8217;t simply plug in the settings you used in the last project and hope for the same results.</p><p>Most people don&#8217;t address this issue properly and pick parameters almost randomly. While some are comfortable with this approach, I decided to tackle the problem numerically.</p><p><strong>Here&#8217;s where evaluating your RAG comes in.</strong></p><p>In this issue, I&#8217;ll show you a quick method you can follow to efficiently and quickly evaluate your RAGs across two tasks:</p><ol><li><p><strong>Retrieval</strong></p></li><li><p><strong>Generation</strong></p></li></ol><p>By mastering this evaluation pipeline, you can iterate, perform multiple experiments,  compare them with metrics, and hopefully land on the best configuration</p><p>Let&#8217;s see how this works &#128071;.</p><h3><strong>1&#8212;Create a synthetic dataset</strong></h3><p>Evaluating an LLM often requires annotating a test set manually. This takes time, requires domain expertise, and is prone to human errors.</p><p>Hopefully, LLMs can help us with this task.</p><p>Sample N chunks from your data. For each chunk, instruct an LLM to generate K tuples of questions and answers.<br>After the generation is complete, you will obtain a dataset of N*K tuples, each one having (question, answer, context). </p><p><em>Ps: The context here is the original paragraph and its metadata</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!hCeH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 424w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 848w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!hCeH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png" width="1456" height="741" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:741,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:1102248,&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="/__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 424w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 848w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hCeH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe354049a-8875-4f9d-b671-c9b1d2eacfd1_3935x2002.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 aria-hidden="true" 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><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&#8217;s the prompt I used in one of my projects:</p><pre><code>Create exactly {num_questions} questions using the context and make sure each question doesn't reference
terms like "this study", "this research", or anything that's not available to the reader.

End each question with a '?' character and then in a newline write the answer to that question using only 
the context provided.
Separate each question/answer pair by "XXX"
Each question must start with "question:".
Each answer must start with "answer:".
CONTEXT = {context}</code></pre><h3><strong>2&#8212;Run your RAG over each synthetic question </strong></h3><p>Once the dataset is built, you can use your RAG to perform predictions on each question.</p><p>This will generate answers backed by a set of retrieved sources.</p><p>For each question, make sure you list the retrieved documents: this will later be useful for evaluation.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!cXXA!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 424w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 848w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!cXXA!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png" width="1456" height="426" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:426,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:688767,&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="/__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 424w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 848w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.png 1272w, /__u/substackcdn.com/image/fetch/$s_!cXXA!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe883104f-af1f-48a6-bd61-7da315f05d67_4343x1270.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 aria-hidden="true" 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><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><strong>3&#8212;Compute two evaluation metrics</strong></h3><p>Now, you can compute two scores for each question:</p><ol><li><p>A <strong>retrieval score</strong> to assess the relevance of the retrieved documents<br>This score can be binary (1/0 for each prediction) and tells whether the true source for each question is in the list of the retrieved sources.</p><p></p></li><li><p>A <strong>quality score</strong> to evaluate the generated answer given the question and the ground-truth answer. Again, an LLM can be used in this task to produce such evaluation over 5.</p><p><br>Here is the prompt I used:</p><pre><code>Your job is to rate the quality of a generated answer
given a query  and a reference answer.

QUERY = {query}

GENERATED ANSWER = {generated_answer}

REFERENCE ANSWER = {reference_answer}

Your score has to be between 1 and 5.
You must return your response in a line with only the score.
Do not return answers in any other format.
On a separate line provide your reasoning for the score as well</code></pre></li></ol><p>After obtaining these scores for each question, average them over the dataset to obtain the final two metrics.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!INEZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 424w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 848w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 1272w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!INEZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png" width="1456" height="421" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:421,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:950039,&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="/__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 424w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 848w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.png 1272w, /__u/substackcdn.com/image/fetch/$s_!INEZ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F9febaa59-5c9c-4e9c-9c74-ecbb55309663_5439x1573.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 aria-hidden="true" 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><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>Resource:</h3><ul><li><p><a href="https://www.anyscale.com/blog/a-comprehensive-guide-for-building-rag-based-llm-applications-part-1#cold-start">https://www.anyscale.com/blog/a-comprehensive-guide-for-building-rag-based-llm-applications-part-1#cold-start</a></p></li></ul><p>Interested to learn more about RAGs? Feel free to check my previous issues:</p><ul><li><p><a href="/__u/thetechbuffet.substack.com/p/the-probelms-behind-rag">Why Your RAG is Not Reliable in Production</a></p></li></ul><ul><li><p><a href="/__u/thetechbuffet.substack.com/p/5-curated-rag-blog-posts">Getting a RAG To Work Well Is Hard - 5 Blog Posts To Become a RAG Master</a></p></li></ul><h3>Get to know other newsletters I like on this platform &#128071;</h3><div class="embedded-publication-wrap" data-attrs="{&quot;id&quot;:1783977,&quot;embedding_publication_id&quot;:null,&quot;name&quot;:&quot;The Kaitchup &#8211; AI on a Budget&quot;,&quot;logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6b01060-0f1f-4900-b129-f7338526dcbf_128x128.png&quot;,&quot;base_url&quot;:&quot;https://kaitchup.substack.com&quot;,&quot;hero_text&quot;:&quot;Weekly news, tips, and tutorials on fine-tuning, running, and serving large language models on your computer. Each tutorial is published along with a notebook ready to run.&quot;,&quot;author_name&quot;:&quot;Benjamin Marie, PhD&quot;,&quot;show_subscribe&quot;:true,&quot;logo_bg_color&quot;:&quot;#ffffff&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="EmbeddedPublicationToDOMWithSubscribe"><div class="embedded-publication show-subscribe"><a class="embedded-publication-link-part" native="true" href="/__u/kaitchup.substack.com/?utm_source=substack&amp;utm_campaign=publication_embed&amp;utm_medium=web"><img class="embedded-publication-logo" src="/__u/substackcdn.com/image/fetch/$s_!6qDB!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe6b01060-0f1f-4900-b129-f7338526dcbf_128x128.png" width="56" height="56" style="background-color: rgb(255, 255, 255);"><span class="embedded-publication-name">The Kaitchup &#8211; AI on a Budget</span><div class="embedded-publication-hero-text">Weekly news, tips, and tutorials on fine-tuning, running, and serving large language models on your computer. Each tutorial is published along with a notebook ready to run.</div><div class="embedded-publication-author-name">By Benjamin Marie, PhD</div></a><form class="embedded-publication-subscribe" method="GET" action="/__u/kaitchup.substack.com/subscribe"><input type="hidden" name="source" value="publication-embed"><input type="hidden" name="autoSubmit" value="true"><input type="email" class="email-input" name="email" placeholder="Type your email..."><input type="submit" class="button primary" value="Subscribe"></form></div></div><div class="embedded-publication-wrap" data-attrs="{&quot;id&quot;:1174659,&quot;embedding_publication_id&quot;:null,&quot;name&quot;:&quot;Ahead of AI&quot;,&quot;logo_url&quot;:&quot;https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dcbe6f-2617-404f-8368-9bc428272016_1280x1280.png&quot;,&quot;base_url&quot;:&quot;https://magazine.sebastianraschka.com&quot;,&quot;hero_text&quot;:&quot;Ahead AI specializes in Machine Learning &amp; AI research and is read by tens of thousands of researchers and practitioners who want to stay ahead in the ever-evolving field.&quot;,&quot;author_name&quot;:&quot;Sebastian Raschka, PhD&quot;,&quot;show_subscribe&quot;:true,&quot;logo_bg_color&quot;:&quot;#ffffff&quot;,&quot;language&quot;:&quot;en&quot;}" data-component-name="EmbeddedPublicationToDOMWithSubscribe"><div class="embedded-publication show-subscribe"><a class="embedded-publication-link-part" native="true" href="https://magazine.sebastianraschka.com?utm_source=substack&amp;utm_campaign=publication_embed&amp;utm_medium=web"><img class="embedded-publication-logo" src="/__u/substackcdn.com/image/fetch/$s_!AEiF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fbucketeer-e05bbc84-baa3-437e-9518-adb32be77984.s3.amazonaws.com%2Fpublic%2Fimages%2Fd4dcbe6f-2617-404f-8368-9bc428272016_1280x1280.png" width="56" height="56" style="background-color: rgb(255, 255, 255);"><span class="embedded-publication-name">Ahead of AI</span><div class="embedded-publication-hero-text">Ahead AI specializes in Machine Learning &amp; AI research and is read by tens of thousands of researchers and practitioners who want to stay ahead in the ever-evolving field.</div><div class="embedded-publication-author-name">By Sebastian Raschka, PhD</div></a><form class="embedded-publication-subscribe" method="GET" action="https://magazine.sebastianraschka.com/subscribe?"><input type="hidden" name="source" value="publication-embed"><input type="hidden" name="autoSubmit" value="true"><input type="email" class="email-input" name="email" placeholder="Type your email..."><input type="submit" class="button primary" value="Subscribe"></form></div></div><p>This was a short issue for today. Happy Sunday! &#128075;</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #13: Getting a RAG To Work Well Is Hard - 5 Blog Posts To Become a RAG Master]]></title><description><![CDATA[What you should expect: RAG limitations, Tips on performance and production, Applications to specific domains, New methods for retrieval]]></description><link>https://thetechbuffet.substack.com/p/5-curated-rag-blog-posts</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/5-curated-rag-blog-posts</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Mon, 13 Nov 2023 09:14:52 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello there &#128075;&#127995;, this is Ahmed. I write The Tech Buffet to share weekly practical tips on improving ML systems. Consider subscribing to access exclusive content.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>Hello everyone,</p><p>In this issue, I&#8217;m providing you with a list of interesting reads about RAGs.</p><p>This list doesn&#8217;t cover introductory concepts nor does it showcase simple demos of 5-line Langchain snippets.</p><p>Rather, it discusses the limitations of RAG-based systems, offers valuable insights on deploying them in production, and shares a startup&#8217;s experience applying RAGs to the insurance sector.</p><p>This curated list is the result of thorough documentation I conducted while building conversational agents for the pharmaceutical industry.</p><p>I hope you find it useful to you or your teams.</p><p>Get ready to become a RAG master. &#9820;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="6000" height="4000" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4000,&quot;width&quot;:6000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;chess pieces on board&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="chess pieces on board" title="chess pieces on board" srcset="https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1528819622765-d6bcf132f793?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHw2fHxjaGVzc3xlbnwwfHx8fDE2OTk4NjYwMTh8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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">Photo by <a href="https://unsplash.com/@felix_mittermeier">Felix Mittermeier</a> on <a href="https://unsplash.com">Unsplash</a></figcaption></figure></div><div><hr></div><h3><strong>Building RAG-based LLM Applications for Production</strong></h3><p>&#128279; <a href="https://www.anyscale.com/blog/a-comprehensive-guide-for-building-rag-based-llm-applications-part-1">Link</a> <br>&#128104;&#8205;&#128187; Authors: <strong><a href="https://www.anyscale.com/blog?author=goku-mohandas">Goku Mohandas</a> and <a href="https://www.anyscale.com/blog?author=philipp-moritz">Philipp Moritz</a></strong></p><blockquote><p><em><strong>Disclaime</strong>r: One of the authors (Goku Mohandas) is an excellent technical writer and open-source developer. He&#8217;s particularly famous for his website (<a href="https://madewithml.com/">madewithml.com</a>) that taught thousands of developers to productionize ML systems.</em></p></blockquote><p>This post is a production guide for building RAG-based LLM applications.</p><p>It&#8217;s by far the best piece I&#8217;ve read on this topic. I&#8217;m currently using it as a guide to improve my existing RAG-based apps. If you too are getting serious about RAGs, this post is a <em><strong>must-read</strong>.</em></p><p>This tutorial is also well-written, detailed, and easy to follow. Plus, the corresponding code is available on <a href="https://github.com/ray-project/llm-applications">Github</a>.</p><p>This is a long read but here&#8217;s what you&#8217;ll learn if you go through it:</p><ul><li><p>&#128187; Develop a retrieval augmented generation (RAG) LLM app from scratch.</p></li><li><p>&#128640; Scale the major workloads (load, chunk, embed, index, serve, etc.) across multiple workers.</p></li><li><p>&#9989; Evaluate different configurations of our application to optimize for both per-component (ex. retrieval_score) and overall performance (quality_score).</p></li><li><p>&#128256; Implement an LLM hybrid routing approach to bridge the gap b/w OSS and closed-source LLMs.</p></li><li><p>&#128230; Serve the application in a highly scalable and available manner.</p></li><li><p>&#128165; Share the 1st-order and 2nd-order impacts LLM applications have had on products and organizations</p></li></ul><p><strong>&#128588; What did I like the most about this post?</strong> <br>While reading this guide, I learned  about a powerful method to evaluate RAGs. It consists of building a synthetic evaluation dataset and then computing two metrics: one for evaluating the retrieval quality and another one for the generation quality.<br>I applied this evaluation framework to my current RAG-based projects and this helped me quickly iterate on my experiments: this was useful for determining the optimal parameters (chunk size, number of retrieved docs, embedding models, etc) instead of picking them randomly. </p><p>Learn more about RAG evaluation <a href="https://www.anyscale.com/blog/a-comprehensive-guide-for-building-rag-based-llm-applications-part-1#evaluation">here</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!pgxq!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 424w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 848w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 1272w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!pgxq!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png" width="871" height="303" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:303,&quot;width&quot;:871,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;llm evaluations&quot;,&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="llm evaluations" title="llm evaluations" srcset="/__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 424w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 848w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.png 1272w, /__u/substackcdn.com/image/fetch/$s_!pgxq!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F56a55fc0-69e7-4cb3-9bbb-6b7b36afc00e_871x303.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 aria-hidden="true" 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><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><h3><strong>Disadvantages of RAG</strong></h3><p>&#128279; <a href="https://medium.com/@kelvin.lu.au/disadvantages-of-rag-5024692f2c53">Link</a> <br>&#128104;&#8205;&#128187; Author: <strong><a href="https://medium.com/@kelvin.lu.au">Kelvin Lu</a></strong></p><p>If you&#8217;re new to RAGs, it&#8217;s important to be aware of the limitations these systems hide. This will help you diagnose potential errors and manage unrealistic expectations. </p><p>In this timely post, the author provides a refreshing and brutally honest take on RAG's disadvantages. More specifically, he first discusses the semantic limitations of RAGs. Then, he emphasizes the lossy nature of their underlying processes, from chunking and embedding to retrieval and response generation.<br>Interestingly, he also explains why certain types of search like multi-hop Q&amp;A are not suited to RAGs.</p><p>With these limitations in mind, the author suggests that hybrid LLMs combined with external knowledge bases like graph databases are the way to achieve harder-to-reach goals.</p><p><strong>&#128588; What did I like the most about this post?</strong> <br>Similar to any machine learning system, RAGs come with inherent limitations. Amid the excitement surrounding LLM applications, it becomes crucial to gain a clear understanding of their potential. This post aims to provide precisely that insight.</p><div><hr></div><h3><strong>10 Ways to Improve the Performance of Retrieval Augmented Generation Systems</strong></h3><p>&#128279; <a href="https://towardsdatascience.com/10-ways-to-improve-the-performance-of-retrieval-augmented-generation-systems-5fa2cee7cd5c">Link</a> <br>&#128104;&#8205;&#128187; Author: <strong><a href="https://mattambrogi.medium.com/">Matt Ambrogi</a></strong></p><p>After addressing some of RAG&#8217;s shortcomings, it&#8217;s useful to explore practical tips to improve their performance.</p><p>In this post, the author outlines 10 strategies to implement to bridge the gap between getting RAGs to work and getting them to work very well.</p><p>Here&#8217;s a one-sentence summary for each tip:</p><ol><li><p>Inspect and clean the data your RAG relies on to ground an answer</p></li><li><p>Explore different index types: embedding-based, key-word-based and hybrid</p></li><li><p>The chunk size is a hyper-parameter that must be tuned properly</p></li><li><p>Tweak the system prompt to customize your RAG, control its answers, and avoid hallucinations</p></li><li><p>Retrieval is not limited to the k nearest neighbors: you can leverage chunks&#8217; metadata for additional filtering</p></li><li><p>Create specialized indexes (each one for a specific task) and route your query to one of them</p></li><li><p>Rerank the retrieved documents based on relevance</p></li><li><p>Transform your query to help the LLM provide a better answer</p></li><li><p>Fine-tune the embedding model to align it further with your context</p></li><li><p>Debug LLM by using developer tools like <a href="https://rivet.ironcladapp.com/">Rivet</a></p></li></ol><p>Some of these tips are easy to implement directly while others are already integrated in <a href="https://www.llamaindex.ai/">LlamaIndex</a>.</p><p><strong>&#128588; What did I like the most about this post?</strong> <br>In a 9-minute read, the author condenses a wealth of insights that would typically take any ML practitioner weeks (if not months) of experimenting to uncover.</p><div><hr></div><h3><strong>Gen AI: why does simple Retrieval Augmented Generation (RAG) not work for insurance?</strong></h3><p>&#128279; <a href="https://www.zelros.com/2023/10/27/gen-ai-why-does-simple-retrieval-augmented-generation-rag-not-work-for-insurance/">Link</a> <br>&#128104;&#8205;&#128187; Authors: <strong>Damien Philippon, Christophe Bourguignat</strong></p><p>In this article, the authors, who are the founders of a French <a href="https://www.zelros.com/">startup</a> operating in the insurance sector, claim that RAG, on its own, doesn&#8217;t fully satisfy consumer expectations or meet regulations.</p><p>They explain this through multiple reasons, the most interesting one being: the inability of RAGs to understand the structure of insurance documents.  </p><p>In fact, in their default setting, RAGs cannot accurately answer questions like <em><strong>&#8220;Am I covered if a storm damages the trees in my garden?&#8221;</strong></em> because this question needs to be addressed from multiple angles, each one backed with its related policy in a different section of a +70-page contract.</p><p>A generic RAG would answer this question incorrectly because it retrieves a quick mention of the trees somewhere on page 12 (<em>&#8216;your trees and ground plantations&#8217; if they were planted at least two years before the disaster.&#8217;) </em>without connecting this information with the other conditions of the policy that are on page 11, 66, 13, 52, etc.</p><p>More juicy details in the post. &#128070;</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!bNfH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 424w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 848w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!bNfH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png" width="687" height="685" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:685,&quot;width&quot;:687,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:114296,&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="/__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 424w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 848w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.png 1272w, /__u/substackcdn.com/image/fetch/$s_!bNfH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa490ad33-ff4b-430b-8f11-6ddce377579f_687x685.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 aria-hidden="true" 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><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><strong>&#128588; What did I like the most about this post?<br></strong>It&#8217;s uncommon to get tangible and honest feedback from companies, especially when evaluating over-hyped technologies. This post provides a fresh perspective that anyone applying RAGs can benefit from.</p><div><hr></div><h3>Azure Cognitive Search: Outperforming vector search with hybrid retrieval and ranking capabilities</h3><p>&#128279; <a href="https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-cognitive-search-outperforming-vector-search-with-hybrid/ba-p/3929167">Link</a><br>&#128104;&#8205;&#128187; Author: <a href="https://techcommunity.microsoft.com/t5/user/viewprofilepage/user-id/2031971">Alec Berntson</a> </p><p>This post comes from Microsoft&#8217;s tech blog and presents a new method to improve retrieval in RAG applications. This method uses <strong>hybrid retrieval + semantic ranking</strong>.</p><p>The author claims that it&#8217;s the most effective approach for improved relevance out of the box.</p><p><strong>&#128073; Hybrid retrieval (L1)</strong>: Performs both keyword and vector retrieval and applies a fusion step to select the best results from each technique. </p><p><strong>&#128073; Semantic ranking</strong> is performed by Azure Cognitive Search's L2 ranker which utilizes multi-lingual, deep learning models adapted from Microsoft Bing. The Semantic ranker can rank the top 50 results from the L1.</p><p><em>Retrieval comparison using Azure Cognitive Search in various retrieval modes on customer and academic benchmarks. See <a href="https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-cognitive-search-outperforming-vector-search-with-hybrid/ba-p/3929167#generated">&#167;6.1 How we generated the numbers in this post</a> and <a href="https://techcommunity.microsoft.com/t5/ai-azure-ai-services-blog/azure-cognitive-search-outperforming-vector-search-with-hybrid/ba-p/3929167#searchconfiguration">&#167;6.2 Search and Dataset configuration for Table 1</a> for the setup and measurement details.&nbsp;&nbsp;</em></p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JxdH!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 424w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 848w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JxdH!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png" width="705" height="305" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:305,&quot;width&quot;:705,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:33533,&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="/__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 424w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 848w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JxdH!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3854e60c-7b1f-4d90-8079-7e235afdbfee_705x305.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 aria-hidden="true" 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><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="/__u/substackcdn.com/image/fetch/$s_!HOa4!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 424w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 848w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!HOa4!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png" width="1242" height="548" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:548,&quot;width&quot;:1242,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:92154,&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="/__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 424w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 848w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.png 1272w, /__u/substackcdn.com/image/fetch/$s_!HOa4!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5366294e-e376-4837-85fe-eae9a6f290c7_1242x548.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 aria-hidden="true" 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><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><strong>&#128588; What did I like the most about this post?<br></strong>Instead of applying the same retrieval method over and over, this post provides a new approach that beats the existing state-of-the-art.</p><div><hr></div><h3>Thanks for reading &#128591;</h3><p>This is a new format I&#8217;m experimenting with in the newsletter. Please tell me what you think. (was it helpful? boring? too short?)</p><p>Anywho, I hope you learned one thing or two and explored the articles I shared with you.</p><p>Have a good day and until next time! &#128075;</p><p>Ahmed</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #12: Improve RAG Pipelines With These 3 Indexing Methods]]></title><description><![CDATA[The data we retrieve doesn&#8217;t have to be the same as the data we used while indexing]]></description><link>https://thetechbuffet.substack.com/p/rag-indexing-methods</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/rag-indexing-methods</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Mon, 06 Nov 2023 09:00:47 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello there &#128075;&#127995;, I&#8217;m Ahmed. I write The Tech Buffet to share weekly practical tips on improving ML systems. Join the family (+600 &#127881;) and subscribe!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>In this issue, we&#8217;ll explore 3 different ways you can index your data when building RAGs. </p><p>These methods are worth experimenting with as they can boost the <strong>performance</strong> and <strong>accuracy</strong>.</p><p>Let&#8217;s see how.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="4032" height="3024" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:3024,&quot;width&quot;:4032,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;black and gray metal pipe&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="black and gray metal pipe" title="black and gray metal pipe" srcset="https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1607472586893-edb57bdc0e39?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxNHx8cGlwZWxpbmV8ZW58MHx8fHwxNjk5MjI3MjY4fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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><h3>Reminder on data indexing in typical RAGs</h3><p>In the default implementation of a RAG system, documents are first split into chunks.</p><p>Then, each chunk is embedded and indexed into a vector database. </p><p>In the retrieval step, the input query is also embedded and the most similar chunks are extracted. </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!fnxZ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 424w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 848w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!fnxZ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png" width="1456" height="439" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:439,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:312143,&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="/__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 424w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 848w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.png 1272w, /__u/substackcdn.com/image/fetch/$s_!fnxZ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F53634954-a976-4fa9-b458-cee3165cb7c8_4095x1235.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 aria-hidden="true" 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><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 setup, the data (i.e. <em>the chunks</em>) we retrieve is the same as the data we index.</p><p>This is the most natural and intuitive implementation.</p><p>&#128680; However, this doesn&#8217;t have to be always the case. </p><p>We can index the chunks differently to increase the performance of such systems</p><div class="pullquote"><p><strong>the data we retrieve doesn&#8217;t have to be the same as the data we used while indexing</strong>.</p></div><h3>1&#8212;Index chunks by their subparts &#129513;</h3><p>Instead of indexing the whole chunk directly, we can split it again into smaller pieces (e.g. sentences) and index it with those multiple times.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9QD_!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 424w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 848w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9QD_!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png" width="1456" height="483" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:483,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:386188,&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="/__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 424w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 848w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9QD_!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F6a3cd853-e745-4a86-a2ce-41ffc1e917cf_4380x1454.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 aria-hidden="true" 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><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><blockquote><p><strong>Why is this useful?</strong> </p></blockquote><p>Imagine dealing with long and complex chunks that discuss multiple topics or conflicting information. Using them in a typical RAG will likely generate noisy outputs with some irrelevant content.</p><p>If we separate these chunks into smaller sentences, each sentence will likely have a clear and well-defined topic that matches the user query more accurately. </p><p>When retrieving the chunk, this method makes sure to get a relevant context to the query and a broader context (not present in the indexing sentence) that will be useful for the LLM to generate a comprehensive answer.</p><h3>2&#8212;Index chunks by the questions &#10067;&#65038;they answer</h3><p>Instead of indexing the chunks directly, we can instruct the LLM to generate the questions they answer and use them for indexing. This is a simple approach.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!lfZa!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 424w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 848w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!lfZa!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png" width="1456" height="485" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:485,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:389123,&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="/__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 424w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 848w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.png 1272w, /__u/substackcdn.com/image/fetch/$s_!lfZa!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F91b71590-1d0d-4a30-abe3-592c440eca55_4361x1454.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 aria-hidden="true" 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><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>When submitting the query, the RAG will therefore compare it to the most relevant questions that the data answers. Then, based on these questions, it will retrieve the corresponding chunks.</p><p>This indexing method is useful because it aligns the user's query/objective with the core content of the data. </p><p>If a user doesn&#8217;t formulate a very clear question, such an indexing method can reduce ambiguity. Instead of trying to figure out what chunks are relevant to the user&#8217;s question, we directly map it to existing questions that we know we have an answer for.</p><h3>3&#8212;Index chunks by their summaries &#128221;</h3><p>This indexing method is similar to the previous one. It uses the chunk summary for indexing instead of the questions it answers.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!brov!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 424w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 848w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 1272w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!brov!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png" width="1456" height="480" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:480,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:375758,&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="/__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 424w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 848w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.png 1272w, /__u/substackcdn.com/image/fetch/$s_!brov!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F540a3f56-e9a0-47e3-bb76-aa63dc1ccf40_4598x1517.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 aria-hidden="true" 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><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 typically useful when the chunks have redundant information or irrelevant details that are not useful to the user&#8217;s query.</p><p>It also captures the essence of the information that the user is looking for.</p><div><hr></div><p>That&#8217;s it for today!</p><p>I hope you&#8217;ve enjoyed this issue and learned something useful about improving RAG indexing.</p><p>If you know about other indexing methods that improve RAG systems, please tell me about them (in the comments or via a reply to this email).</p><blockquote><p>Interested in building RAGs for your company? Have a look at my next issue where I cover a curated list of top articles from the industry.</p></blockquote><p>Until next time! &#128075;</p><p>Ahmed</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #11: Ruff - A Blazing Fast Linter and Code Formatter For Python]]></title><description><![CDATA[Unleash the power of Rust.]]></description><link>https://thetechbuffet.substack.com/p/ruff</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/ruff</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Thu, 02 Nov 2023 09:00:38 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="1080" height="608" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:608,&quot;width&quot;:1080,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;long exposure photography of road and cars&quot;,&quot;title&quot;:&quot;long exposure photography of road and cars&quot;,&quot;type&quot;:&quot;image/jpg&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="long exposure photography of road and cars" title="long exposure photography of road and cars" srcset="https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1498084393753-b411b2d26b34?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwyfHxmYXN0fGVufDB8fHx8MTY5ODg3NjI1Mnww&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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><blockquote><p>Hello again &#128075; it&#8217;s Ahmed. I write The Tech Buffet to share practical tips and tutorials helping you build industrial-grade ML applications.<br>Subscribe for exclusive content &#128071;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>If you use Python, you probably use a linter or a code formatter that checks the quality of your codebase. </p><p>This enforces industry standards and normalizes the code quality across the developers of the same team.</p><p>I&#8217;ve personally always used Black, isort, and Flake8 in large codebases.</p><p>In this issue, I want to share a promising alternative that is 10 to 100 times faster than those tools with additional benefits.</p><p>It&#8217;s called <strong><a href="https://github.com/astral-sh/ruff">Ruff</a></strong></p><h3>What is Ruff?</h3><p>Ruff is an extremely fast Python linter and code formatter, written in Rust.</p><blockquote><p>If you don&#8217;t know what Rust is, it is a multi-paradigm, general-purpose programming language that emphasizes <strong>performance</strong>, <strong>type safety</strong>, and <strong>concurrency</strong>.</p></blockquote><p>The main selling point of Ruff is its speed. It is <em><strong>insanely </strong></em>fast. In large codebases, this makes a huge difference by speeding up the developer&#8217;s workflow.</p><p>Multiple benchmarks have been conducted (I read this <a href="https://www.reddit.com/r/Python/comments/16ig4wu/ruff_format_new_tool_to_format_python_files_that/">one</a> on Reddit) and all agree that this tool is 10-100x faster than existing linters (like Flake8) and formatters (like Black).</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!GAGc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 424w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 848w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 1272w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!GAGc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg" width="1456" height="416" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:416,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;Shows a bar chart with benchmark results.&quot;,&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="Shows a bar chart with benchmark results." title="Shows a bar chart with benchmark results." srcset="/__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 424w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 848w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 1272w, /__u/substackcdn.com/image/fetch/$s_!GAGc!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F092d89c4-7417-413f-a44e-6ec9127feb1c_585x167.svg 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 aria-hidden="true" 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><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>You should consider moving to Ruff</h3><p>Ruff has taken the Python community by storm and is now becoming the go-to solution that combines linting and formatting in the same place.</p><p>Here are its main features:</p><ul><li><p>&#128013; It can be installed with <code>pip </code>or <code>poetry</code></p></li><li><p>&#128736;&#65039; It provides support for <code>pyproject.toml</code></p></li><li><p>&#129309; It&#8217;s compatible with modern versions of Python (3.12 at this time of writing)</p></li><li><p>&#9878;&#65039; It&#8217;s 99% compatible with Black and 30x faster</p></li><li><p>&#128230; It has a caching mechanism and reanalyzes unchanged files only</p></li><li><p>&#128295; It spots linting errors like traditional linters and fixes them too</p></li><li><p>&#128207; It has over 700 built-in rules</p></li><li><p>&#9000;&#65039; It integrates well with the developer&#8217;s tool (Jetbrain, Vscode, etc.)</p></li><li><p>&#127758; It&#8217;s mono-repo-friendly</p></li></ul><p>Ruff is under active development and is supported by a large community of developers. </p><p>It&#8217;s also used in major open-source projects:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1dgh!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 424w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 848w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1dgh!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png" width="1456" height="812" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:812,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:250660,&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="/__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 424w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 848w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1dgh!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa8d47334-6b4e-48bb-8389-4bae7ec4d7b1_2154x1201.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 aria-hidden="true" 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><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>Getting started</h3><p>You can install Ruff with pip (or any other package manager):</p><pre><code>pip install ruff</code></pre><p>And you can start using it for lining or formatting from the terminal.</p><ul><li><p>To run Ruff as a linter, you can use one of these commands:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!IU03!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!IU03!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png" width="1456" height="426" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:426,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:188776,&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="/__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!IU03!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F956ec107-fb42-4654-971f-f4264a6c3b78_2176x636.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 aria-hidden="true" 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><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>If Ruff detects linting errors, you can ask it to fix them with this command:</p><pre><code>ruff check . --fix</code></pre><ul><li><p>To run Ruff as a formatter, you can use one of these commands:</p></li></ul><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!9KKo!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!9KKo!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png" width="1456" height="426" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:426,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:188132,&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="/__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 424w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 848w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.png 1272w, /__u/substackcdn.com/image/fetch/$s_!9KKo!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F3652998b-16b5-4c07-ad9b-f24b4db8dd27_2176x636.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 aria-hidden="true" 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><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 also use Ruff in a pre-commit hook via <a href="https://github.com/astral-sh/ruff-pre-commit">ruff-pre-commit</a>.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!hhRr!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 424w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 848w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!hhRr!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png" width="1456" height="501" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:501,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:159722,&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="/__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 424w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 848w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hhRr!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F87c4fb29-b85e-4f17-8c2e-dc15189fe24a_2176x748.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 aria-hidden="true" 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><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><blockquote><p>Not familiar with pre-commit hooks? Check out this <a href="/__u/thetechbuffet.substack.com/p/improve-python-development-workflow">issue</a> when I cover them in details.</p></blockquote><h3>Configuration</h3><p>To determine the appropriate settings for each Python file, Ruff looks for the first <code>pyproject.toml</code>, <code>ruff.toml</code>, or <code>.ruff.toml</code> file in the file's directory or any parent directory.</p><p>To configure Ruff, let's create a <code>pyproject.toml</code> file in our project's root directory. In this example, we&#8217;ll a specific <a href="https://docs.astral.sh/ruff/rules/line-too-long/">rule</a> named line-too-long and defined by the E501 code.</p><pre><code>[project]
# Support Python 3.10+.
requires-python = "&gt;=3.10"

[tool.ruff]
# Set the maximum line length to 79.
line-length = 79

[tool.ruff.lint]
# Add the `line-too-long` rule to the enforced rule set.
extend-select = ["E501"]</code></pre><p>Running Ruff again, we see that it now enforces a maximum line width, with a limit of 79:</p><pre><code>&#10095; ruff check .
numbers/numbers.py:5:80: E501 Line too long (90 &gt; 79)
Found 1 error.</code></pre><p>For a full enumeration of the supported settings, see <a href="https://docs.astral.sh/ruff/settings/">Settings</a>.</p><p>If you want a detailed tutorial on setting up Ruff for your project, have a look a this <a href="https://docs.astral.sh/ruff/tutorial/">link</a>.</p><h3>Resources:</h3><ul><li><p><a href="https://github.com/astral-sh/ruff">https://github.com/astral-sh/ruff</a></p></li></ul><ul><li><p><a href="https://www.reddit.com/r/Python/comments/16ig4wu/ruff_format_new_tool_to_format_python_files_that/">https://www.reddit.com/r/Python/comments/16ig4wu/ruff_format_new_tool_to_format_python_files_that/</a></p></li><li><p><a href="https://docs.astral.sh/ruff/tutorial/">https://docs.astral.sh/ruff/tutorial/</a></p></li><li><p><a href="https://blog.jerrycodes.com/ruff-the-python-linter/">https://blog.jerrycodes.com/ruff-the-python-linter/</a></p></li></ul><p></p><p>This was a quick issue! Thanks for reading. &#128075;</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/p/ruff?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/thetechbuffet.substack.com/p/ruff?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #10: 12 Python Decorators to Take Your Code to the Next Level]]></title><description><![CDATA[Do more things with less code without compromising on quality]]></description><link>https://thetechbuffet.substack.com/p/python-decorators</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/python-decorators</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Tue, 31 Oct 2023 09:00:46 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello, this is Ahmed! &#128075;</p><p>This issue is part of a Python series dedicated to sharing tips and best practices to improve your code.<br>If you&#8217;re interested in this type of content (+ the additional coding material)<br>consider subscribing.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><p>Python decorators are powerful tools that help you produce clean, reusable, and maintainable code. They provide interesting functionalities such as caching, automatic retry, rate limiting, logging, or turning your classes into supercharged data containers.</p><p>I&#8217;ve long waited to learn about these abstractions and now that I&#8217;ve acquired a solid understanding, I&#8217;m writing this practical guide to help you, too, grasp the concepts behind decorators.</p><p>No big intros or lengthy theoretical definitions today.</p><p><strong>This issue is rather a documented list of 12 helpful decorators I regularly use in my projects to extend my code with extra functionalities.<br>We&#8217;ll dive into each decorator, look at the</strong><em><strong> code,</strong></em><strong> and play with some </strong><em><strong>hands-on examples.</strong></em></p><p>If you&#8217;re a Python developer, this post will extend your toolbox with helpful scripts to increase your productivity and avoid code duplication.</p><p>Less talk, I suggest we jump into the code now &#128187;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="6016" height="4016" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4016,&quot;width&quot;:6016,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;a computer screen with a bunch of code on it&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&quot;,&quot;href&quot;:null,&quot;belowTheFold&quot;:false,&quot;topImage&quot;:true,&quot;internalRedirect&quot;:null,&quot;isProcessing&quot;:false,&quot;align&quot;:null,&quot;offset&quot;:false}" class="sizing-normal" alt="a computer screen with a bunch of code on it" title="a computer screen with a bunch of code on it" srcset="https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1515879218367-8466d910aaa4?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwzfHxweXRob258ZW58MHx8fHwxNjk4NzA5NzA0fDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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 class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.substack.com/p/python-decorators?utm_source=substack&utm_medium=email&utm_content=share&action=share&quot;,&quot;text&quot;:&quot;Share&quot;,&quot;action&quot;:null,&quot;class&quot;:null}" data-component-name="ButtonCreateButton"><a class="button primary" href="/__u/thetechbuffet.substack.com/p/python-decorators?utm_source=substack&amp;utm_medium=email&amp;utm_content=share&amp;action=share"><span>Share</span></a></p><div><hr></div><p></p><h3><strong>1 &#8212; @logger (to get started)&#9999;&#65039;</strong></h3><p>If you&#8217;re new to decorators, you can think of them as functions that take functions as input and extend their functionalities without altering their primary purpose.</p><p>Let&#8217;s start with a simple decorator that extends a function by <strong>logging when it starts and ends executing</strong>.</p><p>The result of the function being decorated would look like this:</p><div class="captioned-image-container"><figure><a class="image-link image2" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!w4zi!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 424w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 848w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 1272w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!w4zi!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png" width="480" height="240" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:468,&quot;width&quot;:936,&quot;resizeWidth&quot;:480,&quot;bytes&quot;:35759,&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="/__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 424w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 848w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 1272w, /__u/substackcdn.com/image/fetch/$s_!w4zi!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F878670b0-c9ec-49c5-9410-74c0abb4089f_936x468.png 1456w" sizes="100vw" loading="lazy"></picture><div></div></div></a></figure></div><p>To write this decroator, you first have to pick an appropriate name: let&#8217;s call it <strong>logger.</strong></p><p><strong>logger</strong> is a function that takes a function as input and returns a function as output. The output function is usually an extended version of the input. In our case, we want the output function to surround the call of the input function with <code>start</code> and <code>end</code> statements.</p><p>Since we don&#8217;t know what arguments the input function uses, we can pass them from the wrapper function using <strong>*args</strong> and <strong>**kwargs. </strong>These expressions allow passing an arbitrary number of positional and keyword arguments.</p><p>Here&#8217;s a simple implementation of the <code>logger</code> decorator:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Arpc!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 424w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 848w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Arpc!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png" width="1412" height="554" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:554,&quot;width&quot;:1412,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:83370,&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="/__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 424w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 848w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Arpc!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F97c26a1b-d2ec-4c8f-b945-b73fa5be39ab_1412x554.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 aria-hidden="true" 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><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 you can apply <strong>logger</strong> to <code>some_function</code> or any other function for that matter.</p><pre><code>decorated_function = logger(some_function)</code></pre><p>Python provides a more Pythonic syntax for this, it uses the <strong>@</strong> symbol.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!mpOK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 424w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 848w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!mpOK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png" width="1412" height="810" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:810,&quot;width&quot;:1412,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:93119,&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="/__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 424w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 848w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.png 1272w, /__u/substackcdn.com/image/fetch/$s_!mpOK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F5dba2ce2-a305-49f4-8b94-254964f47cd1_1412x810.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 aria-hidden="true" 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><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>11 decorators left to review. Let&#8217;s move to the next one.</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/python-decorators">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #9: Let's talk about LLM Hallucinations]]></title><description><![CDATA[Why do they happen? How to quantify them? How to avoid them?]]></description><link>https://thetechbuffet.substack.com/p/llms-hallucinations</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/llms-hallucinations</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Tue, 24 Oct 2023 07:05:29 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hey there &#128075; this is Ahmed. With The Tech Buffet, I share digestible tips and concepts to help you industrialize stable ML and LLM applications. </p></blockquote><div class="subscription-widget-wrap-editor" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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">Consider turning into a paid member to access exclusive content: code, notebooks, tool reviews, and in-depth tutorials</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 issue is one of a kind. It covers hallucinations &#129313;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="6720" height="4320" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:4320,&quot;width&quot;:6720,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;red mushrooms&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="red mushrooms" title="red mushrooms" srcset="https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1571074635691-b910c7a5cdbb?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxfHxtdXNocm9vbXxlbnwwfHx8fDE2OTgxMDUyNDd8MA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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>Not exactly these hallucinations, but the ones Large Language Models face.</p><p>If you&#8217;ve ever played with ChatGPT, Bard, Claude, or even one of their open-source brothers (Llama2 or Mistral 7B) you&#8217;ve probably noticed these AI systems produce misleading or incorrect information.</p><p>This is what the AI community agreed to define as <strong>hallucinations.</strong></p><blockquote><p>In this issue, I explain why hallucinations happen, how you can quantitatively evaluate them, and go over the different strategies to mitigate them.</p></blockquote><p>Let&#8217;s dig in &#128269;</p><div><hr></div><h3>Why do LLMs hallucinate?</h3><p>When talking about hallucination in the context of LLMs, it&#8217;s important to keep in mind that this phenomenon happens not because these systems can &#8220;imagine&#8221;, &#8220;perceive&#8221; or &#8220;dream&#8221;.</p><p>First, it's essential to grasp that LLMs are pre-trained to predict tokens. They lack a concept of true or false, instead relying on probabilities for text generation. While this approach enables some unexpected reasoning capabilities, like passing the BAR exam or USMLE, it's a result of their probabilistic, token-by-token reasoning. </p><p>Additional training steps, such as instruct tuning and RLHF in modern LLMs, introduce some "bias towards factuality" but don't alter the fundamental underlying mechanism and its limitations.</p><p>LLMs draw knowledge from vast sources like the internet, books, Q&amp;A databases, and Wikipedia. Their responses tend to be biased towards what they've encountered most frequently. If you ask a medical question without careful prompting, you might receive an answer aligned with established medical literature or random forum discussions.</p><p>Summing up this in two sentences: LLMs hallucinate because they lack reasoning and understanding capabilities. They spit text by extrapolating a prompt and struggle to cite their sources.</p><div><hr></div><h3>How to quantify LLM hallucinations?</h3><p>Evaluating the LLM hallucinations with a number is important when conducting iterative experiments.</p><p>This is where FActScore comes in handy.</p><p><a href="https://arxiv.org/abs/2305.14251">FActScore</a> is a modern metric that serves for both human and model-based assessments. </p><p>It dissects an LLM's generation into "atomic facts," and the overall score is calculated as the sum of the accuracy of these atomic facts, each holding equal importance. </p><p>Accuracy, in this context, is a straightforward binary measure indicating whether the atomic fact is supported by the source. To determine this metric, the authors employ various automation techniques that leverage LLMs and vector stores.</p><p>Here&#8217;s how the FActScore works in practice. &#128071;</p><p>You first instruct your LLM to generate content. Let&#8217;s say, a biography of Bridget Moynahan.</p><blockquote><p>&#8220;Bridget Moynahan is an American actress, model and producer. She is best known for her roles in Grey&#8217;s Anatomy, I, Robot and Blue Bloods. She studied acting at the American Academy of Dramatic Arts, and &#8230;&#8221;</p></blockquote><p>Next, you split this text into atomic facts. </p><ul><li><p>Bridget Moynahan is American. </p></li><li><p>Bridget Moynahan is an actress.</p></li><li><p>Bridget Moynahan is a model.</p></li><li><p>Bridget Moynahan is a producer.</p></li><li><p>She is best known for her roles in Grey&#8217;s Anatomy</p></li></ul><p>Then, you verify each fact with an external source (e.g. Wikipedia). Think RAG here.</p><p>If the fact is supported by the source, this accounts for 1, otherwise it&#8217;s 0.</p><ul><li><p>Bridget Moynahan is American. &#9989; &#8594; 1</p></li><li><p>Bridget Moynahan is an actress. &#9989; &#8594; 1</p></li><li><p>Bridget Moynahan is a model. &#9989; &#8594; 1 </p></li><li><p>Bridget Moynahan is a producer.&#10060; &#8594; 0</p></li><li><p>She is best known for her roles in Grey&#8217;s Anatomy &#10060; &#8594; 0</p><p></p></li></ul><p><strong>The final score is therefore (1+1+1)/ 5 = 0.6</strong></p><p>Here&#8217;s the full example from the original paper&#128071; </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!AnML!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 424w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 848w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!AnML!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png" width="694" height="569.5947802197802" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1195,&quot;width&quot;:1456,&quot;resizeWidth&quot;:694,&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="/__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 424w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 848w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.png 1272w, /__u/substackcdn.com/image/fetch/$s_!AnML!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F2b50a116-c902-470a-b310-d9c5092a8f93_1518x1246.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 aria-hidden="true" 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><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><h3><strong>How to mitigate </strong>hallucinations<strong>?</strong></h3><p>This is a complex problem that you can address from multiple angles.</p><h4><strong>&#128073; Product-Level Recommendations:</strong></h4><p>Hallucinations in Language Models (LLMs) can be a challenge, but with the right strategies, you can minimize their impact. Here are some product-level recommendations to help you navigate this.</p><p>These recommendations challenge the way you intend to apply and interact with LLMs. </p><ol><li><p><strong>Purposeful Design</strong>: Start by structuring your use case to naturally reduce hallucination risks. For instance, for content generation applications, focus on opinion pieces over factual articles.</p></li><li><p><strong>Empower User Editability</strong>: Allow users to fine-tune AI-generated content. This not only enhances scrutiny but also bolsters content reliability.</p></li><li><p><strong>User Accountability</strong>: Clearly communicate that users bear responsibility for the content generated and published.</p></li><li><p><strong>Citations and References</strong>: Implement a feature that includes citations, providing a safety net for users to verify information before sharing.</p></li><li><p><strong>Operational Flexibility</strong>: Offer various operational modes, such as a "precision" mode that utilizes a more accurate model, albeit at a higher computational cost.</p></li><li><p><strong>User Feedback Loop</strong>: Create a feedback mechanism for users to report inaccuracies, harmful content, or incompleteness. This user data is invaluable for refining the model in future iterations.</p></li><li><p><strong>Output Control</strong>: Mindfully manage the length and complexity of generated responses. Longer and more complex outputs have a higher potential for hallucinations.</p></li><li><p><strong>Structured Input/Output</strong>: Consider implementing structured fields rather than free-form text, particularly useful in applications like resume generation. Predefined fields for educational background, work experience, and skills can be a game-changer.</p></li></ol><p>Addressing hallucinations is crucial for LLMs' responsible use. Implementing these recommendations can enhance user experiences and content reliability.</p><h4><strong>&#128073; General prompting guidelines</strong></h4><p>It&#8217;s no secret that adjusting your prompts dramatically improves the answers of your LLM.</p><p>Here are some principles I applied that proved to be effective:</p><ul><li><p><strong>Assertive Tone</strong>: Improve model compliance with ALL CAPS and highlight key directives.</p></li><li><p><strong>Context Matters</strong>: Provide more background information to anchor the model's responses. For example, attributing a &#8220;role&#8221; to the LLM generally helps direct the generated text toward a desired response.</p></li><li><p><strong>Refinement Steps</strong>: Review the initial output and make necessary adjustments.</p></li><li><p><strong>Inline Citations</strong>: Ask the model to back its claims with references.</p></li><li><p><strong>Selective Grounding</strong>: Identify situations where grounding is essential versus optional.</p></li><li><p><strong>Reiteration</strong>: Emphasize key instructions at the end of prompts.</p></li><li><p><strong>Echo Input</strong>: Request the model to recap essential input details for alignment.</p></li><li><p><strong>Algorithmic Filtering</strong>: Utilize algorithms to prioritize relevant information.</p></li></ul><h4>&#128073; Chain Of Thoughts (CoT) </h4><p>The concept of a 'Chain of Thought' was first introduced in the <a href="https://arxiv.org/abs/2201.11903">paper</a> titled 'Chain-of-Thought Prompting Elicits Reasoning in Large Language Models' by researchers at Google. </p><p>The underlying principle is straightforward: since Large Language Models (LLMs) are primarily trained to predict tokens rather than engage in explicit reasoning, you can <strong>encourage reasoning by providing explicit step-by-step instructions</strong>. </p><p>Here's a simple example from the original paper:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!SyrK!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 424w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 848w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!SyrK!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png" width="1456" height="701" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:701,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&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="/__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 424w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 848w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.png 1272w, /__u/substackcdn.com/image/fetch/$s_!SyrK!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc38a9683-ed9b-4f31-96e8-4d3ff5b6511d_1644x792.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 aria-hidden="true" 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><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>There&#8217;s another method to apply CoT called zero-shot CoT where you simply ask the LLM to &#8220;think step by step&#8221;.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!XXqP!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 424w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 848w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 1272w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!XXqP!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png" width="472" height="507.4611398963731" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:830,&quot;width&quot;:772,&quot;resizeWidth&quot;:472,&quot;bytes&quot;:252132,&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="/__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 424w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 848w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.png 1272w, /__u/substackcdn.com/image/fetch/$s_!XXqP!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0582dff9-e2e4-4856-9544-1d6feceb89b4_772x830.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 aria-hidden="true" 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><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>&#128073; Grounding the answer with RAG</h4><p>RAG is the acronym for <strong>Retrieval Augmented Generation.</strong></p><p>The RAG framework is a simple yet powerful framework to mitigate hallucinations. Its primary purpose is to augment an LLM with a factual and verified context drawn from an external database.</p><p>Here&#8217;s how RAG works:</p><p>It first takes an input question and retrieves relevant documents to it from an external database. Then, it passes those chunks as a context in a prompt to help an LLM generate an <em>augmented </em>answer.</p><p>That&#8217;s basically saying:</p><blockquote><p>&#8220;Hey LLM, here&#8217;s my question, and here are some pieces of text to help you understand the problem. Give me an answer.&#8221;</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!BC-h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 424w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 848w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!BC-h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png" width="949" height="644" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:644,&quot;width&quot;:949,&quot;resizeWidth&quot;:null,&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="/__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 424w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 848w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.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 aria-hidden="true" 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><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><p>Hallucinations are what prevent most companies nowadays from deploying LLM-based solutions to production. </p><p>To control this issue, it&#8217;s important to </p><ul><li><p>Understand that this phenomenon is inherent to the way LLMs are trained. Hallucinations happen from pure statistics, not intrinsic cognitive abilities</p></li><li><p>Be able to quantitatively evaluate it to conduct experiments efficiently</p></li><li><p>Mitigate hallucinations with a multi-faceted strategy</p></li></ul><p>I hope this issue addressed these 3 points in the most comprehensive way.</p><p>That&#8217;d be all for me today. </p><p>Until next time &#128075;</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #8: Flowise - An Interface To Build and Test LLMs Apps Easily]]></title><description><![CDATA[With no-code, directly from the browser.]]></description><link>https://thetechbuffet.substack.com/p/build-and-test-llms-with-flowise</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/build-and-test-llms-with-flowise</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Wed, 18 Oct 2023 06:21:32 GMT</pubDate><enclosure url="https://substackcdn.com/image/fetch/$s_!1gUt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!1gUt!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 424w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 848w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!1gUt!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png" width="1456" height="765" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:765,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:419817,&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="/__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 424w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 848w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.png 1272w, /__u/substackcdn.com/image/fetch/$s_!1gUt!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F0b6afb44-edbb-43aa-bb23-efdc1e66472b_2262x1188.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 aria-hidden="true" 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><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="pullquote"><p>Hello there,  I&#8217;m Ahmed Besbes &#128075; </p><p>I write The Tech Buffet to share weekly practical nuggets to improve your code and ship ML applications faster. Consider subscribing to access exclusive content.</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></div><p>Today, we&#8217;ll explore an open-source no-code tool that helps you build and visualize LLM applications. </p><p>If you spend time designing <a href="https://www.hopsworks.ai/dictionary/retrieval-augmented-generation-llm">RAGs</a>, chatbots, or sophisticated agents, this tool will speed up your prototyping.</p><p>&#8627; Here&#8217;s the agenda &#128203;</p><ul><li><p>A quick intro of the solution</p></li></ul><ul><li><p>Setup and configuration</p></li><li><p>Demo: Create a chatbot over PDFs</p></li><li><p>My honest opinion</p></li></ul><div><hr></div><h3>Flowise: an interface for building LLMs</h3><p>The LangChain framework made it very easy to build LLM applications. </p><p>By abstracting objects like chains, retrievers, or document loaders, it gave us the power to compose complex workflows that solve interesting tasks: chatbots over documents, semantic search engines, personal assistants, etc.</p><p><strong><a href="https://flowiseai.com/">Flowise</a> went further to ease this process by providing an interactive UI on top of LangChain.</strong></p><p>By using Flowise, it&#8217;s now possible to build the same chains directly from the browser by selecting the right components and connecting them.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!hIBl!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 424w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 848w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!hIBl!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png" width="1456" height="638" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:638,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:447995,&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="/__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 424w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 848w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.png 1272w, /__u/substackcdn.com/image/fetch/$s_!hIBl!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8e3d9d74-2b76-4db3-8006-b7e2719d8d26_2870x1258.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 aria-hidden="true" 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><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><blockquote><p>It does look good, doesn&#8217;t it? That&#8217;s the power of LangChainJS combined with TypeScript and JavaScript.</p></blockquote><div><hr></div><h3>Setup and configuration</h3><p>To start Flowise on your computer you can either install it from source code or use it in a Docker container. (I recommend the second option)</p><h5>&#8627; Option 1&#8212; Install it from source</h5><p>To install Flowise, make sure you have NodeJS &gt;= 18.15.0 set up on your computer and run this command:</p><pre><code>npm install -g flowise</code></pre><p>After it&#8217;s installed, you can start Flowise with this command:</p><pre><code><code>npx flowise start</code></code></pre><p>You can also specify the username and password as arguments:</p><pre><code><code>npx flowise start --FLOWISE_USERNAME=user --FLOWISE_PASSWORD=1234</code></code></pre><p>The app is now accessible on <strong>http://localhost:3000</strong></p><h5>&#8627; Option 2&#8212; Run Flowise in a Docker container</h5><p>To run Flowise using Docker, go to the <code>Docker</code> folder at the root of the <a href="https://github.com/FlowiseAI/Flowise">project</a>.</p><p>Then copy the <code>.env.example</code> file, paste it into the same location, and rename it to <code>.env.</code></p><p>Run this Docker command to start the Flowise server:</p><pre><code>docker-compose up -d</code></pre><p>With that, the app is accessible on the same URL: <strong>http://localhost:3000</strong></p><blockquote><p>Ok this is cool, but show me the app now! &#129327;</p></blockquote><p>When you open Flowise, you&#8217;ll first see a screen with the ChatFlows you&#8217;ve already created (a ChatFlow is a workflow you build with Flowise) </p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!qEcC!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 424w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 848w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!qEcC!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png" width="1456" height="470" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/84079399-a61d-4837-9449-b82418f7b286_2866x926.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:470,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:159965,&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="/__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 424w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 848w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.png 1272w, /__u/substackcdn.com/image/fetch/$s_!qEcC!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F84079399-a61d-4837-9449-b82418f7b286_2866x926.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 aria-hidden="true" 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><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>To create a ChatFlow that represents an LLM chain, click on Add New, then click on the plus sign on the left.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!dwui!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 424w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 848w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!dwui!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png" width="1456" height="669" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:669,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:233792,&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="/__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 424w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 848w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.png 1272w, /__u/substackcdn.com/image/fetch/$s_!dwui!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc760f981-5510-4c2f-b3f8-56c654ac6572_2880x1324.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 aria-hidden="true" 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><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 will open up a list of nodes that you can drag and drop to the interface and connect them with each other.</p><p>If you&#8217;re already familiar with LangChain, these nodes correspond to the same components you already use:</p><ul><li><p>Document Loaders</p></li><li><p>Embeddings</p></li><li><p>Prompts</p></li><li><p>Retrievers</p></li><li><p>&#8230;</p><p></p></li></ul><p>If you click on Document Loaders for example, you&#8217;ll find many options that you can pick depending on your data format (CSV, PDF, Markdown, etc.)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!CRp7!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 424w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 848w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!CRp7!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png" width="242" height="399.45512820512823" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1030,&quot;width&quot;:624,&quot;resizeWidth&quot;:242,&quot;bytes&quot;:83033,&quot;alt&quot;:&quot;&quot;,&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="" title="" srcset="/__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 424w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 848w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.png 1272w, /__u/substackcdn.com/image/fetch/$s_!CRp7!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F448c862a-e30f-47d4-b8fe-996cc460761e_624x1030.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 aria-hidden="true" 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><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>If you click on Embeddings, you&#8217;ll find different embedding providers as well. You can find for example AWS, GCP, Azure, OpenAI and HuggingFace</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!xwWR!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 424w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 848w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!xwWR!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png" width="294" height="469.2692307692308" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/e5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:996,&quot;width&quot;:624,&quot;resizeWidth&quot;:294,&quot;bytes&quot;:104480,&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="/__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 424w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 848w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.png 1272w, /__u/substackcdn.com/image/fetch/$s_!xwWR!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fe5fc1749-d9fd-4757-92d3-a5f0d2d246ff_624x996.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 aria-hidden="true" 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><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 for the vector stores, you also have a lot of options (Chroma, Weaviate, Pinecone &#8230;) </p><p>With Flowise, you can either feed your vector store directly in a chatflow or you can load an existing one that you created elsewhere. That&#8217;s up to you.</p><div><hr></div><h3>Demo: Create a chatbot over PDFs</h3><p>Here&#8217;s a common use case: your company asks you to build a chatbot over internal PDF documents (contracts? invoices? research papers?) to gather insights and test LLM capabilities. </p><p>Building this prototype in Flowise is easier than ever.</p><p>You first start by importing the PDF loader.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!g8Rv!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 424w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 848w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!g8Rv!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png" width="1456" height="807" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:807,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:187787,&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="/__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 424w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 848w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.png 1272w, /__u/substackcdn.com/image/fetch/$s_!g8Rv!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F7f755754-bf70-42c8-ab49-13e2cd6a9a64_2072x1148.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 aria-hidden="true" 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><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>Your PDF is quite long so you need to split it into chunks. Therefore, you need to import a Character Text Splitter. You can specify the separator (\n), the chunk size (500), and the chunk overlap (150). </p><p>This text splitter must be connected to the PDF file loader.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!wu3Q!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!wu3Q!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png" width="1320" height="800" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:800,&quot;width&quot;:1320,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:135880,&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="/__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 424w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 848w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.png 1272w, /__u/substackcdn.com/image/fetch/$s_!wu3Q!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F55205fc1-aae0-40b4-8e88-98f57f1fd6fb_1320x800.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 aria-hidden="true" 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><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 chunked documents must now be inserted in a vector store. Let&#8217;s import one.</p><p>In this demo, we&#8217;ll use Chroma.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ux9z!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ux9z!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png" width="1456" height="1031" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1031,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:263411,&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="/__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ux9z!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc0b114a2-d75a-4116-83c0-e7b466d403a7_1780x1260.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 aria-hidden="true" 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><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 you see, the Chroma database is missing the embedding model so let&#8217;s add that.</p><p>I&#8217;m going to pick one from OpenAI.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!sdqJ!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 424w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 848w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!sdqJ!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png" width="1456" height="1025" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/a922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:1025,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:305003,&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="/__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 424w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 848w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.png 1272w, /__u/substackcdn.com/image/fetch/$s_!sdqJ!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fa922a18d-1703-4e73-8df1-97e8e7cfae20_1796x1264.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 aria-hidden="true" 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><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>Since we need an API key to perform calls to OpenAI, we can add and save these credentials in Flowise. (They&#8217;re encrypted)</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!opKI!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 424w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 848w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 1272w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!opKI!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png" width="466" height="287.1513859275053" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/c163c36d-d53e-418e-8337-33b1be0d630a_938x578.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:578,&quot;width&quot;:938,&quot;resizeWidth&quot;:466,&quot;bytes&quot;:39555,&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="/__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 424w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 848w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.png 1272w, /__u/substackcdn.com/image/fetch/$s_!opKI!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Fc163c36d-d53e-418e-8337-33b1be0d630a_938x578.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 aria-hidden="true" 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><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 the last part: we need to create a Conversational Retrieval QA chain that takes as inputs a chat model and the Chroma database.</p><p>So let&#8217;s go ahead and add those.</p><p>Here&#8217;s the final flow. The first time I made it, it took me probably 3 minutes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!Ho0T!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!Ho0T!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png" width="1456" height="958" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/fa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:958,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:325779,&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="/__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 424w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 848w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.png 1272w, /__u/substackcdn.com/image/fetch/$s_!Ho0T!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ffa9efd8a-aed5-4d92-86f6-3581959a36e9_1934x1272.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 aria-hidden="true" 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><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>That&#8217;s pretty much it. </p><blockquote><p>In this demo, I&#8217;m going to chat with the first chapter of this <a href="https://www.amazon.com/gp/product/0134853989/ref=as_li_tl?ie=UTF8&amp;tag=onbifl-20&amp;camp=1789&amp;creative=9325&amp;linkCode=as2&amp;creativeASIN=0134853989&amp;linkId=4585530da0fc1da25cc24902ba6cd11d">book</a>: <strong>Effective Python: 90 Specific Ways to Write Better Python</strong></p></blockquote><p>To do this, you first need to upload the book directly to the PDF loader.</p><p>To chat with it, you simply need to click on the purple icon (on the right) to open an interactive chat.</p><p>Here&#8217;s an example question:</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!JxQm!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 424w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 848w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!JxQm!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png" width="1456" height="717" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:717,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:491023,&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="/__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 424w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 848w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.png 1272w, /__u/substackcdn.com/image/fetch/$s_!JxQm!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8bc0165f-5e64-4971-8064-f0c61e1ba8ac_2540x1250.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 aria-hidden="true" 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><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>How awesome is that?</p><p>Notice that Flowise can also display the items the LLM used when generating the answer. This helps diagnose the results. </p><h4><strong>and this doesn&#8217;t stop, here comes the best part:</strong></h4><p>Once your chatbot is built and tested, you can have access to an endpoint to interact with it programmatically and embed it in other applications. </p><p>It&#8217;s as simple as writing these lines of code.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!ypxF!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 424w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 848w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!ypxF!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png" width="1408" height="788" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:788,&quot;width&quot;:1408,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:122766,&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="/__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 424w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 848w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.png 1272w, /__u/substackcdn.com/image/fetch/$s_!ypxF!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F8c42a3c9-4578-409b-9fbd-e962c3f2a258_1408x788.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 aria-hidden="true" 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><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>Before I move to the last section of this post, I wanted to mention that this demo is  built locally. In a real setting though, you&#8217;d need to deploy Flowise on the cloud so that teammates can easily collaborate on the same ChatFlow.</p><p>Check this <a href="https://docs.flowiseai.com/deployment">doc</a> to learn more about the deployment options.</p><div><hr></div><h3>My honest opinion</h3><p>Flowise is a powerful tool that makes prototyping chains very easy. It provides a nice UI to assemble blocks together and quickly test them. </p><p>I also like the ability to embed the ChatFlow by using the provided endpoint. </p><p>As this solution is relatively new, there are some improvements that could be made.</p><ul><li><p>An improved stacktrace to diagnose bugs</p></li><li><p>Displaying a status to the user when a heavy workload (e.g. embedding) is being performed or when a large file is being ingested</p></li><li><p>A more detailed documentation</p></li></ul><p>Will I use this solution? </p><p>In the short term, absolutely.</p><p>However, my commitment in the long run is less certain. This hesitancy is rooted in the fact that Flowise is closely intertwined with LangChain's core components. Although LangChain is a great package, I occasionally find its architecture overly complex. At times, constructing chains or RAGs from the ground up seems more practical. Hence, I might consider exploring alternative frameworks in the future.</p><p>Perhaps, if the community someday reaches a consensus on a standardized approach for representing LLMs, solutions like Flowise could enjoy broader adoption.</p><div><hr></div><p>That&#8217;s all for today. I hope you discovered a tool that would make your life easier for building and prototyping.</p><p>Thanks for reading, </p><p>Until next time! &#128075; </p><p>Ahmed</p>]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #7: Better Manipulate Paths In Python With Pathlib]]></title><description><![CDATA[Forget about the os module]]></description><link>https://thetechbuffet.substack.com/p/better-manipulate-paths-with-pathlib</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/better-manipulate-paths-with-pathlib</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Fri, 13 Oct 2023 08:09:58 GMT</pubDate><enclosure url="https://substack-post-media.s3.amazonaws.com/public/images/3b52f07e-8a11-40c6-a124-1ad5531dfd42_1892x1212.webp" length="0" type="image/jpeg"/><content:encoded><![CDATA[<div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080" width="4344" height="2441" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:2441,&quot;width&quot;:4344,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;gray and white pathway between green plants on vast valley&quot;,&quot;title&quot;:null,&quot;type&quot;:&quot;image/jpg&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="gray and white pathway between green plants on vast valley" title="gray and white pathway between green plants on vast valley" srcset="https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 424w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 848w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 1272w, https://images.unsplash.com/photo-1439396874305-9a6ba25de6c6?crop=entropy&amp;cs=tinysrgb&amp;fit=max&amp;fm=jpg&amp;ixid=M3wzMDAzMzh8MHwxfHNlYXJjaHwxMnx8cGF0aHN8ZW58MHx8fHwxNjk3MTQ0NDQwfDA&amp;ixlib=rb-4.0.3&amp;q=80&amp;w=1080 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 aria-hidden="true" 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><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><blockquote><p><em><strong>Hello again! &#128075; </strong></em></p><p><em><strong>This issue is part of a Python series dedicated to sharing tips and best practices to improve your code.<br>If you&#8217;re interested in this type of content (+ the additional coding material) <br>consider subscribing.</strong></em></p></blockquote><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p><p>As a data scientist, I manipulate paths and files on a daily basis to read and write data.</p><p>To do this, I typically use the <code>os.path</code> Python module to perform operations such as joining paths, checking the content of a directory, or creating folders.</p><p>In this issue, I&#8217;m challenging this practice by introducing another path management library called <strong>Pathlib</strong>.</p><p><strong>We&#8217;ll see how this library works, how it differs from the os.path module, what features and benefits it provides, and when you should (or not) use it</strong><em><strong>.</strong></em></p><p>If you&#8217;re a Python developer, learning about Pathlib will make your code lighter, more flexible, and easier to write and maintain.</p><p>Let&#8217;s dig in.</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/better-manipulate-paths-with-pathlib">
              Read more
          </a>
      </p>
   ]]></content:encoded></item><item><title><![CDATA[The Tech Buffet #6: Why Your RAG is Not Reliable in Production]]></title><description><![CDATA[And how you should tune it properly &#128736;&#65039;]]></description><link>https://thetechbuffet.substack.com/p/the-probelms-behind-rag</link><guid isPermaLink="false">https://thetechbuffet.substack.com/p/the-probelms-behind-rag</guid><dc:creator><![CDATA[Ahmed Besbes]]></dc:creator><pubDate>Tue, 10 Oct 2023 06:26:50 GMT</pubDate><enclosure url="https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80" length="0" type="image/jpeg"/><content:encoded><![CDATA[<blockquote><p>Hello there &#128075;&#127995;, I&#8217;m Ahmed. I write The Tech Buffet to share weekly practical tips on productionizing ML systems. Join the family (+400 &#127881;) and subscribe!</p><p class="button-wrapper" data-attrs="{&quot;url&quot;:&quot;https://thetechbuffet.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="/__u/thetechbuffet.substack.com/subscribe"><span>Subscribe now</span></a></p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 424w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 848w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 1272w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 1456w" sizes="100vw"><img src="https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80" width="1000" height="668" data-attrs="{&quot;src&quot;:&quot;https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:668,&quot;width&quot;:1000,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;perles noires et argent&#233;es sur une surface blanche&quot;,&quot;title&quot;:null,&quot;type&quot;:null,&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="perles noires et argent&#233;es sur une surface blanche" title="perles noires et argent&#233;es sur une surface blanche" srcset="https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 424w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 848w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 1272w, https://images.unsplash.com/photo-1620456044459-539403d1e157?ixlib=rb-4.0.3&amp;ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&amp;auto=format&amp;fit=crop&amp;w=1000&amp;q=80 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 aria-hidden="true" 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><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>With the rise of LLMs, the Retrieval Augmented Generation (RAG) framework also gained popularity by making it possible to build question-answering systems over data.</p><p>We&#8217;ve all seen those demos of chatbots conversing with PDFs or emails.</p><p>While these systems are certainly impressive, they might not be reliable in production without tweaking and experimentation.</p><p>In this issue, we explore the problems behind the RAG framework and go over some tips to improve its performance.</p><blockquote><p>These findings are based on my experience as an ML engineer who&#8217;s still learning about this tech.</p></blockquote><div><hr></div><h3>RAG in a nutshell &#9881;&#65039;</h3><p>Let's get the basics right first.</p><p>Here&#8217;s how RAG works:</p><p>It first takes an input question and retrieves relevant documents to it from an external database. Then, it passes those chunks as a context in a prompt to help an LLM generate an <em>augmented </em>answer.</p><p>That&#8217;s basically saying: </p><blockquote><p>&#8220;Hey LLM, here&#8217;s my question, and here are some pieces of text to help you understand the problem. Give me an answer.&#8221;</p></blockquote><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!BC-h!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 424w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 848w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!BC-h!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png" width="604" height="409.8798735511064" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:644,&quot;width&quot;:949,&quot;resizeWidth&quot;:604,&quot;bytes&quot;:58302,&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="/__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 424w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 848w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.png 1272w, /__u/substackcdn.com/image/fetch/$s_!BC-h!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F01a66d3a-7ebc-488f-9984-c71206571f58_949x644.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 aria-hidden="true" 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><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 should not be fooled by the simplicity of this diagram. <br><br>In fact, RAG hides a certain complexity and involves the following components behind the scenes:</p><ul><li><p>Loaders to parse external data in different formats: PDFs, websites, Doc files, etc.</p></li><li><p>Splitters to chunk the raw data into smaller pieces of text</p></li><li><p>An embedding model to convert the chunks into vectors</p></li><li><p>A vector database to store the vectors and query them</p></li><li><p>A prompt to combine the question and the retrieved documents</p></li><li><p>An LLM to generate the answer</p></li></ul><p>If you like diagrams, here&#8217;s another for you. </p><p>A tad more complex but it illustrates the indexing and retrieval processes.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!LLQg!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 424w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 848w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!LLQg!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png" width="666" height="578.6455813953488" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:934,&quot;width&quot;:1075,&quot;resizeWidth&quot;:666,&quot;bytes&quot;:null,&quot;alt&quot;:&quot;RAG: Complete&quot;,&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="RAG: Complete" title="RAG: Complete" srcset="/__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 424w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 848w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.png 1272w, /__u/substackcdn.com/image/fetch/$s_!LLQg!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff985c725-64d6-4791-93b5-8f4f52c24347_1075x934.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 aria-hidden="true" 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><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>Phew!</p><p>Don&#8217;t worry though, you can still prototype your RAG very quickly.</p><p>Frameworks like <a href="https://www.langchain.com/">LangChain</a> abstracted most of the steps involved in building a RAG and it became easy to prototype those systems.</p><p>How easy is that? 5-line-of-code easy.</p><div class="captioned-image-container"><figure><a class="image-link image2 is-viewable-img" target="_blank" href="/__u/substackcdn.com/image/fetch/$s_!R_Fk!,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png" data-component-name="Image2ToDOM"><div class="image2-inset"><picture><source type="image/webp" srcset="/__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 424w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 848w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_webp, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 1456w" sizes="100vw"><img src="/__u/substackcdn.com/image/fetch/$s_!R_Fk!,w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png" width="1456" height="384" data-attrs="{&quot;src&quot;:&quot;https://substack-post-media.s3.amazonaws.com/public/images/f7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png&quot;,&quot;srcNoWatermark&quot;:null,&quot;fullscreen&quot;:null,&quot;imageSize&quot;:null,&quot;height&quot;:384,&quot;width&quot;:1456,&quot;resizeWidth&quot;:null,&quot;bytes&quot;:88812,&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="/__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_424, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 424w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_848, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 848w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_1272, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.png 1272w, /__u/substackcdn.com/image/fetch/$s_!R_Fk!, /__u/thetechbuffet.substack.com/w_1456, /__u/thetechbuffet.substack.com/c_limit, /__u/thetechbuffet.substack.com/f_auto, /__u/thetechbuffet.substack.com/q_auto:good, /__u/thetechbuffet.substack.com/fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff7451d2e-86e3-4fae-ae6d-e979e51204ea_1700x448.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 aria-hidden="true" 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><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>Of course, there&#8217;s always a problem with the apparent simplicity of such code snippets: depending on your use case, they don&#8217;t always work as-is and need very careful tuning.</p><p>They&#8217;re great as quickstarts but they&#8217;re certainly not a reliable solution for an industrialized application.</p><div><hr></div><h3>The problems with RAG</h3><p>If you start building RAG systems with little to no tuning, you may be surprised. </p><p>Here&#8217;s what I noticed during the first weeks of using LangChain and building RAGs.</p>
      <p>
          <a href="/__u/thetechbuffet.substack.com/p/the-probelms-behind-rag">
              Read more
          </a>
      </p>
   ]]></content:encoded></item></channel></rss>