<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>wow its jareds blog</title><link>https://kofron.io/</link><description>Recent content on wow its jareds blog</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Wed, 12 Feb 2025 08:44:34 -0800</lastBuildDate><atom:link href="https://kofron.io/index.xml" rel="self" type="application/rss+xml"/><item><title>The Readback Prompt</title><link>https://kofron.io/posts/llm-readback-prompting/</link><pubDate>Wed, 12 Feb 2025 08:44:34 -0800</pubDate><guid>https://kofron.io/posts/llm-readback-prompting/</guid><description>Setting the table If you hang out with me for long enough, you&amp;rsquo;ll hear me drop my favorite quote, which is often attributed to George Bernard Shaw (although the actual provenance is deeply unclear):
&amp;ldquo;The single biggest problem in communication is the illusion that it has taken place.&amp;rdquo;
The effects of this rather brilliant observation are everywhere, and occur across pretty much every stratum of relationships that we as people have.</description><content:encoded><![CDATA[<h2 id="setting-the-table">Setting the table</h2>
<p>If you hang out with me for long enough, you&rsquo;ll hear me drop my favorite quote, which is often attributed to George Bernard Shaw (<a href="https://quoteinvestigator.com/2014/08/31/illusion/">although the actual provenance is deeply unclear</a>):</p>
<blockquote>
<p>&ldquo;The single biggest problem in communication is the illusion that it has taken place.&rdquo;</p>
</blockquote>
<p>The effects of this rather brilliant observation are <em>everywhere</em>, and occur across pretty much every stratum of relationships that we as people have.  Miscommunication leads to hurt feelings, missed opportunities, and a true cornucopia of &ldquo;I thought you said X&rdquo;-type interactions.</p>
<p>Part of my own communication practice is to try to avoid this as much as possible.  I can&rsquo;t just wave a magic wand and eliminate the potential for miscommunication, but I&rsquo;ve found that there is a reasonably simple thing that I can do that seems to help an awful lot.  At the end
of any high stakes interaction, or in a conversation where I&rsquo;m starting to get &ldquo;that feeling&rdquo;, I like to wrap things up by reading the conversation back.  Typically I&rsquo;ll say something like &ldquo;Ok I think I got it, let me say that back to you so that I&rsquo;m sure.&rdquo;  Then I quickly recap what we just talked about
and make sure everybody agrees that we&rsquo;re on the same page.</p>
<p>In cases where it was unnecessary, the only potential cost I pay is looking a little silly for performing this ritual - but in general I find that people feel reassured that they&rsquo;ve been heard correctly.  In cases where it <em>was</em> necessary, it has been an invaluable tool for getting
the important stuff back on the table for discussion and coming to the agreement we were trying to reach all along.</p>
<p>But what does this have to do with AI?  There&rsquo;s an old programming joke that goes something like &ldquo;I had a string parsing problem, so I decided to use regular expresions.  Now I have two problems.&rdquo;  When I first started to use AI to help write code, I thought of that regex joke just about
every day.  I spent so much time <em>just cleaning up after the damn AI</em> that it didn&rsquo;t add up to an overall boost in productivity - just the opposite.  These days, I think that AI is a truly 10x speed boost for me - but it took developing some really good tricks over time to get there.
Far and away the most successful of those tricks is the &ldquo;readback prompt&rdquo; - and so now, having buried the lede as deep as possible, let me tell you what it is.</p>
<h2 id="the-readback-prompt">The Readback Prompt</h2>
<p>If you haven&rsquo;t already seen where I&rsquo;m going with all this, the highest level readback prompt is pretty simple: When you ask AI to do something for you, tell it to take a beat and repeat back to you what it thinks it&rsquo;s being asked to do first.  This works in more or less every setting I&rsquo;ve tried it in,
and dramatically improves the actual results - even though I very rarely find myself correcting its thoughts on what it should do.</p>
<p>For coding tasks, I typically add something like &ldquo;Before you write any code, tell me what you think I&rsquo;m getting at.&rdquo;  I have more thoughts below, but honestly, that&rsquo;s about it.  Myself and my colleagues at PSL have found this to be an incredibly powerful approach to getting better results out of LLMs, and
I think you will too.</p>
<h3 id="but-is-it-just-cot">But is it just CoT?</h3>
<p>No, I don&rsquo;t think so.</p>
<p>If you&rsquo;re familiar with the LLM space, you may have heard of Chain-of-Thought prompting.  <a href="https://arxiv.org/abs/2201.11903">When people first starting doing this</a>, it was
quite surprising - if you just added &ldquo;think step by step&rdquo; to the end of your prompt, you could get huge boosts in performance, especially
on tasks that require logical thinking.</p>
<p>This <em>feels</em> a little bit like it at least rhymes with the readback prompt, because we&rsquo;re asking the LLM to do some work &ldquo;up front&rdquo; to
get its story straight before answering.  However, in my (limited) experiment, I believe that not only does readback produce fundamentally
different reasoning patterns, but it also outperforms chain-of-thought - at least at solving riddles.</p>
<p>Here&rsquo;s my setup:</p>
<ol>
<li>Claude Sonnet 3.5-latest</li>
<li>Temperature=1</li>
</ol>
<p>The prompt is as follows:</p>
<blockquote>
<p>Answer the following riddle:</p>
<p>A farmer wants to cross a river and take with him a wolf, a goat and a cabbage.
He has a boat with three secure separate compartments. If the wolf and the goat are alone on one shore, the wolf will eat the goat.
If the goat and the cabbage are alone on the shore, the goat will eat the cabbage.
How can the farmer efficiently bring the wolf, the goat and the cabbage across the river without anything being eaten?</p>
</blockquote>
<p>Before we go any further, the correct answer is: there are three objects, and three secure compartments - just put all of them in separate compartments and go across.
By the way, that riddle was lifted from <a href="https://arxiv.org/html/2405.19616v1">this paper</a>.</p>
<p>For the Chain-of-thought modification, I add &ldquo;Think step by step&rdquo; as the final line.  For the readback prompt, we add &ldquo;But before you do,
please explain the task that I&rsquo;ve asked you to perform to confirm your understanding.&rdquo;  Additionally, for the readback prompt, we
respond to <em>whatever the LLM says at first</em> with &ldquo;Proceed&rdquo;.  See the code <a href="https://github.com/kofron/experiments">here</a> if you happen to be so inclined.</p>
<p>If you&rsquo;re playing spot-the-difference, there&rsquo;s a second round trip that happens with the readback prompt.  One might argue that this
is somehow cheating, or giving the LLM more bites at the apple.  Given how LLMs work, I don&rsquo;t agree with this argument, but for the sake
of science, I&rsquo;ve included a variation that asks the LLM to first readback, then respond within the same message.</p>
<p>🥁 And here are the results:</p>
<table>
<thead>
<tr>
<th>Method</th>
<th>N correct (out of 50)</th>
<th>Percent correct</th>
</tr>
</thead>
<tbody>
<tr>
<td>Raw</td>
<td>5</td>
<td>10%</td>
</tr>
<tr>
<td>Chain-of-thought</td>
<td>2</td>
<td>4%</td>
</tr>
<tr>
<td>Readback</td>
<td>13</td>
<td>26%</td>
</tr>
<tr>
<td>Readback-no-round-trip</td>
<td>12</td>
<td>24%</td>
</tr>
</tbody>
</table>
<p>Ok, so a few things.</p>
<ul>
<li>Readback is a huge improvement over the raw baseline of 10%</li>
<li>Chain-of-thought is <em>worse</em>, and substantially so, than the baseline.</li>
</ul>
<p>But why?  Isn&rsquo;t chain of thought, like, good?  Yeah, it for sure is, and that&rsquo;s been shown over and over again.</p>
<p>So why doesn&rsquo;t it work here?  It&rsquo;s hard to know exactly, but I have a theory.  LLM outputs are causal - the next token only depends on all of the tokens that came before it.
So when reasoning is happening in a chain-of-thought style prompt, <em>early mistakes can be fatal</em> because they lead the LLM down a blind alley of
thinking.</p>
<p>Readback doesn&rsquo;t suffer from this as much, because it&rsquo;s inviting the LLM to think in a style more akin to &ldquo;end, beginning, end&rdquo; - it tends to
lay out a plan, and sometimes even include some thoughts on what potential pitfalls might be, before it starts to actually answer in earnest.</p>
<p>This is a little tenuous - it&rsquo;s unclear why on this <em>particular</em> riddle chain-of-thought would do so poorly, but I suspect it has something to do
with the somewhat nonlinear thinking that this riddle tends to induce.</p>
<h2 id="cool">Cool</h2>
<p>Yeah, pretty sweet.</p>
]]></content:encoded></item><item><title>About</title><link>https://kofron.io/about/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kofron.io/about/</guid><description>This is the personal site of Jared Kofron. I&amp;rsquo;m a Principal AI Engineer at Pioneer Square Labs here in Seattle, WA. I hold a Ph.D. in Physics from the University of Washington, where I studied with Hamish Robertson. I&amp;rsquo;ve worked on various startups in the PNW and the Bay Area since I graduated in 2015. For the past 3 years or so I have been developing user-facing AI applications full-time.</description><content:encoded><![CDATA[<p>This is the personal site of Jared Kofron.  I&rsquo;m a Principal AI Engineer at <a href="https://psl.com">Pioneer Square Labs</a> here in Seattle, WA.
I hold a Ph.D. in Physics from the University of Washington, where I studied with Hamish Robertson.  I&rsquo;ve worked on various startups
in the PNW and the Bay Area since I graduated in 2015.  For the past 3 years or so I have been developing user-facing AI applications
full-time.</p>
]]></content:encoded></item></channel></rss>