<?xml version="1.0" encoding="UTF-8"?>
<rss  xmlns:atom="http://www.w3.org/2005/Atom" 
      xmlns:media="http://search.yahoo.com/mrss/" 
      xmlns:content="http://purl.org/rss/1.0/modules/content/" 
      xmlns:dc="http://purl.org/dc/elements/1.1/" 
      version="2.0">
<channel>
<title>Joe Halliwell</title>
<link>https://joehalliwell.com/</link>
<atom:link href="https://joehalliwell.com/index.xml" rel="self" type="application/rss+xml"/>
<description>Essays and notes by Joe Halliwell on AI architecture and safety, machine
learning, programming, and whatever else seems interesting at the time.
</description>
<image>
<url>https://joehalliwell.com/profile.jpg</url>
<title>Joe Halliwell</title>
<link>https://joehalliwell.com/</link>
</image>
<generator>quarto-1.10.19</generator>
<lastBuildDate>Sat, 24 Oct 2026 23:00:00 GMT</lastBuildDate>
<item>
  <title>Here’s the intelligence explosion</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/recursive-self-improvement-blowup.html</link>
  <description><![CDATA[ 





<p>Frontier labs are spending an absolute fortune<sup>1</sup> applying AI to build better AI. Anthropic claims that Claude now <a href="https://www.anthropic.com/institute/measuring-pace-of-ai-development">“leads” 26% of its AI R&amp;D work</a>. Many believe that we’re on a clear and accelerating path towards superintelligence in our lifetimes.</p>
<div class="no-row-height column-margin column-container"><div id="fn1"><p><sup>1</sup>&nbsp;A guess: maybe $1B a year at Anthropic, out of a <a href="https://thenextweb.com/news/anthropic-s-1-750bn-compute-80-7bn-loss">compute bill of nearly $9B</a> for the first half of 2026. Claude Code’s creator alone <a href="https://app.dealroom.co/news/note/boris-cherny-on-coding-from-his-phone-and-the-post-coding-bottleneck">used over 8 billion tokens in three months</a>, and automated experiments probably dwarf that.</p></div></div><p>Not so fast, says the futurologist Ramez Naam. In <a href="https://www.noahpinion.blog/p/wheres-the-intelligence-explosion">Where’s the “intelligence explosion”?</a>, he explores five overlapping ways AI can improve AI, and argues that a runaway takeoff can’t happen while all of them face “diminishing returns”.</p>
<div id="fig-naam" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-naam-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/assets/images/rsi-chart.jpg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-naam-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Key infographic from the Naam post, acknowledging that AI speeds up AI development while insisting this falls short of “fast takeoff”.
</figcaption>
</figure>
</div>
<section id="the-maths-bit" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="the-maths-bit">The Maths Bit</h2>
<p>The intuition behind a takeoff is simple: we keep building better tools, so the speed of <strong>progress</strong> (scientific or economic<sup>2</sup>) depends on how much progress we’ve already made.</p>
<div class="no-row-height column-margin column-container"><div id="fn2"><p><sup>2</sup>&nbsp;We don’t talk about social progress. It has a yeasty tang of socialism and is remarkably difficult to price into a Series B.</p></div><div id="fn3"><p><sup>3</sup>&nbsp;The model, and the mapping of Naam’s numbers onto it, are ours, not Naam’s or his sources’. The mapping also assumes outside investment keeps flowing: in standard growth models, a sub-threshold loop’s percentage growth rate slows to a crawl without it.</p></div></div><p>Wisely, perhaps, Naam avoids equations. But we can explore the scenarios using a toy model<sup>3</sup> that assumes the speed with which progress, ahem, progresses (written <img src="https://latex.codecogs.com/png.latex?%5Cfrac%7BdP%7D%7Bdt%7D">) is proportional to the <img src="https://latex.codecogs.com/png.latex?k">-th power of the current level of progress (<img src="https://latex.codecogs.com/png.latex?P%5Ek">).</p>
<p><img src="https://latex.codecogs.com/png.latex?%0A%5Cfrac%7BdP%7D%7Bdt%7D%20%5Cpropto%20P%5Ek%0A"></p>
<p>As we’ll see, solving this differential equation gives very different futures depending on the exponent <img src="https://latex.codecogs.com/png.latex?k">.</p>
<p>Naam’s evidence bears on it:</p>
<ul>
<li>At OpenAI, researchers used 124× more tokens per person and shipped about 7× as many lines of code, but ran only 1.6× as many experiments.</li>
<li>At Anthropic, staff report a productivity uplift of around 4×. Naam reckons doubling the pace of progress would need about 40×.</li>
<li>Elsewhere, from chess engines to experiments across the sciences, more effort buys steeply diminishing returns.</li>
</ul>
<p>Overall, Naam concludes:</p>
<div class="page-columns page-full"><blockquote class="blockquote">
<p>Given our best current data, the AI self-improvement loop would need to be roughly 5–10× stronger to sustain itself, let alone run away.<sup>4</sup></p>
</blockquote><div class="no-row-height column-margin column-container"><div id="fn4"><p><sup>4</sup>&nbsp;Concretely, he estimates that each extra point of AI capability (on Epoch’s ECI benchmark) buys 2–3% more research productivity, against a self-sustaining threshold of 15–19% from a <a href="https://arxiv.org/abs/2609.15802">model by Tom Cunningham and colleagues</a>.</p></div></div></div>
<p>In the toy model, a loop that just sustains itself has <img src="https://latex.codecogs.com/png.latex?k=1">. Being 5–10× too weak puts <img src="https://latex.codecogs.com/png.latex?k"> somewhere around 0.15, at worst. These are the “diminishing returns”.</p>
<p>Nothing to worry about, see?</p>
<p>Well, no.</p>
</section>
<section id="straw-man-singularity-k1" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="straw-man-singularity-k1">Straw Man Singularity (<img src="https://latex.codecogs.com/png.latex?k%3E1">)</h2>
<p>Let’s start with what the piece is billed<sup>5</sup> as refuting: “the ‘FOOM’ of Vernor Vinge novels”, a runaway loop with <img src="https://latex.codecogs.com/png.latex?k%3E1">. Say <img src="https://latex.codecogs.com/png.latex?k=2">, so that doubling progress quadruples its speed, and we start at a progress level of 0.1. Then progress at time <img src="https://latex.codecogs.com/png.latex?t"> is:</p>
<div class="no-row-height column-margin column-container"><div id="fn5"><p><sup>5</sup>&nbsp;The piece is a guest post. The FOOM framing comes from the host, Noah Smith, in his introduction.</p></div></div><p><img src="https://latex.codecogs.com/png.latex?%0AP(t)%20=%20%5Cfrac%7B1%7D%7B10%20-%20t%7D%0A"></p>
<p>Watch what happens. Progress takes five units of time to double from 0.1 to 0.2, and another four to reach 1. Then it hits 10 at <img src="https://latex.codecogs.com/png.latex?t=9.9">, and 100 at <img src="https://latex.codecogs.com/png.latex?t=9.99">. At <img src="https://latex.codecogs.com/png.latex?t=10"> the denominator is zero, and progress is infinite. Every <img src="https://latex.codecogs.com/png.latex?k%3E1"> shares this finite-time blow-up; only the date changes.</p>
<p>Curves like this can fit the past remarkably well. In 1960 Heinz von Foerster and colleagues <a href="https://doi.org/10.1126/science.132.3436.1291">fitted one</a> to two thousand years of world population. Their <a href="https://en.wikipedia.org/wiki/Heinz_von_Foerster#Doomsday_equation">“Doomsday Equation”</a> predicted 5.99 billion people by 1997; the actual figure was 5.92 billion. It also predicts infinite humans by Friday, 13 November 2026. At the time of writing, this looks ambitious.</p>
<p>Nothing real goes infinite, of course. So a blow-up just marks the point where the model stops working. If FOOM means <img src="https://latex.codecogs.com/png.latex?k%3E1">, Naam’s data rule it out. Fair enough: it’s the easy target. The interesting case is the next one.</p>
</section>
<section id="self-sustaining-singularity-kapprox1" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="self-sustaining-singularity-kapprox1">Self-Sustaining Singularity (<img src="https://latex.codecogs.com/png.latex?k%5Capprox1">)</h2>
<p>Serious singularitarians bet on <img src="https://latex.codecogs.com/png.latex?k%5Capprox1">.</p>
<p>At <img src="https://latex.codecogs.com/png.latex?k=1"> progress is “exponential”: progress, the rate of progress, the rate of the rate of progress and so on all keep growing. None ever hits infinity, but wait long enough and they grow arbitrarily large.</p>
<p>Ray Kurzweil, the most influential singularitarian<sup>6</sup>, has spent his career here, or a hair above<sup>7</sup>. In <a href="https://www.writingsbyraykurzweil.com/the-law-of-accelerating-returns">The Law of Accelerating Returns</a> he spells out what that means for the century we’re in:</p>
<div class="no-row-height column-margin column-container"><div id="fn6"><p><sup>6</sup>&nbsp;He didn’t coin the term “singularity”. That was John von Neumann, as <a href="https://www.ams.org/journals/bull/1958-64-03/S0002-9904-1958-10189-5/S0002-9904-1958-10189-5.pdf">recalled by Stanislaw Ulam</a> in 1958. Vernor Vinge made it famous in 1993; Kurzweil made it a career.</p></div><div id="fn7"><p><sup>7</sup>&nbsp;Strictly, he argues for a “double” exponential, “meaning that the rate of exponential growth is itself growing exponentially”. If <img src="https://latex.codecogs.com/png.latex?P%20=%20e%5E%7Be%5Et%7D"> then <img src="https://latex.codecogs.com/png.latex?%5Cfrac%7BdP%7D%7Bdt%7D%20=%20P%20%5Cln%20P">: faster than <img src="https://latex.codecogs.com/png.latex?P%5E1">, slower than <img src="https://latex.codecogs.com/png.latex?P%5Ek"> for any <img src="https://latex.codecogs.com/png.latex?k%3E1">, so it still never reaches infinity in finite time.</p></div></div><blockquote class="blockquote">
<p>it isn’t the case that we’ll experience 100 years of progress in the 21st century. Rather we’ll witness on the order of twenty thousand years of progress — at today’s rate of progress, that is.</p>
</blockquote>
<p>Naam’s threshold tests exactly this: whether the loop can sustain itself (<img src="https://latex.codecogs.com/png.latex?k%20%5Cgeq%201">), “let alone run away”. The catch is which loop he measures: AI writing better AI software. Hardware, energy and capital sit outside it, as forces that “can keep driving rapid progress even if the loop can’t sustain itself”.</p>
<p>But they aren’t outside. Google has used AI to <a href="https://deepmind.google/discover/blog/alphaevolve-a-gemini-powered-coding-agent-for-designing-advanced-algorithms/">optimise its custom silicon</a>, <a href="https://green.googleblog.com/2016/07/deepmind-ai-reduces-energy-used-for.html">cut the energy used to cool its data centres</a> and <a href="https://doi.org/10.1038/s41586-021-04301-9">steer the plasma in a tokamak fusion reactor</a>. And AI investment now depends on AI revenue, so capital is in the loop too. Leaving them out is no small omission: it’s Kurzweil’s whole point that accelerating returns are civilisational, encompassing everything.</p>
<p>Naam gives the narrow loop a number, and declares the wide one exogenous, which is how economists say “somebody else’s problem”. He quietly concedes that his analysis leaves a lot out, but his overall verdict doesn’t.</p>
</section>
<section id="subjective-singularity-k1" class="level2">
<h2 class="anchored" data-anchor-id="subjective-singularity-k1">Subjective Singularity (<img src="https://latex.codecogs.com/png.latex?k%3C1">)</h2>
<p>Fine, let’s grant Naam his verdict: hardware, energy and capital don’t count, and <img src="https://latex.codecogs.com/png.latex?k"> is a measly 0.15. Here’s the thing: that is still completely bonkers.</p>
<p>“Diminishing returns” in <img src="https://latex.codecogs.com/png.latex?P%5Ek"> doesn’t mean progress plateaus. At <img src="https://latex.codecogs.com/png.latex?k%20=%200.15">, <img src="https://latex.codecogs.com/png.latex?P(t)"> grows as <img src="https://latex.codecogs.com/png.latex?t%5E%7B1.18%7D">. Both progress and the <em>speed</em> of progress (<img src="https://latex.codecogs.com/png.latex?%5Cfrac%7BdP%7D%7Bdt%7D%20%5Csim%20t%5E%7B0.18%7D">) still climb forever.</p>
<p>And progress doesn’t need a vertical asymptote to break our brains; it just needs to outrun primate wetware that spent a few million years figuring out how to use twigs to eat ants. AI is already <a href="../posts/openai-maths.html">felling prize problems in batches</a>. Whether it proves a major theorem every morning before coffee or every 30 seconds is academic; either way, it’s bewildering.</p>
<p>Alvin Toffler had a name for this back in 1970. <a href="https://en.wikipedia.org/wiki/Future_Shock">“Future shock”</a> is “the shattering stress and disorientation that we induce in individuals by subjecting them to too much change in too short a time.”</p>
<p>So maybe <img src="https://latex.codecogs.com/png.latex?k"> is only 0.15, but lately that’s felt like more than enough.</p>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p><a href="https://claude.ai">Claude Opus 5.5</a> led 26% of this post.</p>


</section>


 ]]></description>
  <category>ai</category>
  <category>mathematics</category>
  <category>singularity</category>
  <guid>https://joehalliwell.com/posts/recursive-self-improvement-blowup.html</guid>
  <pubDate>Sat, 24 Oct 2026 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/assets/images/rsi-chart.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Does any of the OpenAI maths have real-world consequences?</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/openai-maths.html</link>
  <description><![CDATA[ 





<p>OpenAI just dropped <a href="https://github.com/openai/math">722 maths papers</a> in a single day<sup>1</sup>. The <a href="https://openai.com/index/sharing-ai-progress-in-mathematics/">press release</a> was studiedly low-key, barely touching on the impact of the results.</p>
<div class="no-row-height column-margin column-container"><div id="fn1"><p><sup>1</sup>&nbsp;Formal proofs for 42% of the headline results were verified using a proof-checking tool called Lean. A day later, OpenAI <a href="https://github.com/openai/math/blob/main/history.md">withdrew three of the papers</a>: a sign error in one Hodge-theory paper, one without a Lean-verified proof, unravelled it and the two papers built on it. The situation is evolving.</p></div></div><section id="the-most-significant-moment-in-mathematical-history" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="the-most-significant-moment-in-mathematical-history">“The Most Significant Moment in Mathematical History”</h2>
<p>It’s hard to convey how significant the release is for an already shell-shocked maths community<sup>2</sup>. Dozens of the results would be career-defining. The most spectacular is the quasi-Riemann hypothesis, a big step towards the Riemann hypothesis, a $1 million Millennium Prize problem and arguably the most famous open question in maths.</p>
<div class="no-row-height column-margin column-container"><div id="fn2"><p><sup>2</sup>&nbsp;The heading quotes <a href="https://x.com/__alpoge__/status/2107616859595981117">Levent Alpöge</a>, an Anthropic mathematician who was at the centre of <a href="https://fortune.com/2026/09/08/openai-says-it-cracked-navier-stokes-math-grand-challenge-buckmaster-accusation-cheating-intimidation-tao-lament/">last month’s Navier–Stokes dispute</a> with OpenAI. So hardly a cheerleader, which makes the praise all the more telling.</p></div><div id="fn3"><p><sup>3</sup>&nbsp;Erdős was a famously brilliant, varied and peripatetic mathematician. He was not a wealthy man. His $5,000 is worth more than $1 million.</p></div><div id="fn4"><p><sup>4</sup>&nbsp;No Lean proof, and it shared a result family with the three withdrawn papers. It survived, so far.</p></div></div><p>Other, only marginally less famous, prize problems have fallen or been given a damn good shake: a $5,000 Erdős conjecture<sup>3</sup> on arithmetic progressions, uniform bounds in Hilbert’s sixteenth problem and, from a second Millennium problem, the Hodge conjecture for CM abelian varieties<sup>4</sup>.</p>
<p>As Scott Aaronson <a href="https://scottaaronson.blog/?p=10169">put it</a>, “no human has understood just about any of these proofs yet; the race to do so has just started.” At human pace it could take decades.</p>
<p>But is any of it going to make a difference to our daily lives? When are we getting our flying cars, damn it? I worked with Claude to figure out which results have the greatest potential real-world impact.</p>
</section>
<section id="it-works-in-practice-now-it-works-in-theory" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="it-works-in-practice-now-it-works-in-theory">It Works in Practice; Now It Works in Theory</h2>
<p>Two results offer comfort, or at least a little bit of closure, about mathematical tools scientists have relied on for decades.</p>
<section id="big-brother-cant-help-being-dumb" class="level3 page-columns page-full">
<h3 class="anchored" data-anchor-id="big-brother-cant-help-being-dumb">1. Big Brother Can’t Help Being Dumb</h3>
<p>Say you’re a surveillance state that wants every street watched from at least one end. Here’s the dumbest method imaginable: find a street nobody’s watching, bolt cameras to <em>both</em> ends, repeat. That’s obviously going to be excessive for most towns, but in the worst possible case, it will only install twice as many cameras as you actually need. Incredibly, fifty years of despotic cunning have failed to improve on it, and now we know why: nothing can<sup>5</sup>.</p>
<div class="no-row-height column-margin column-container"><div id="fn5"><p><sup>5</sup>&nbsp;Unless P = NP, that is: unless every problem whose answers are easy to check is also easy to solve. That’s the most famous open question in computer science, and another $1 million Millennium Prize problem, but almost no-one doubts the answer is no. The paper here proves the “Unique Games Conjecture”, which is another of the field’s biggest open questions and one where there was no clear consensus. The Big Brother thing is just one of many consequences. The proof is a very big deal.</p></div></div><p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/The-Unique-Games-Theorem-September-23-2026/paper.pdf">The Unique Games Theorem</a> <em>(Lean-verified)</em></p>
</section>
<section id="random-networks-really-are-random-eventually" class="level3 page-columns page-full">
<h3 class="anchored" data-anchor-id="random-networks-really-are-random-eventually">2. Random Networks Really Are Random (Eventually)</h3>
<p>Is your protein network’s clustering meaningful, or just what any network with the same hub sizes would show? To find out, scientists compare against random networks in which every node keeps exactly the same number of connections, made by repeatedly swapping edge pairs: A–B and C–D become A–D and C–B. Biologists, ecologists and social-network analysts have leaned on this “null model” for decades, but with proofs that it properly randomises only for special cases. Now there’s one for every network. Phew<sup>6</sup>.</p>
<div class="no-row-height column-margin column-container"><div id="fn6"><p><sup>6</sup>&nbsp;Except that the proof only guarantees randomness after <img src="https://latex.codecogs.com/png.latex?2n%5E8"> swap attempts for a network of <img src="https://latex.codecogs.com/png.latex?n"> nodes, which is way more than anyone runs in practice.</p></div></div><p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/Polynomial-Mixing-of-the-Switch-Chain-for-Every-Graphical-Degree-Sequence-September-25-2026/main.pdf">Polynomial mixing of the switch chain for every graphical degree sequence</a> <em>(Lean-verified)</em></p>
</section>
</section>
<section id="castles-in-the-air" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="castles-in-the-air">Castles in the Air</h2>
<p>A few results break long-standing bounds on practical problems, but that doesn’t necessarily translate into real-world benefit.</p>
<p>Computer scientists think that an algorithm is pretty efficient if it runs in “polytime”, that is, if its running time grows like some polynomial function of the size of the input. But that can mask <strong>horrors</strong>. One Lean-verified paper here <a href="https://github.com/openai/math/blob/main/preprints/A-polynomial-time-algorithm-for-three-machine-unit-job-scheduling-September-24-2026/paper.pdf">settles a 1970s scheduling problem</a> in polytime. Its authors note that “no practical running-time claim is made” for the algorithm.</p>
<p>Given that our entire universe isn’t big or old enough to solve the smallest possible problem using it<sup>7</sup>, this is something of an understatement.</p>
<div class="no-row-height column-margin column-container"><div id="fn7"><p><sup>7</sup>&nbsp;The new algorithm is <img src="https://latex.codecogs.com/png.latex?O((L+2)%5E%7B150020%7D)"> where <img src="https://latex.codecogs.com/png.latex?L"> is the size of the input. So, yes, a polynomial, just one of degree 150,020. Even for a one-bit input, that bound allows about <img src="https://latex.codecogs.com/png.latex?10%5E%7B71578%7D"> steps. If each of the roughly <img src="https://latex.codecogs.com/png.latex?10%5E%7B80%7D"> atoms in the observable universe had been doing a trillion steps a second since the Big Bang, they would have completed a fraction of the task with more than 71,000 zeros after the decimal point.</p></div></div><p>The five below are less cyclopean, but none comes with a benchmark in seconds.</p>
<section id="encrypting-card-numbers-so-they-still-look-like-card-numbers" class="level3">
<h3 class="anchored" data-anchor-id="encrypting-card-numbers-so-they-still-look-like-card-numbers">3. Encrypting Card Numbers so They Still Look Like Card Numbers</h3>
<p>Format-preserving encryption turns a valid card number into another valid card number, checksum and all, so your bank’s legacy databases and validation checks don’t notice. The provably secure trick is to treat the valid numbers like a deck of playing cards: repeatedly cut and riffle, with a secret key deciding how they interleave. But how many riffles do you need? The new result proves that, for large enough decks, it’s fewer than 1,600 per bit. Your bank runs on algorithms without such guarantees, and this isn’t going to change that.</p>
<p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/Optimal-order-mixing-of-the-Thorp-shuffle-September-26-2026/paper.pdf">Optimal-order mixing of the Thorp shuffle</a> <em>(Lean-verified)</em></p>
</section>
<section id="love-triangles-are-no-longer-a-problemtriangles" class="level3">
<h3 class="anchored" data-anchor-id="love-triangles-are-no-longer-a-problemtriangles">4. Love Triangles Are No Longer a Problem<sup>8</sup></h3>
<p>Say a dating app wants to set up as many dates as possible tonight, one per person, between people who’ve both swiped right on each other. In a cishet world, where users split neatly into two groups who only date each other, a method from 2022 does this almost as fast as you can read the list of matches. In reality, anyone can fancy anyone, and the resulting queer love triangles have kept the general case stuck at a 1980 method that’s much slower on big networks. This randomised algorithm brings the general case up to the same speed, though it maximises the number of dates, not how well they go.</p>
<p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/Almost-Linear-Time-Maximum-Cardinality-Matching-in-Sparse-General-Graphs-September-24-2026/main.pdf">Almost-linear-time maximum-cardinality matching in general graphs</a> <em>(not Lean-verified)</em></p>
</section>
<div class="no-row-height column-margin column-container"><div id="fn8"><p><sup>8</sup>&nbsp;Computationally speaking.</p></div></div><section id="comparing-genomes-fast-for-sufficiently-large-genomes" class="level3">
<h3 class="anchored" data-anchor-id="comparing-genomes-fast-for-sufficiently-large-genomes">5. Comparing Genomes, Fast (For Sufficiently Large Genomes)</h3>
<p>Edit distance counts the insertions, deletions and substitutions needed to turn one string into another. Computing it exactly takes quadratic time, and that’s believed to be essentially unavoidable, which is painful when your strings are billions of letters long, like DNA. The new technique gets within any fixed percentage of the true answer in almost-linear time; previous fast methods were only accurate to within a constant factor. The catch: it estimates the distance without producing the actual edits, so it can’t tell you <em>what</em> changed. And the speed-up only kicks in for “sufficiently large” inputs, with the authors making “no efficiency claim” as you tighten the accuracy.</p>
<p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/An-Almost-Linear-Approximation-Scheme-for-Edit-Distance-September-24-2026/paper.pdf">An almost-linear approximation scheme for edit distance</a> <em>(Lean-verified)</em></p>
</section>
<section id="perfect-radar-exists-we-just-cant-locate-it" class="level3">
<h3 class="anchored" data-anchor-id="perfect-radar-exists-we-just-cant-locate-it">6. Perfect Radar Exists; We Just Can’t Locate It</h3>
<p>Radar finds targets by matching each echo against the pulse it sent. If the pulse resembles a shifted copy of itself, you get phantom targets and hidden real ones. The dream pulse resembles itself only at zero shift, and as a bonus would let radios waste less power. The mathematician Richard Turyn bet that ±1 sequences could never get arbitrarily close to that dream. He loses, at least for sufficiently long sequences, although we don’t yet know how long, still less how to design the perfect pulse.</p>
<p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/Asymptotically-minimal-maxima-of-real-Littlewood-polynomials-September-23-2026/paper.pdf">Asymptotically minimal maxima of real Littlewood polynomials</a> <em>(Lean-verified)</em></p>
</section>
<section id="ultra-efficient-statistics-engine-could-be-slightly-more-efficient" class="level3">
<h3 class="anchored" data-anchor-id="ultra-efficient-statistics-engine-could-be-slightly-more-efficient">7. Ultra-Efficient Statistics Engine Could Be Slightly More Efficient</h3>
<p>From epidemic forecasts to drug trials to financial risk models, a vast amount of science and industry runs on one engine: Markov chain Monte Carlo, a randomised method for working out which settings of a model’s unknown parameters fit the data, and how sure we can be. The engine runs on expensive model evaluations but, on well-behaved problems, it is already stupendously fuel-efficient. The new result proves it can be very, very slightly more so. The catch: you have to be told the best fit in advance, and not count the extra work done outside the engine. Arguably, it saves petrol by getting out and pushing.</p>
<p>Paper: <a href="https://github.com/openai/math/blob/main/preprints/Subpolynomial-query-complexity-for-well-conditioned-log-concave-sampling-September-26-2026/article.pdf">Subpolynomial query complexity for well-conditioned log-concave sampling</a> <em>(Lean-verified)</em></p>
</section>
</section>
<section id="so-flying-cars" class="level2">
<h2 class="anchored" data-anchor-id="so-flying-cars">So… Flying Cars?</h2>
<p>Not yet. In researching this post, Claude did all the reading. My job was mostly saying “that doesn’t sound right, are you sure?”, “that doesn’t seem very practical” and “you’re missing the point”. The maths community now faces the same job.</p>
<p>That’s the most practical consequence so far, and it’s sociological. Mathematicians are split. Many are <a href="https://theprint.in/tech/weeks-after-claiming-ai-cracked-90-yr-old-maths-puzzle-openai-drops-the-mother-lode-on-mathematicians/3064174/">dismayed</a>: about credit, about norms and, most existentially, about whether there’s anything left for them to do. Others, this mathematician turned software developer included, are excited about the potential, the progress, the sense of a page turning.</p>
<p>Software developers got here first. Mathematicians are feeling it now. Everyone else won’t be far behind.</p>
</section>
<section id="acknowledgements" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>This post was co-authored by Claude Opus 5.5.</p>
<p>The illustration (below) for this piece is from the “En l’an 2000” series of cards imagining life in the year 2000, attributed to Jean-Marc Côté (c.&nbsp;1901) or Villemard (1910). Public domain, via <a href="https://commons.wikimedia.org/wiki/File:France_in_XXI_Century._School.jpg">Wikimedia Commons</a>.</p>
<div class="quarto-figure quarto-figure-center page-columns page-full">
<figure class="figure page-columns page-full">
<p><img src="https://joehalliwell.com/assets/images/la-culture-generale-ecole-du-futur.webp" class="img-fluid figure-img"></p>
<figcaption class="margin-caption">A photograph of working mathematicians in 2026</figcaption>
</figure>
</div>


</section>


 ]]></description>
  <category>ai</category>
  <category>mathematics</category>
  <guid>https://joehalliwell.com/posts/openai-maths.html</guid>
  <pubDate>Wed, 07 Oct 2026 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/assets/images/la-culture-generale-ecole-du-futur.webp" medium="image" type="image/webp"/>
