<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: dspy</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/dspy.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2026-07-02T18:25:00+00:00</updated><author><name>Simon Willison</name></author><entry><title>Using DSPy to evaluate and improve Datasette Agent's SQL system prompts</title><link href="https://simonwillison.net/2026/Jul/2/dspy-datasette-agent-prompts/" rel="alternate"/><published>2026-07-02T18:25:00+00:00</published><updated>2026-07-02T18:25:00+00:00</updated><id>https://simonwillison.net/2026/Jul/2/dspy-datasette-agent-prompts/</id><summary type="html">
    
        &lt;p&gt;&lt;strong&gt;Research:&lt;/strong&gt; &lt;a href="https://github.com/simonw/research/tree/main/dspy-datasette-agent-prompts#readme"&gt;Using DSPy to evaluate and improve Datasette Agent&amp;#x27;s SQL system prompts&lt;/a&gt;&lt;/p&gt;
        &lt;p&gt;One of this morning's AIE keynotes covered &lt;a href="https://github.com/stanfordnlp/dspy"&gt;dspy&lt;/a&gt;, which reminded me I've been meaning to see if it could help me improve the system prompt used by &lt;a href="https://agent.datasette.io"&gt;Datasette Agent&lt;/a&gt; - so I fired off an asynchronous research task in Claude Code for web using Claude Fable 5:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;Pip install the latest Datasette alpha and datasette-agent and dspy - then figure out how to use dspy to evaluate and improve the main system prompts used by Datasette Agent for the feature where it can execute read only SQL queries to answer user questions about data.&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Fable chose to test using GPT 4.1 mini and nano, and identified several promising looking directions for improvements. I particularly like this one:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The schema listing gives only table names; the "don't call describe_table if you already have the information" advice caused column-name guessing (page_count, o.order_id, first_name) and error-retry loops in baseline traces. Either include column names in the prompt's schema listing or soften that advice.&lt;/p&gt;
&lt;/blockquote&gt;
    
    
        &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/datasette"&gt;datasette&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/evals"&gt;evals&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dspy"&gt;dspy&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/datasette-agent"&gt;datasette-agent&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/claude-mythos-fable"&gt;claude-mythos-fable&lt;/a&gt;&lt;/p&gt;
    