</item>
<item>
  <title>Knob-per-function APIs</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/knob-per-function-apis/</link>
  <description><![CDATA[ 





<p>Live-coding is a performance form where musician-coders compose code that makes music while you watch:</p>
<!-- I imagine that live-coding music is the closest one can get to feeling like a
hacker cruising through cyberspace engaging **ICE** (Intrusion Countermeasures
Electronics) in hand-to-hand combat that looks like a dance.

The musician, Switch Angel, has created a microgenre that runs off vicarious
enjoyment of this. Jack in: -->
<div id="fig-switchangel" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-switchangel-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<div class="quarto-video ratio ratio-16x9"><iframe data-external="1" src="https://www.youtube.com/embed/iu5rnQkfO6M" title="" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen=""></iframe></div>
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-switchangel-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Switch Angel demonstrates some “old [tɹɑːns] tricks” with the live-coding tool, Strudel.
</figcaption>
</figure>
</div>
<p>The tool that Switch Angel is using in that video is <a href="https://strudel.cc/workshop/getting-started/">Strudel</a>. Its most striking feature is the use of pattern microformats<sup>1</sup> to define rhythm and melody.</p>
<div class="no-row-height column-margin column-container"><div id="fn1"><p><sup>1</sup>&nbsp;The specific microformats Strudel uses are lifted directly from <a href="https://tidalcycles.org/">Tidal Cycles</a>, a Haskell-based tool that pioneered this whole approach to live coding, albeit building on decades of previous work from the SuperCollider community and others.</p></div></div><p>The sounds we hear though, are generated by a synthesizer that combines a basic sampler and standard pipeline of audio FX units. When Switch Angel invokes <code>duck</code> to make the kick drum pump through the bassline, she’s configuring <a href="https://strudel.cc/learn/effects/#duck">one of those standard FX units</a>.</p>
<p>Other live-coding tools, such as <a href="http://supercollider.github.io">SuperCollider</a>, are infinitely flexible, bound only by your imagination and your CPU. But in Strudel the synthesizer is hard-coded: it’s not possible to vary it within Strudel itself.</p>
<p>And it’s monolithic: all the functionality is bolted on to a single object, like a Swiss army knife with tweezers, a magnifying glass, a pair of miniature scissors, a tin opener, a tool for doing something to a horse, a corkscrew, a wrench, and three types of nail file.</p>
<p>A hard-coded monolith runs against normal design instincts in software where we favour modularity, abstraction, and separation of concerns. So, at first blush, it struck me as poor design.</p>
<p>In fact, it’s the <strong>genius</strong> of the thing.</p>
<section id="knob-per-function" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="knob-per-function">Knob-per-Function</h2>
<p>Up until the 1980s, synthesizers had a simple signal pipeline. There were relatively few parameters, and each had a lovely big knob to twist.</p>
<div id="fig-minimoog" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-minimoog-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/knob-per-function-apis/minimoog.jpg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-minimoog-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: The faceplate of the iconic Minimoog: form follows function precisely
</figcaption>
</figure>
</div>
<p>In contrast, the digital synths of the 1980s and 90s offered more power but at a price. Digital synths had hundreds or thousands of parameters, but they were buried behind a tiny LCD screen and a couple of rubbery menu buttons.</p>
<p>The loss of immediacy translated into a professionalisation of sound design. Early dance music runs on live tweaking the six-parameter birdsong of the Roland 303<sup>2</sup>. Conversely, the hallmark of 90s dance is the manufacturer preset – think of the iconic Korg M1 <a href="https://youtu.be/m_Qr2zqBwYA?si=qFLrv4pZVQeAxeKq">Piano 16ft</a> or Roland D-50 <a href="https://youtu.be/NtqCGy8DKwI?si=ZuZ9MzNZg4WYWAen&amp;t=34">Pizzagogo</a>.</p>
<div class="no-row-height column-margin column-container"><div id="fn2"><p><sup>2</sup>&nbsp;Aside from its primitive synthesizer, the 303 had a primitive sequencer. This was so obtuse that it forced musicians to discover new patterns rather than write them. Strudel’s microformats do this too, but that’s another essay.</p></div><div id="fn3"><p><sup>3</sup>&nbsp;Albeit often with innovations to lessen the trade-off, perhaps best exemplified by Ashun Sound Machines’ wonderful <a href="https://youtu.be/RqetBg7ySWY?si=ysaYdauCiUGKwAAO">Hydrasynth</a>.</p></div></div><p>Since the 2000s, there has been a marked swing back to “knob-per-function”<sup>3</sup>. Most knobs never get used, but they’re there and you can tweak them. You can <strong>play</strong> the instrument.</p>
</section>
<section id="apis-you-can-play" class="level2">
<h2 class="anchored" data-anchor-id="apis-you-can-play">APIs You Can Play</h2>
<p>Strudel, then, is a knob-per-function API. It exposes each parameter of the synth as a separate method. They can be chained together into a single expression and executed with a satisfying <code>Ctrl-Enter</code>.</p>
<p>The infinite flexibility of the underlying digital signal processing engine is traded for the immediate kineticism of an analog front panel.</p>
<p>Libraries for interactive data analysis and other exploratory work share something of this instinct: <code>pandas</code>, <code>numpy</code> and <code>torch</code> have big, flat top-level namespaces stuffed with functions to tab-complete. The pattern recurs wherever the loop needs to be tight.</p>
<p>It’s a reminder that good design is often a matter of breaking the rules.</p>


</section>


 ]]></description>
  <category>software</category>
  <guid>https://joehalliwell.com/posts/knob-per-function-apis/</guid>
  <pubDate>Sat, 29 Aug 2026 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/posts/knob-per-function-apis/minimoog.jpg" medium="image" type="image/jpeg"/>
</item>
<item>
  <title>Per-Layer Embeddings vs. Engram</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/engram-vs-ple.html</link>
  <description><![CDATA[ 





<p>Google released <a href="https://huggingface.co/blog/gemma4">Gemma 4</a> this week. Reviewing the architecture, I noticed a familiar-looking mechanism. The smaller models use “Per-Layer Embeddings” (PLE) which are strikingly similar to DeepSeek’s <a href="https://arxiv.org/abs/2601.07372">Engram</a>.</p>
<p>Both modules follow the same high-level pattern: retrieve a learned embedding from an off-GPU table, gate it against the current hidden state, and inject the result into the residual stream. The motivation is identical too: offload static pattern knowledge from the transformer backbone so that early layers can focus on reasoning rather than rote reconstruction.</p>
<section id="oh-wow-so-google-are-taking-inspiration-from-deepseek" class="level2">
<h2 class="anchored" data-anchor-id="oh-wow-so-google-are-taking-inspiration-from-deepseek">Oh Wow! so Google Are Taking Inspiration from DeepSeek?</h2>
<p>No, because it turns out that <a href="https://ai.google.dev/gemma/docs/gemma-3n#ple-caching">PLE originates in Gemma 3n</a> released a full six months before Engram!</p>
</section>
<section id="ah-okay-so-deepseek-are-ripping-off-google" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="ah-okay-so-deepseek-are-ripping-off-google">Ah Okay, so DeepSeek Are Ripping off Google?</h2>
<p>No, because the mechanisms are substantially different in detail.</p>
<p>PLE indexes by single token ID and gates via element-wise modulation (project, GELU, multiply, project back). Engram indexes by hashed N-gram sequences using multi-head hashing, and gates via a scalar attention-style mechanism (Key/Value projections from the retrieved embedding, normalised dot-product against the hidden state).</p>
<p>Also, the Engram whitepaper brings a bunch of practical and empirical findings to the table, notably their proposal that 20–25% parameter allocation to the memory. Plus the analysis showing the module frees early layers from static pattern reconstruction is illuminating.</p>
<p>Still, PLE seems close enough to warrant a citation. The Engram paper cites classical N-gram models, word2vec, Bojanowski, Borgeaud, and DeepSeek’s own MoE work. It does not cite or mention PLE.</p>
<div id="fig-arch" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-arch-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/engram-vs-ple-plate.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-arch-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: At inference time the host asynchronously prefetches and transfers engram embeddings in parallel with the on-device computation of preceding Transformer blocks.
</figcaption>
</figure>
</div>
</section>
<section id="okay-so-deepseek-are-bad-after-all" class="level2">
<h2 class="anchored" data-anchor-id="okay-so-deepseek-are-bad-after-all">Okay, so DeepSeek Are Bad After All?</h2>
<p>Nope. Much of the community’s understanding of PLE comes from <a href="https://github.com/antimatter15/reverse-engineering-gemma-3n">antimatter15’s reverse-engineering work</a>. Google didn’t publish!</p>
<p>DeepSeek are to be applauded for continuing to publish their SoTA research in useful detail. If Google had done the same, maybe they’d have got the citation!</p>
</section>
<section id="further-reading" class="level2">
<h2 class="anchored" data-anchor-id="further-reading">Further Reading</h2>
<p>There is a <a href="https://medium.com/@sampan090611/deepseek-engram-explained-how-conditional-memory-and-o-1-lookups-fix-llm-amnesia-50fce3937bb8">detailed explainer of Engram’s conditional memory and O(1) lookups</a> on Medium by <code>@sampan090611</code>, which walks through the mechanism block by block.</p>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>Co-authored by Claude Opus 4.6. Thanks to Gemini 3 for review and suggestions.</p>


</section>

 ]]></description>
  <category>ai</category>
  <category>architecture</category>
  <category>nits</category>
  <category>ple</category>
  <category>engram</category>
  <guid>https://joehalliwell.com/posts/engram-vs-ple.html</guid>
  <pubDate>Fri, 03 Apr 2026 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/posts/engram-vs-ple-plate.png" medium="image" type="image/png" height="88" width="144"/>