</summary><category term="ai"/><category term="datasette"/><category term="generative-ai"/><category term="llms"/><category term="evals"/><category term="dspy"/><category term="datasette-agent"/><category term="claude-mythos-fable"/></entry><entry><title>Let the LLM Write the Prompts: An Intro to DSPy in Compound Al Pipelines</title><link href="https://simonwillison.net/2025/Oct/4/drew-on-dspy/" rel="alternate"/><published>2025-10-04T22:48:59+00:00</published><updated>2025-10-04T22:48:59+00:00</updated><id>https://simonwillison.net/2025/Oct/4/drew-on-dspy/</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://www.youtube.com/watch?v=I9ZtkgYZnOw"&gt;Let the LLM Write the Prompts: An Intro to DSPy in Compound Al Pipelines&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
I've had trouble getting my head around &lt;a href="https://dspy.ai"&gt;DSPy&lt;/a&gt; in the past. This half hour talk by Drew Breunig at the recent Databricks Data + AI Summit is the clearest explanation I've seen yet of the kinds of problems it can help solve.&lt;/p&gt;
&lt;p&gt;Here's Drew's &lt;a href="https://www.dbreunig.com/2025/06/10/let-the-model-write-the-prompt.html"&gt;written version of the talk&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Drew works on Overture Maps, which combines Point Of Interest data from numerous providers to create a single unified POI database. This is an example of &lt;strong&gt;conflation&lt;/strong&gt;, a notoriously difficult task in GIS where multiple datasets are deduped and merged together.&lt;/p&gt;
&lt;p&gt;Drew uses an inexpensive local model, &lt;a href="https://huggingface.co/Qwen/Qwen3-0.6B"&gt;Qwen3-0.6B&lt;/a&gt;, to compare 70 million addresses and identity matches, for example between &lt;code&gt;Place(address="3359 FOOTHILL BLVD", name="RESTAURANT LOS ARCOS")&lt;/code&gt; and &lt;code&gt;Place(address="3359 FOOTHILL BLVD", name="Los Arcos Taqueria"')&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;DSPy's role is to optimize the prompt used for that smaller model. Drew used GPT-4.1 and the &lt;a href="https://dspy.ai/api/optimizers/MIPROv2/"&gt;dspy.MIPROv2&lt;/a&gt; optimizer, producing a 700 token prompt that increased the score from 60.7% to 82%.&lt;/p&gt;
&lt;p&gt;&lt;img alt="Determine if two points of interest refer to the same place. Arrow to optimized prompt: Given two records representing places or businesses-each with at least a name and address-analyze the information and determine if they refer to the same real-world entity. Consider minor differences such as case, diacritics, transliteration, abbreviations, or formatting as potential matches if both the name and address are otherwise strongly similar. Only output &amp;quot;True&amp;quot; if both fields are a close match; if there are significant differences in either the name or address, even if one field matches exactly, output &amp;quot;False&amp;quot;. Your decision should be robust to common variations and errors and should work across multiple languages and scripts." src="https://static.simonwillison.net/static/2025/optimized-prompt.jpeg" /&gt;&lt;/p&gt;
&lt;p&gt;Why bother? Drew points out that having a prompt optimization pipeline makes it trivial to evaluate and switch to other models if they can score higher with a custom optimized prompt - without needing to execute that trial-and-error optimization by hand.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/geospatial"&gt;geospatial&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/prompt-engineering"&gt;prompt-engineering&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/drew-breunig"&gt;drew-breunig&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/overture"&gt;overture&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dspy"&gt;dspy&lt;/a&gt;&lt;/p&gt;



</summary><category term="geospatial"/><category term="ai"/><category term="prompt-engineering"/><category term="generative-ai"/><category term="llms"/><category term="drew-breunig"/><category term="overture"/><category term="dspy"/></entry><entry><title>AI Prompt Engineering Is Dead. Long live AI prompt engineering</title><link href="https://simonwillison.net/2024/Mar/20/prompt-engineering/" rel="alternate"/><published>2024-03-20T03:22:18+00:00</published><updated>2024-03-20T03:22:18+00:00</updated><id>https://simonwillison.net/2024/Mar/20/prompt-engineering/</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://spectrum.ieee.org/prompt-engineering-is-dead"&gt;AI Prompt Engineering Is Dead. Long live AI prompt engineering&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Ignoring the clickbait in the title, this article summarizes research around the idea of using machine learning models to optimize prompts—as seen in tools such as Stanford’s DSPy and Google’s OPRO.&lt;/p&gt;

&lt;p&gt;The article includes possibly the biggest abuse of the term “just” I have ever seen:&lt;/p&gt;

&lt;p&gt;“But that’s where hopefully this research will come in and say ‘don’t bother.’ Just develop a scoring metric so that the system itself can tell whether one prompt is better than another, and then just let the model optimize itself.”&lt;/p&gt;

&lt;p&gt;Developing a scoring metric to determine which prompt works better remains one of the hardest challenges in generative AI!&lt;/p&gt;

&lt;p&gt;Imagine if we had a discipline of engineers who could reliably solve that problem—who spent their time developing such metrics and then using them to optimize their prompts. If the term “prompt engineer” hadn’t already been reduced to basically meaning “someone who types out prompts” it would be a pretty fitting term for such experts.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/ai"&gt;ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/prompt-engineering"&gt;prompt-engineering&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/generative-ai"&gt;generative-ai&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/llms"&gt;llms&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/dspy"&gt;dspy&lt;/a&gt;&lt;/p&gt;



</summary><category term="ai"/><category term="prompt-engineering"/><category term="generative-ai"/><category term="llms"/><category term="dspy"/></entry></feed>