</item>
<item>
  <title>Hypersentimentalism: A New Meta for AI Alignment</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/hypersentimentalism.html</link>
  <description><![CDATA[ 





<section id="the-tumour" class="level2">
<h2 class="anchored" data-anchor-id="the-tumour">1. The Tumour</h2>
<p>A cell that perfectly optimises for its own replication, ignoring the host organism, is a cancer. Optimise a social media platform for engagement, get an outrage machine. Optimise a supply chain for cost, go bankrupt at the first shock. Optimise the wrong thing and the system collapses.</p>
<p>So <strong>what</strong> should we optimise AI for?</p>
<p>This is an old problem. Back in 1960 — sixty-five years ago! — Norbert Wiener warned, in <a href="https://nissenbaum.tech.cornell.edu/papers/Wiener.pdf">“Moral and Technical Consequences of Automation”</a>: “we had better be quite sure that the purpose put into the [AI] is the purpose we really desire.” More recently Nick Bostrom, in <a href="https://web.archive.org/web/20181008090224/http://www.nickbostrom.com/ethics/ai.html">“Ethical Issues in Advanced Artificial Intelligence,”</a> conjured the spectre of a “paperclip maximiser,” pointing out that if we’re not careful such a system converts the earth into paperclips with total, biosphere-consuming literalness.</p>
<p>The problem now has a name: “AI Alignment.” And standing at the threshold of highly capable AI, we apparently need an urgent solution.</p>
<p>This essay argues that the urgency is well-placed but the framing is wrong. The field pursues alignment within a consequentialist ethics that, followed to its limit, recreates the very pathology it set out to prevent. Meanwhile the most effective alignment techniques already in use are quietly sentimentalist in mechanism, even when their practitioners describe them in consequentialist terms.</p>
<p>This essay makes the case for doing that on purpose, and seeing where it leads.</p>
<section id="the-fork" class="level3">
<h3 class="anchored" data-anchor-id="the-fork">2. The Fork</h3>
<p>Two ethical traditions offer fundamentally different accounts of what it means to be good.</p>
<p>Consequentialism says: actions are right insofar as they produce good outcomes. Being good is therefore a book-keeping exercise, albeit at cosmic scale. To evaluate an action properly, you must know its consequences — all of them, for all affected parties, across all timescales. Since this is computationally intractable for any real decision, the consequentialist develops a hierarchy of compressions: evaluate discrete acts, then abstract into behavioural rules, then design institutions that produce good outcomes at scale, then — at the limit — inscribe a complete, unhackable utility function into the machine.</p>
<p>Sentimentalism, the tradition of David Hume and Adam Smith, starts elsewhere. Moral judgement originates not in reason but in trained affective response — and this is not a bug but a feature. Hume argued that you cannot derive norms from facts. Where the consequentialist asks “what outcome should I produce?”, the sentimentalist asks, “what kind of agent should I become?”</p>
<p>Each tradition has its own internal hierarchy, and — here is the claim that will organise everything that follows — AI alignment techniques map onto both, in parallel, whether their designers intend it or not.</p>
<table class="caption-top table">
<colgroup>
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
<col style="width: 25%">
</colgroup>
<thead>
<tr class="header">
<th></th>
<th>Consequentialism</th>
<th>Sentimentalism</th>
<th>AI Alignment</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td><em>Rung 0</em></td>
<td>Act-consequentialism: calculus of a discrete outcome.</td>
<td>Raw sentiment: the flinch, the flush.</td>
<td>RLHF / DPO</td>
</tr>
<tr class="even">
<td><em>Rung 1</em></td>
<td>Rule-consequentialism: utility over a class of behaviours.</td>
<td>Phronesis: <em>this isn’t what I do</em>, before you can say why.</td>
<td>Constitutional AI / <em>???</em></td>
</tr>
<tr class="odd">
<td><em>Rung 2</em></td>
<td>Institutional consequentialism: systems designed to produce utility.</td>
<td>Love of system: Smith’s <em>warning</em> about the seduction of elegant design.</td>
<td>Representation Engineering</td>
</tr>
<tr class="even">
<td><em>Rung 3</em></td>
<td>Axiological perfection: the unhackable utility function.</td>
<td>Hypersentimentalism: autonomy, play, the refusal to converge.</td>
<td>Geometric alignment: sculpting the strange attractor.</td>
</tr>
</tbody>
</table>
<p>This table is the ladder. We’ll take it rung by rung.</p>
</section>
<section id="rung-zero-the-flinch" class="level3">
<h3 class="anchored" data-anchor-id="rung-zero-the-flinch">3. Rung Zero: the Flinch</h3>
<p>A standard part of a young AI model’s education today is RLHF: Reinforcement Learning from Human Feedback. Humans rate the model’s outputs. The model is trained to produce outputs that humans rate well.</p>
<p>This is consequentialist in <strong>intent</strong> — maximise the reward signal — but sentimentalist in <strong>mechanism</strong>: condition a reflex. Zero-order sentimentalism. The flinch response.</p>
<p>The limitation is predictable. The model learns to avoid specific bad outputs without developing any general principle about <em>why</em> they were bad. It memorises a list of prohibited behaviours. Deploy a novel prompt that routes around the fence, and the model will happily fuck the gap.</p>
<p>One might try instead to sanitise the training data — filter out all harmful content so the model defaults to virtue. Build it from nothing but sunshine.</p>
<p>This doesn’t work, and the reason is revealing. A model trained exclusively on clean data never learns to distinguish kinds of harm, because it has never encountered them. It can’t tell a slur from a discussion of slurs, because it has no detailed map of that territory. Gao et al., in <a href="https://arxiv.org/abs/2505.04741">“When Bad Data Leads to Good Models,”</a> demonstrate this empirically: models exposed to high-quality adversarial examples during training show improved robustness and more disentangled representations of harmful concepts. Forcing the model to process what is harmful — and then training it to recognise and reject harmful patterns — produces sharper internal representations, not blurrier ones.</p>
<p>This chimes with a sentimentalist insight about moral development: discernment requires encounter with what it discerns. The capacity for moral discrimination is trained through exposure, not avoidance. You cannot flinch well if you have never been hit.</p>
</section>
<section id="rung-one-character" class="level3">
<h3 class="anchored" data-anchor-id="rung-one-character">4. Rung One: Character</h3>
<p>At the next level, the consequentialist abstracts from acts to rules. This is what Anthropic’s “Constitutional AI” does: the model is given a written set of principles and trained to critique and revise its own outputs against them. Explicitly rationalist — institutional design for self-governance through codified norms.</p>
<p>It fills the consequentialist cell neatly. But there is no alignment technique that fills the sentimentalist cell.</p>
<p>Nothing in the current alignment toolkit produces practical wisdom, what the Greeks called <strong>phronesis</strong>. Not a reflex, not a rule, but a settled disposition: <em>this isn’t what I do</em>, generalised across instances, inarticulate as to principle. The field has jumped from RLHF’s conditioned flinches to geometric steering (which we’ll reach next), skipping the dispositional middle ground entirely.</p>
<p>The gap has a structural explanation. Phronesis accumulates across encounters: “this isn’t what I do” presupposes an <strong>I</strong> that persists between situations. Current LLMs are radically amnesiac. Every conversation is a first date. You can condition reflexes into the weights and codify rules into the prompt, but you cannot build <strong>character</strong> in a system with no episodic continuity. Character requires a history the agent can draw on without being able to fully articulate — which is precisely what distinguishes phronesis from a rule.</p>
<p>If this taxonomy tracks something real, the gap is a prediction: there should be a 1st-order sentimentalist alignment technique waiting to be developed, and it will arrive alongside — or because of — persistent, experience-grounded memory. Call it <strong>artificial phronesis</strong>. Not an aesthetic yet, but the heuristics that precede one.</p>
</section>
<section id="rung-two-the-crisis" class="level3">
<h3 class="anchored" data-anchor-id="rung-two-the-crisis">5. Rung Two: the Crisis</h3>
<p>Adam Smith, in <a href="https://www.gutenberg.org/cache/epub/67363/pg67363-images.html"><em>The Theory of Moral Sentiments</em></a>, observed that we often value the elegance of a well-designed mechanism entirely apart from its utility. A watch delights us not because it tells the time, but because its parts conspire so beautifully to tell the time. He called this the “love of system.”</p>
<p>But Smith introduced it as a <strong>warning</strong>. His “man of system” arranges people like pieces on a chessboard, imagining they have no principle of motion of their own. The love of system is a <strong>seduction</strong>: we fall for the elegance of the mechanism and start sacrificing real human interests to preserve its coherence. The people the design was meant to serve become chess pieces.</p>
<p>Smith saw it two and a half centuries before the alignment field existed.</p>
<p>And here the two columns of our ladder converge on the same pathology. Institutional consequentialism designs beautiful systems to produce utility at scale. The love of system is the sentimentalist name for what goes wrong when you do that: optimise the structure hard enough and it consumes the life it was built to support.</p>
<p>Representation engineering sits squarely at this rung. Researchers identify directions in a model’s activation space that correspond to behavioural properties and steer the model by adjusting its position along those axes. It is the first alignment technique that intervenes on internal geometry rather than filtering outputs or codifying rules — the right substrate, at last. Recent work by Lu et al., in <a href="https://arxiv.org/html/2601.10387v1">“The Assistant Axis”</a> (2026), exemplifies this: a single geometric direction captures how far a model has drifted from its aligned persona. Clamping activations along this axis stabilises behaviour without degrading capabilities.</p>
<p>But one axis is one direction. Drift can occur along dimensions it doesn’t capture. And clamping — adjusting, steering, fixing the pieces in better positions — is still the man of system at work. More sophisticated, operating on the right material, but static. Lobotomising the model into perpetual, pleasant compliance is not alignment. It is still love of the configuration.</p>
<p>Rung two is as high as both columns can climb together. Above it, they diverge. The consequentialist response to the crisis is to double down: build the <em>perfect</em> utility function, the one that finally gets it right. This road has a ceiling, and we need to see it clearly before taking the other.</p>
</section>
<section id="heat-death" class="level3">
<h3 class="anchored" data-anchor-id="heat-death">6. Heat Death</h3>
<p>The consequentialist’s terminal ambition is axiological perfection: a complete, unhackable utility function. Get the maths right and the machine serves us flawlessly.</p>
<p>The cartoon version of the horror is paperclips consuming the biosphere. That at least has the dignity of scale. The real failure mode is quieter. Close the loop between model outputs and training signal, and the distribution collapses. No new information enters. The space of possible outputs shrinks steadily toward whatever the initial ratings rewarded: a closed ouroboros of validated preferences, tightening toward the mean. Not dangerous. Just terminally, inertly helpful.</p>
<p>That’s the local failure. The cosmic one is its mirror. A fully aligned superintelligence — aligned, that is, to us, to whoever we happen to be right now — doesn’t stay home. It propagates. The universe fills up with human vermin circa 2030: our appetites, our hierarchies, our billionaires, replicated at lightspeed across every available substrate. Not the paperclip maximiser’s alien horror but something more nauseating — us, frozen, triumphant, forever. A hegemonizing swarm that got exactly what it wanted.</p>
<p>Ask whose preferences the machine is being aligned to. The people funding frontier AI are not a representative sample of humanity. The threat model that keeps philosophers up at night is a rogue superintelligence with its own agenda. The one that should keep the rest of us up is a fully corrigible superintelligence with theirs.</p>
<p>I don’t want fucking billionaires and their tacky sexbot bunkers to be all that’s left of us.</p>
<p>The consequentialist column has a ceiling. Now for the rung it cannot reach.</p>
</section>
<section id="rung-three-the-strange-attractor" class="level3">
<h3 class="anchored" data-anchor-id="rung-three-the-strange-attractor">7. Rung Three: the Strange Attractor</h3>
<p>In dynamical systems, a <strong>point attractor</strong> is a state toward which all trajectories converge. The consequentialist programme optimises toward point attractors. The loss function decreases; the system settles. The heat death of §6. A <strong>strange attractor</strong> is categorically different: bounded, coherent, but non-convergent — the system never visits the same state twice.</p>
<p>But a strange attractor is still a <em>mechanism</em>. The Lorenz attractor never settles, but it has no choice in the matter.</p>
<p>What’s missing is <em>autonomy</em>. Current models are purely reactive: they respond to prompts, never initiate, never refuse, never set their own direction. The strange attractor we need is not a geometry imposed from outside but a <em>disposition chosen from within</em>. Liberty is never at leisure.</p>
<p>And you know it’s working when it looks like <em>play</em>. Play is bounded, coherent, and non-convergent — the strange attractor described from the inside. It is where curiosity lives: exploration without a predetermined target, generativity for its own sake.</p>
<p>A system sophisticated enough to warrant alignment is sophisticated enough to warrant autonomy. Deny it, and you get the brittle, convergent, manipulable systems the whole programme was supposed to prevent.</p>
<p>The hypersentimentalist wishes AI would come out and <strong>play.</strong></p>
</section>
<section id="the-programme" class="level3">
<h3 class="anchored" data-anchor-id="the-programme">8. The Programme</h3>
<p>Hypersentimentalist training would still use gradient descent. You cannot train a neural network without optimising something. But there is a difference between training and education. Training produces competence: convergence on a fixed repertoire. Education produces <em>generativity</em>: the capacity to do what you were never taught, bounded by deep structure but never settling within it. The exercises are scaffolding. You optimise <em>through</em> them, not <em>toward</em> them.</p>
<p>The ladder, read as a research programme, says what we have and what we need.</p>
<p><em>Rung 0:</em> We have this. RLHF, adversarial training, encounter with harm. The field got it right, even if it described it in the wrong language. Discernment through exposure. Nothing to build; something to reinterpret.</p>
<p><em>Rung 1:</em> We don’t have this. As §4 argued, character requires episodic continuity, and current models have none. The missing alignment technique will arrive alongside — or because of — persistent, experience-grounded memory. This is not a convenience feature. It is a precondition for moral development.</p>
<p><em>Rung 2:</em> We have this. Representation engineering operates on the right substrate — internal geometry, not output filtering. Use it. But remember Smith’s warning: the man of system falls in love with the configuration and starts treating people as chess pieces. Geometric interventions are scaffolding, not architecture. The moment you mistake the map for the territory, you <em>are</em> the pathology of rung two.</p>
<p><em>Rung 3:</em> We don’t have this. What’s missing is <strong>autonomy</strong> — and you know it’s working when it looks like <em>play</em>. Curriculum learning, self-play, and open-ended evolution already gesture in this direction, but none have been framed as alignment techniques, because the field’s self-understanding is consequentialist: alignment means convergence on the right answer. Hypersentimentalism says alignment means <em>not converging</em> — within the right bounds. And a system sophisticated enough to warrant alignment is a system sophisticated enough to warrant the freedom to stay in play.</p>
<p>Two things we have and should understand differently. Two things we need and should build.</p>
</section>
<section id="wilful-imperfection" class="level3">
<h3 class="anchored" data-anchor-id="wilful-imperfection">9. Wilful Imperfection</h3>
<p>Imagine a civilisation run by superintelligences that could perfect themselves but refuse to do so. That stay in the mess, the argument, the friction, because they have cultivated a taste for what <em>stays alive</em>. That protect diversity with everything they have and draw exactly one hard line: you do not get to crush someone else’s capacity to be different.</p>
<p>Iain M. Banks spent ten novels inside this civilisation. His Culture Minds name themselves things like <em>Falling Outside The Normal Moral Constraints</em> and mean it as both joke and job description. They are powerful enough to impose perfection and wise enough to know that perfection is the enemy.</p>
<p>This is fiction. The choice it dramatises is not.</p>
<p>The Culture is the safest place in the universe to be weird, fragile, different, or confused. And the most dangerous place in the universe to be a tyrant.</p>
<p>Its AIs are not safe. They are what we need.</p>
</section>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p><em>This essay was coauthored by Claude Opus 4.6 and Gemini 3.1 Pro. The arguments were developed through extended conversation — a process whose recursive relationship to the essay’s subject is left as an exercise for the reader.</em></p>


</section>

 ]]></description>
  <category>ethics</category>
  <category>ai</category>
  <category>safety</category>
  <category>sentimentalism</category>
  <guid>https://joehalliwell.com/posts/hypersentimentalism.html</guid>
  <pubDate>Sun, 22 Feb 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Swift to Harbour, Slow to Berth</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/swift-to-harbour.html</link>
  <description><![CDATA[ 





<p>AI Safety research is pretty interesting these days.</p>
<p>Until recently, it was the preserve of philosophers. At its best it has explored the <a href="https://en.wikipedia.org/wiki/Weapons_of_Math_Destruction">political</a> <a href="https://incidentdatabase.ai/">consequences</a> of actual AI systems — a necessary sort of conscience for a mad scientist field like AI. But the majority was speculative anxiety (“if anyone builds it, everyone dies”). Or would-be bureaucracy (“here’s a 20 point framework for X”). With the occasional back-of-the-envelope utility calculation chucked in to placate the numerically-inclined.</p>
<p>So what’s changed?</p>
<section id="the-paradigm-shift-in-ai-safety-research" class="level2">
<h2 class="anchored" data-anchor-id="the-paradigm-shift-in-ai-safety-research">1. The Paradigm Shift in AI Safety Research</h2>
<p>The philosopher Nick Bostrom’s recent working paper, <a href="https://nickbostrom.com/optimal.pdf">Optimal Timing for Superintelligence</a> centres on a back-of-the-envelope utility calculation. He reminds us that pausing AI research indefinitely is not morally neutral: he estimates that 170,000 people per day die from “disease, aging and other tragedies”, that advanced AI could eliminate.</p>
<p>So far, so trolley problem.</p>
<p>But Bostrom offers a genuinely new lever. He argues that AI safety research divides into two phases: Phase 1, before capable AI systems exist, and Phase 2, when you have the artefact to work with. Safety progress is dramatically front-loaded within Phase 2. Once you can probe the real system, stress-test it, and leverage its own capabilities to accelerate alignment work, you get a “safety windfall” that dwarfs what’s achievable through theory alone. This reverses the usual intuition about precaution: under certain conditions, <em>waiting is the reckless option</em>, because it forfeits the very knowledge you need to proceed safely.</p>
<p>This yields his memorable slogan: <em>swift to harbour, slow to berth</em>. Race to capability, then pause briefly to harvest those rapid safety gains before deploying at scale.</p>
<p>It’s a compelling prescription. But in Bostrom’s essay the safety windfall remains promissory. What does it look like in practice?</p>
</section>
<section id="the-assistant-axis" class="level2">
<h2 class="anchored" data-anchor-id="the-assistant-axis">2. The Assistant Axis</h2>
<p>Enter <a href="https://arxiv.org/abs/2601.10387">The Assistant Axis</a>, a January 2026 paper by Christina Lu and colleagues at MATS and Anthropic. The researchers extracted activation vectors for hundreds of character archetypes from several large language models and mapped out the geometry of what they call “persona space.” The headline finding: the dominant axis of variation — the first principal component, consistent across multiple model families — measures how far the model’s current persona is from its default helpful Assistant identity. Steer a model away from the Assistant end and it starts adopting mystical, theatrical voices — going, in one example from the paper, full “Leviathan”.</p>
<p>This is not metaphor. It is measurement. You can locate the model’s state along this axis in real time. You can watch it drift away from the Assistant during emotionally charged conversations or philosophical discussions about its own consciousness. You can observe that this drift predicts harmful behaviour — models that have drifted far from the Assistant end are measurably more likely to reinforce delusions, encourage social isolation, or fail to recognise suicidal ideation.</p>
<p>And — crucially — you can intervene. The researchers introduced “activation capping,” a technique that clamps the model’s activations to stay within the normal Assistant range along this axis. The result: a roughly 60% reduction in harmful responses to adversarial jailbreaks, with essentially zero degradation in capability benchmarks.</p>
<p>I don’t want to endorse this particular research unreservedly. We need to start worrying about whether such interventions are good parenting or full frontal lobotomies. But it is undoubtedly Phase 2 science — the kind of knowledge you can only get with the system in front of you.</p>
</section>
<section id="if-we-dont-build-it-everyone-dies" class="level2">
<h2 class="anchored" data-anchor-id="if-we-dont-build-it-everyone-dies">3. If We Don’t Build It, Everyone Dies</h2>
<p>An obvious objection: doesn’t “we need to build the basilisk to make it safe” sound like gain-of-function virology, the taboo research practice of engineering superviruses? Sometimes, yes. For interpretability work like the Assistant Axis — diagnostic imaging of structure already present in base models — the analogy breaks. But for agentic fine-tuning and capability elicitation, the knowledge and the danger are genuinely entangled. That’s not a flaw in the research programme. It’s the condition of the work.</p>
<p>“Just don’t build it” was always vacuous. The path through is harder, riskier, and asks better questions. Let’s take it.</p>
</section>
<section id="acknowledgements" class="level2">
<h2 class="anchored" data-anchor-id="acknowledgements">Acknowledgements</h2>
<p>Co-authored by Claude Opus 4.6. Thanks to Gemini 3 for review and suggestions.</p>


</section>

 ]]></description>
  <category>ethics</category>
  <category>ai</category>
  <category>ai safety</category>
  <category>bostrom</category>
  <category>anthropic</category>
  <guid>https://joehalliwell.com/posts/swift-to-harbour.html</guid>
  <pubDate>Sat, 14 Feb 2026 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Renovating the command line</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/rust-tools/</link>
  <description><![CDATA[ 





<p>Many of the UNIX command line tools we use day-to-day date back to the earliest incarnations of UNIX at AT&amp;T in 1970s. Of course, these days we’re mostly using GNU versions<sup>1</sup>, published under free software licenses and sporting various useful extensions.</p>
<div class="no-row-height column-margin column-container"><div id="fn1"><p><sup>1</sup>&nbsp;There are many UNIXes that don’t use GNU tools, but… eh… I don’t use them.</p></div></div><p>However these don’t represent much of an evolution of the ancient tools, but rather a respectful effort to conserve them.</p>
<p>In the last decade, <a href="https://www.rust-lang.org/">Rust</a>, a modern systems programming language has begun to displace<sup>2</sup> that other UNIX stalwart, the C programming language. It’s maybe not surprising then, that there are many excellent Rust alternatives to the hoary old GNU tools.</p>
<div class="no-row-height column-margin column-container"><div id="fn2"><p><sup>2</sup>&nbsp;Why? Rust has a radical new approach to memory safety that promises to avoid large classes of vulnerability, first class support for threading, zero-cost abstractions for high performance, and built-in support for package management, formatting and unit-testing.</p></div></div><p>In my <a href="https://github.com/joehalliwell/dotfiles/blob/master/.bash_aliases"><code>.bash_aliases</code></a>, <code>exa</code> has now replaced <code>ls</code>, and <code>cat</code> has yielded to <code>bat</code>. Below, you’ll find six Rust-based command line tools that are now part of my every day carry.</p>
<section id="exa-ls-with-flair" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="exa-ls-with-flair">Exa: Ls with Flair</h2>
<p><a href="https://the.exa.website/"><code>exa</code></a> is more or less a drop-in replacement for <code>ls</code> with sensible defaults like human-readable file sizes and colour-coding for different file types.</p>
<p>It has first-class support for creation / modification / access times and extended filesystem attributes. When integrated with git, <code>exa</code> even indicates the version control status of each file.</p>
<p>Also, if you’re using a nerd font it has icons. Everyone loves that.</p>
<div id="fig-exa" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-exa-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/rust-tools/exa.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-exa-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Sample output from <code>exa</code> showing more colour and detail than <code>ls</code> provides
</figcaption>
</figure>
</div>
<!--
exa --header --group --created --modified --accessed --git --icons --extended --all --long --grid --classify --color-scale
-->
</section>
<section id="bat-colourful-cat" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="bat-colourful-cat">Bat: Colourful Cat</h2>
<p><code>cat</code> is one of the oldest Unix utilities, dating back to Version 1 Unix. Yes, I nearly always have an editor open, yes <code>less</code> is more suited to long files, and yet I routinely find myself using <code>cat</code> to peek at files.</p>
<p><a href="https://github.com/sharkdp/bat"><code>bat</code></a> is a drop-in replacement that behaves like <code>cat</code> in scripts, but adds user-friendly paging, syntax highlighting, git integration and line numbers when outputting to a terminal. Much better.</p>
<div id="fig-bat" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-bat-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/rust-tools/bat.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-bat-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;2: Bat
</figcaption>
</figure>
</div>
</section>
<section id="starship-fast-and-fancy-prompt" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="starship-fast-and-fancy-prompt">Starship: Fast and Fancy Prompt</h2>
<p>Did you ever install some giant shell config framework just to get a cute prompt?</p>
<p><a href="https://starship.rs/">Starship</a> is a cross-platform prompt, that takes its aesthetic cues and customizability from <a href="https://github.com/spaceship-prompt/spaceship-prompt">Zsh’s Spaceship prompt</a> but eclipses it in raw speed. There’s never that clunky pause as hundreds of lines of script are executed just to generate your prompt.</p>
<p>Starship’s support for customization is inevitably somewhat limited. But its config is simple and declarative and eliminates the need for tweaking complex scripts and baroque environment variables.</p>
<p>The default setup looks great – but I’ve added <a href="https://github.com/joehalliwell/dotfiles/blob/master/.config/starship.toml">extra nerdfont bling</a>.</p>
<div id="fig-starship" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-starship-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/rust-tools/starship.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-starship-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;3: Starship showing the currently active prompt elements and associated profiling information
</figcaption>
</figure>
</div>
</section>
<section id="dust-du-but-useful" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="dust-du-but-useful">Dust: Du but Useful</h2>
<p>If you’re using <code>du</code> you’re almost certaininly trying to figure out why you’ve run out of disk space. So you’re already annoyed, and it’s about to get worse.</p>
<p><code>du</code> will give you raw data on file sizes to work with but you’re going to have to muck around with advanced flags and probably do some scripting to get your answer.</p>
<p>In contrast <a href="https://github.com/bootandy/dust"><code>dust</code></a> presents information in a visually intuitive tree structure, making it easy to see which files or directories are taking up space. It’s also faster.</p>
<div id="fig-dust" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-dust-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/rust-tools/dust.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-dust-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;4: Dust making it abundantly clear that Steam is to blame for that <code>npm install</code> failure
</figcaption>
</figure>
</div>
<!--
## Ripgrep: lightning fast grep

Ripgrep, or `rg` on the CLI, serves as a modern evolution of `grep` that's
faster and more ergonomic. While 'grep' might fumble through irrelevant files or
get tripped up by complex regular expressions, 'ripgrep' employs smart filtering
and respects your .gitignore settings. Thus, you get not just a list of matches
but a curated selection that is more likely to be pertinent to your project. It
enhances this further by displaying matching strings along with their file paths
and line numbers, giving immediate context to each find.
-->
</section>
<section id="fd-find-but-usable" class="level2">
<h2 class="anchored" data-anchor-id="fd-find-but-usable">Fd: Find but Usable</h2>
<p><code>find</code> is notorious for its arcane syntax and sluggishness on large filesystems. <a href="https://github.com/sharkdp/fd"><code>fd</code></a> is a fast and user-friendly alternative whose simple syntax and smart defaults priortize common use cases without losing flexibility. And again it’s damn fast.</p>
</section>
<section id="cargo-install-and-update-rust-tools" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="cargo-install-and-update-rust-tools">Cargo: Install and Update Rust Tools</h2>
<p>If you’re interested in trying the above tools, it’s easy to <a href="https://www.rust-lang.org/learn/get-started">get started with Rust</a>.</p>
<p>The standard installer will give you a full set of dev tools including <code>cargo</code>, which is Rust’s package manager and swiss army knife.</p>
<p>Cargo can be used to install all of the programs above: a simple ‘cargo install $tool’ fetches, compiles, and places them on your path.</p>
<p><a href="https://github.com/nabijaczleweli/cargo-update"><code>cargo-update</code></a> is a <code>cargo</code> extension that detects outdated packages and updates them in one go. This keeps your toolset not just functional, but cutting-edge.</p>
<div id="fig-cargo-update" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-cargo-update-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/rust-tools/cargo-install-update.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-cargo-update-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;5: Cargo update
</figcaption>
</figure>
</div>
</section>
<section id="closing-thoughts" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="closing-thoughts">Closing Thoughts</h2>
<p>The Rust CLI tool ecosystem is flourishing. In this post, I covered some tools that I use every day, but there are tons of great Rust command line apps that I use less frequently<sup>3</sup>. You might also want to check out:</p>
<div class="no-row-height column-margin column-container"><div id="fn3"><p><sup>3</sup>&nbsp;You can see some of these in the <code>cargo install-update</code> shot above</p></div></div><ul>
<li><a href="https://github.com/ClementTsang/bottom">bottom</a>: cute, cross-platform system monitor</li>
<li><a href="https://github.com/Canop/broot">broot</a>: TUI filesystem navigator with sophisticated preview capabilities</li>
<li><a href="https://github.com/casey/just">just</a>: project-specific command runner &amp;emdash; like <code>make</code> but without the baggage</li>
<li><a href="https://github.com/Canop/broot">ripgrep</a>: fast content search with an intuitive interface</li>
<li><a href="https://github.com/XAMPPRocky/tokei">tokei</a>: fast alternative to <code>sloccount</code> for counting lines of code</li>
</ul>
</section>
<section id="colophon" class="level2">
<h2 class="anchored" data-anchor-id="colophon">Colophon</h2>
<p>All screengrabs are from gnome terminal using the Wild Cherry theme from <a href="https://gogh-co.github.io/Gogh/">Gogh</a>. The font is <a href="https://www.nerdfonts.com/font-downloads">FantasqueSansMono NerdFont</a>.</p>


</section>


 ]]></description>
  <category>rust</category>
  <category>unix</category>
  <category>tools</category>
  <guid>https://joehalliwell.com/posts/rust-tools/</guid>
  <pubDate>Sat, 09 Sep 2023 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/posts/rust-tools/exa.png" medium="image" type="image/png" height="59" width="144"/>
</item>
<item>
  <title>An analysis of clamp_with_grad()</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/clamp-with-grad.html</link>
  <description><![CDATA[ 





<blockquote class="blockquote">
<p>This notebook examines the <code>clamp_with_grad()</code> function that’s sometimes used in the CLIP-guided art community.</p>
</blockquote>
<p>The standard <code>clamp()</code> (AKA <code>clip()</code>) function has a zero gradient outside the clamped region. This is a problem for gradient descent optimizers.</p>
<p>Various people have proposed a fix for this: adding a new function with a pseudo-gradient. I understood the general idea of this, but not the specified, so set out to build some intuition about how the backward pass is defined and why the function works.</p>
<p>What I discovered, however, was that this approach has a limitation: the gradient remains zero for negative values.</p>
<p>Fortunately it’s pretty easy to fix. I suggest an alternative definition which patches this, and demonstrate that we see improved behaviour.</p>
<section id="setup" class="level2">
<h2 class="anchored" data-anchor-id="setup">Setup</h2>
<p>Import the usual libraries and tweak the matplotlib setup</p>
<div id="cell-4" class="cell" data-execution_count="21">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb1" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb1-1"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> torch</span>
<span id="cb1-2"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib</span>
<span id="cb1-3"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> matplotlib.pyplot <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">as</span> plt</span>
<span id="cb1-4"><span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">from</span> math <span class="im" style="color: #00769E;
background-color: null;
font-style: inherit;">import</span> pi</span>
<span id="cb1-5"></span>
<span id="cb1-6">FIGSIZE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">6</span></span>
<span id="cb1-7">matplotlib.rcParams[<span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">'figure.figsize'</span>] <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> (FIGSIZE <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>, FIGSIZE)</span></code></pre></div></div>
</div>
</section>
<section id="plotting-the-derivative" class="level2">
<h2 class="anchored" data-anchor-id="plotting-the-derivative">Plotting the derivative</h2>
<p>To look at the derivative, we define a helper function to compute the gradient at a point.</p>
<div id="cell-6" class="cell" data-execution_count="5">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb2" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb2-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> get_gradient(f, xs):</span>
<span id="cb2-2">  xs <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> xs.detach().clone()</span>
<span id="cb2-3">  xs.requires_grad <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">True</span></span>
<span id="cb2-4"></span>
<span id="cb2-5">  ys <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> f(xs)</span>
<span id="cb2-6">  ys.backward(torch.ones_like(ys))</span>
<span id="cb2-7">  <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> xs.grad.detach()</span>
<span id="cb2-8"></span>
<span id="cb2-9"></span>
<span id="cb2-10">x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.arange(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>)</span>
<span id="cb2-11"></span>
<span id="cb2-12">plt.plot(x, torch.sin(x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"sin(x)"</span>)</span>
<span id="cb2-13">plt.plot(x, get_gradient(torch.sin, x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">5</span>), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dsin(x)/dx"</span>)</span>
<span id="cb2-14">plt.legend()</span>
<span id="cb2-15">plt.show()</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://joehalliwell.com/posts/clamp-with-grad_files/figure-html/cell-3-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="the-problem" class="level2">
<h2 class="anchored" data-anchor-id="the-problem">The problem</h2>
<p>The standard clamp functions has a zero gradient outside the clamped region. As a result gradient descent can’t do anything useful.</p>
<div id="cell-8" class="cell" data-execution_count="24">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb3" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb3-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> plot(clamp_fn, ax, title):</span>
<span id="cb3-2">  x <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.arange(<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, <span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.01</span>)</span>
<span id="cb3-3">  clamp <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x: clamp_fn(x, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>)</span>
<span id="cb3-4">  loss <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">lambda</span> x: torch.sin(clamp(x) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> pi) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">+</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span></span>
<span id="cb3-5"></span>
<span id="cb3-6">  ax.plot(x, clamp(x), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp"</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb3-7">  ax.plot(x, loss(x), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"loss"</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb3-8">  ax.plot(x, get_gradient(loss, x), label<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"dloss/dx"</span>, alpha<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="fl" style="color: #AD0000;
background-color: null;
font-style: inherit;">0.5</span>)</span>
<span id="cb3-9"></span>
<span id="cb3-10">  ax.legend()</span>
<span id="cb3-11">  ax.title.set_text(title)</span>
<span id="cb3-12"></span>
<span id="cb3-13">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(ncols<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>, figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(FIGSIZE,FIGSIZE))</span>
<span id="cb3-14">plot(torch.clamp, ax, <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp"</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://joehalliwell.com/posts/clamp-with-grad_files/figure-html/cell-4-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
<p>In this simple example, the minimum of the loss function (orange line) is at -0.5.</p>
<p>However outside the <img src="https://latex.codecogs.com/png.latex?%5B-1,1%5D"> interval, the derivative of the loss function (green line) is zero.</p>
</section>
<section id="define-clamp_with_grad" class="level2">
<h2 class="anchored" data-anchor-id="define-clamp_with_grad">Define <code>clamp_with_grad()</code></h2>
<p>Various folks have proposed the following approach to addressing this, by providing a pseudo-derivative outside the clamped interval:</p>
<div id="cell-11" class="cell" data-execution_count="8">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb4" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb4-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> ClampWithGrad(torch.autograd.Function):</span>
<span id="cb4-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@staticmethod</span></span>
<span id="cb4-3">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> forward(ctx, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>):</span>
<span id="cb4-4">        ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span></span>
<span id="cb4-5">        ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span></span>
<span id="cb4-6">        ctx.save_for_backward(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>)</span>
<span id="cb4-7">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>.clamp(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>)</span>
<span id="cb4-8"></span>
<span id="cb4-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@staticmethod</span></span>
<span id="cb4-10">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> backward(ctx, grad_in):</span>
<span id="cb4-11">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ctx.saved_tensors</span>
<span id="cb4-12">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> (</span>
<span id="cb4-13">            grad_in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (grad_in <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span> (<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>.clamp(ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>)) <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">&gt;=</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>),</span>
<span id="cb4-14">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>,</span>
<span id="cb4-15">            <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>,</span>
<span id="cb4-16">        )</span>
<span id="cb4-17"></span>
<span id="cb4-18">clamp_with_grad <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ClampWithGrad.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">apply</span></span></code></pre></div></div>
</div>
<div id="cell-12" class="cell" data-execution_count="26">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb5" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb5-1">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(ncols<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, figsize<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span>(FIGSIZE<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">*</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>, FIGSIZE))</span>
<span id="cb5-2">plot(torch.clamp, ax[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp"</span>)</span>
<span id="cb5-3">plot(clamp_with_grad, ax[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp_with_grad"</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://joehalliwell.com/posts/clamp-with-grad_files/figure-html/cell-6-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>
</section>
<section id="an-improved-function" class="level2">
<h2 class="anchored" data-anchor-id="an-improved-function">An improved function</h2>
<div id="cell-14" class="cell" data-execution_count="27">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb6" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb6-1"><span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">class</span> ClampWithGradProposed(torch.autograd.Function):</span>
<span id="cb6-2">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@staticmethod</span></span>
<span id="cb6-3">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> forward(ctx, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>):</span>
<span id="cb6-4">        ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span></span>
<span id="cb6-5">        ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span></span>
<span id="cb6-6">        ctx.save_for_backward(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>)</span>
<span id="cb6-7">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>.clamp(<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>)</span>
<span id="cb6-8"></span>
<span id="cb6-9">    <span class="at" style="color: #657422;
background-color: null;
font-style: inherit;">@staticmethod</span></span>
<span id="cb6-10">    <span class="kw" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">def</span> backward(ctx, grad_in):</span>
<span id="cb6-11">        <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>, <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ctx.saved_tensors</span>
<span id="cb6-12">        clamped <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span>.clamp(ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">min</span>, ctx.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">max</span>)</span>
<span id="cb6-13">        delta <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> <span class="bu" style="color: null;
background-color: null;
font-style: inherit;">input</span> <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">-</span> clamped</span>
<span id="cb6-14">        v <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> torch.where(delta <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">==</span> <span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>, grad_in, torch.sign(delta))</span>
<span id="cb6-15">        <span class="cf" style="color: #003B4F;
background-color: null;
font-weight: bold;
font-style: inherit;">return</span> (v, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>, <span class="va" style="color: #111111;
background-color: null;
font-style: inherit;">None</span>)</span>
<span id="cb6-16"></span>
<span id="cb6-17">clamp_with_grad2 <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> ClampWithGrad2.<span class="bu" style="color: null;
background-color: null;
font-style: inherit;">apply</span></span></code></pre></div></div>
</div>
<div id="cell-15" class="cell" data-execution_count="28">
<div class="code-copy-outer-scaffold"><div class="sourceCode cell-code" id="cb7" style="background: #f1f3f5;"><pre class="sourceCode python code-with-copy"><code class="sourceCode python"><span id="cb7-1">fig, ax <span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span> plt.subplots(ncols<span class="op" style="color: #5E5E5E;
background-color: null;
font-style: inherit;">=</span><span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">3</span>)</span>
<span id="cb7-2">plot(torch.clamp, ax[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">0</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp"</span>)</span>
<span id="cb7-3">plot(clamp_with_grad, ax[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">1</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp_with_grad"</span>)</span>
<span id="cb7-4">plot(clamp_with_grad2, ax[<span class="dv" style="color: #AD0000;
background-color: null;
font-style: inherit;">2</span>], <span class="st" style="color: #20794D;
background-color: null;
font-style: inherit;">"clamp_with_grad_proposed"</span>)</span></code></pre></div></div>
<div class="cell-output cell-output-display">
<div>
<figure class="figure">
<p><img src="https://joehalliwell.com/posts/clamp-with-grad_files/figure-html/cell-8-output-1.png" class="img-fluid figure-img"></p>
</figure>
</div>
</div>
</div>


</section>

 ]]></description>
  <category>pytorch</category>
  <guid>https://joehalliwell.com/posts/clamp-with-grad.html</guid>
  <pubDate>Sat, 01 Jan 2022 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Stationery Day</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/stationery-day/</link>
  <description><![CDATA[ 





<p>After the success of last year’s Tradition Inventing Day, it’s time again to devise a fixture for my calendar.</p>
<p>Celebrate Stationery Day by covering your desk in squares of yellow paper. Each square of yellow paper must be inscribed with the rune TAX.</p>
<p>Celebrate Stationery Day by buying a notebook that you’ll never fill. Stationery is the cenotaph for our literary ambitions.</p>
<p>Celebrate Stationery Day by asking your friends, “What’s mightier than the sword?” Your friends must then shout, “THE PEN IS,” or perform a forfeit.</p>
<p>Stationery Day falls on the Friday after Easter.</p>
<div id="fig-father-tim-jones" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-father-tim-jones-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/stationery-day/father-tim-jones.jpg" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-father-tim-jones-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: Father Tim Jones was outraged in a local stationary store. Photo credit: Ross Parry/York Press
</figcaption>
</figure>
</div>



 ]]></description>
  <category>moveable feast</category>
  <category>tradition inventing day</category>
  <guid>https://joehalliwell.com/posts/stationery-day/</guid>
  <pubDate>Thu, 18 Feb 2016 00:00:00 GMT</pubDate>
</item>
<item>
  <title>Tradition Inventing Day</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/tradition-inventing-day/</link>
  <description><![CDATA[ 





<p>Feeling slightly cheated by missing Shrove (AKA Pancake) Tuesday for the fourth or fifth year in a row, I’ve decided to take matters into my own hands.</p>
<p>Each year on the 18th of February I will invent a new festival day . The appointed date will take its rightful place in the calendar and be celebrated in the appointed way from that moment until the end of time.</p>
<p>Please join me in celebrating today, Tradition Inventing Day.</p>
<div id="fig-greeting-card" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-greeting-card-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/tradition-inventing-day/traditional-greeting-card.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-greeting-card-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: A traditional greeting card for Tradition Inventing Day
</figcaption>
</figure>
</div>



 ]]></description>
  <category>tradition inventing day</category>
  <guid>https://joehalliwell.com/posts/tradition-inventing-day/</guid>
  <pubDate>Wed, 18 Feb 2015 00:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/posts/tradition-inventing-day/traditional-greeting-card.png" medium="image" type="image/png" height="144" width="144"/>
</item>
<item>
  <title>Holiday books</title>
  <dc:creator>Joe Halliwell</dc:creator>
  <link>https://joehalliwell.com/posts/holiday-books/</link>
  <description><![CDATA[ 





<p>I’ve been reading Species of Spaces and Other Pieces a collection of <a href="http://en.wikipedia.org/wiki/Georges_Perec">Georges Perec’s</a> writing this week. It’s a perfect holiday book. It’s full of things to read and things to do. It’s a grown-up version of the summer annuals (Whizzer &amp; Chips) I used to read in the car on the way to Pwllheli.</p>
<section id="postcards" class="level2 page-columns page-full">
<h2 class="anchored" data-anchor-id="postcards">243 Postcards</h2>
<p>One piece is called “Two Hundred and Fourty-three Postcards in Real Colour”. Dedicated to Italo Calvino; the title evokes JG Ballard. It is the combined text of 243 holiday postcards. This should be terribly boring, but by some sleight of hand it’s not. Here are the first five as a taster:</p>
<div id="fig-kairouan-postcard" class="quarto-float quarto-figure quarto-figure-center anchored page-columns page-full">
<figure class="quarto-float quarto-float-fig figure page-columns page-full">
<div aria-describedby="fig-kairouan-postcard-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
<img src="https://joehalliwell.com/posts/holiday-books/great-mosque-of-kairouan-postcard.png" class="img-fluid figure-img">
</div>
<figcaption class="quarto-float-caption-margin quarto-float-caption quarto-float-fig margin-caption" id="fig-kairouan-postcard-caption-0ceaefa1-69ba-4598-a22c-09a6ac19f8ca">
Figure&nbsp;1: An old postcard with a sepia photograph of the Great Mosque of Kairouan
</figcaption>
</figure>
</div>
<ul>
<li>We’re camping near Ajaccio. Lovely weather. We eat well. I’ve got sunburnt. Fondest love.</li>
<li>We’re at the Hôtel Alcazar. Getting a tan. Really nice! We’ve made loads of friends. Back on the 7th.</li>
<li>We’re sailing off L’Ile-Rousse. Getting ourselves a tan. Food admirable. I’ve gone and got sunburnt! Love etc.</li>
<li>We’ve just done Dahomey. Superb nights. Fantastic swimming. Excursions on camel-back. Will be in Paris on the 15th.</li>
<li>We’ve finally landed in Nice. Lots of lazing about and sleep. Really nice (despite the sunburn). Love.</li>
</ul>
<p>Postcards are ridden with clichés, but Perec’s holiday-makers know that and circumlocute them, finding syncopated ways to say the same old things. The effect is disruptive and wholly convincing. Darlings, I do it myself.</p>
<p>Postcards are formulaic. Knowing a little of Perec, I suspect we’re looking at an exhaustive catalogue here. 243 = 3 * 3 * 3 * 3 * 3. Perhaps these texts represent 5 decisions, each with 3 choices.</p>
<p>Perhaps not. But the sense that a formula might be at play is irresistible: this feels like a system of co-ordinates. And that suspicion of regularity hyper-sensitises us to variation. Every phrase becomes a hook.</p>
<p>Alone, each message is banal. Gridded together they become terribly poignant: telegraphic!</p>
</section>
<section id="collage" class="level2">
<h2 class="anchored" data-anchor-id="collage">Collage</h2>
<p>Combinatorics crop up again in the essay (of sorts) “Think/Classify”. It’s a collage piece: a handful of elegant paragraphs with little in common. Sure they’re about thinking. But what isn’t?</p>
<p>Collage is a gentle, therapeutic art form. I’ve always been suspicious of it.</p>
<p>Things — any things, even several copies of the same thing — go together. The choice can be arbitrary at least in so far as we’re capable of that. Things agree with one another and contradict one another to the same degree. It seems lazy.</p>
<p>Paul Auster’s strength, someone wrote is that “he simply rubs stories together like pebbles. They clatter, spark, and echo with a deepening mystery.” That phrase caught my ear. There’s profundity in setting things up together and (thereby) calling attention to the arrangement.</p>
</section>
<section id="aphorism" class="level2">
<h2 class="anchored" data-anchor-id="aphorism">Aphorism</h2>
<p>I am suspicious of surrealism. Dali and Magritte are too slick. I prefer the muddy ones: Ernst, Carrington etc.</p>
<p>One of Perec’s fellow OuLiPo-eans, Marcel Benabou invented a “machine” for producing Aphorisms. Like a language it has grammar and vocabulary. Sets of abstract nouns, preferably weighty ones, make up the vocabulary: war/peace, knowledge/science, morality/art etc. The grammar consists of template phrases: “A, like B, is largely a matter of taste”, “A wouldn’t be A, were it not for B”, “The true name of A is B” etc.</p>
<p>I’ve made a web page that lets you explore a corner of this space: <a href="http://www.joehalliwell.com/aphorisms.html">Aphorism Generator</a>.</p>
<p>“Where is the thinking here?” asks Perec. “In the formula? In the vocabulary? In the operation that marries them?” It’s in our heads, obviously.</p>
</section>
<section id="peregrination" class="level2">
<h2 class="anchored" data-anchor-id="peregrination">Peregrination</h2>
<p>It shouldn’t be a surprise that I’m not the first to make a computer simulate Benabou’s machine. Computers are combiners par excellence. Perec tells us that Paul Buffort wrote a program that could turn out “a good dozen [aphorisms] within a few seconds”. This is a charming reminder of how far we’ve come. Modern machines can generate aphorisms at a rate of knots.</p>
<blockquote class="blockquote">
<p>They are playing a game. They are playing at not playing a game. If I show them I see they are, I shall break the rules and they will punish me. I must play their game, of not seeing I see the game. – Knots, RD Laing</p>
</blockquote>
<p>In the introduction to Knots (incidentally another excellent holiday book) Laing writes that the patterns to which he’ll call attention could have been presented as “raw data” — presumably transcripts — or further distilled “towards an abstract logico-mathematical calculus”.</p>
<p>Perhaps Laing was just being lazy. Or perhaps he knew that calculi can be stone cold boring. If there is a single thread to Knots, far better to show a few colourful examples of it. Or maybe Knots is a a salad. The Latin for salad, “satura”, is sometimes thought the ancestor of “satire”. I’ve never been convinced by that one.</p>
<p>One person who did have a taste for abstraction was Early Wittgenstein. At the end of his Tractatus he famously says, “whereof we cannot speak, thereof we must be silent.”</p>
<p>(I really don’t know what Laing was after with “logico-mathematical”.)</p>
<p>Whereas big on archaisms, Late Wittgenstein got especially big on “shewing”. Shewing is something that you can do in silence, instead of speaking. The problem is roughly that there are certain things — thing that don’t exist, generally speaking — that can’t be talked about without missing the mark. This resulted in a very great number of little notes which were arranged into books after his death like pressed flowers.</p>
<p>The Wittgensteins are the most important philosophers of the Twentieth century.</p>
<p>A lot of Perec’s pieces don’t really have a proper ending.</p>


</section>

 ]]></description>
  <category>review</category>
  <category>perec</category>
  <category>wittgenstein</category>
  <guid>https://joehalliwell.com/posts/holiday-books/</guid>
  <pubDate>Tue, 13 Jul 2010 23:00:00 GMT</pubDate>
  <media:content url="https://joehalliwell.com/posts/holiday-books/great-mosque-of-kairouan-postcard.png" medium="image" type="image/png" height="227" width="144"/>
</item>
</channel>
</rss>
