<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sumeet Lalla</title>
    <description>The latest articles on DEV Community by Sumeet Lalla (@sumeet_lalla_6f9e32437132).</description>
    <link>https://dev.to/sumeet_lalla_6f9e32437132</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3947203%2Fe789a52e-9092-41e8-bb4d-1e948b743908.png</url>
      <title>DEV Community: Sumeet Lalla</title>
      <link>https://dev.to/sumeet_lalla_6f9e32437132</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sumeet_lalla_6f9e32437132"/>
    <language>en</language>
    <item>
      <title>Day 1: I'm Done Writing Prompts by Hand — Meet DSPy</title>
      <dc:creator>Sumeet Lalla</dc:creator>
      <pubDate>Sat, 23 May 2026 06:39:57 +0000</pubDate>
      <link>https://dev.to/sumeet_lalla_6f9e32437132/day-1-im-done-writing-prompts-by-hand-meet-dspy-gha</link>
      <guid>https://dev.to/sumeet_lalla_6f9e32437132/day-1-im-done-writing-prompts-by-hand-meet-dspy-gha</guid>
      <description>&lt;p&gt;Let me paint you a picture that probably feels familiar.&lt;/p&gt;

&lt;p&gt;You spend 45 minutes crafting the &lt;em&gt;perfect&lt;/em&gt; prompt. You test it. It works. You ship it. Two days later your colleague tries it with slightly different input and... it falls apart completely. So you're back at it — tweaking a word here, rearranging a sentence there, re-testing, repeat.&lt;/p&gt;

&lt;p&gt;Sound familiar? I've been there more times than I'd like to admit. And it turns out there's a name for this exhausting loop: &lt;strong&gt;prompt engineering&lt;/strong&gt;. More importantly, there's now a smarter way to escape it.&lt;/p&gt;

&lt;p&gt;I'm kicking off a series where I read and share insights from &lt;strong&gt;&lt;a href="https://www.manning.com/books/building-llm-applications-with-dspy" rel="noopener noreferrer"&gt;Building LLM Applications with DSPy&lt;/a&gt;&lt;/strong&gt; by &lt;em&gt;Serj Smorodinsky and William Brett Kennedy&lt;/em&gt; (Manning Publications, MEAP V01, 2026). One chapter a day, straight to the point. Let's get into Day 1.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Problem with Prompt Engineering (Be Honest, You Know It)
&lt;/h2&gt;

&lt;p&gt;Prompt engineering is essentially &lt;em&gt;trial and error dressed up as a skill&lt;/em&gt;. You're manually rephrasing the same instruction hoping the LLM eventually "gets it." The authors describe it well — even prompts that &lt;em&gt;seem equivalent&lt;/em&gt; can produce wildly different results, and once your prompts grow to dozens of lines, you lose track of &lt;em&gt;why&lt;/em&gt; each phrase is even there.&lt;/p&gt;

&lt;p&gt;Here's what makes this particularly painful in production systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every time you switch LLMs (GPT-4 → Claude → Gemini), you start over&lt;/li&gt;
&lt;li&gt;You can't easily track &lt;em&gt;which&lt;/em&gt; prompt variant performed best&lt;/li&gt;
&lt;li&gt;Complex apps with multiple LLM calls compound errors fast — one bad prompt poisons the whole pipeline&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Enter DSPy: Prompt &lt;em&gt;Programming&lt;/em&gt;, Not Prompt &lt;em&gt;Engineering&lt;/em&gt;
&lt;/h2&gt;

&lt;p&gt;DSPy (short for &lt;strong&gt;Declarative Self-improving Python&lt;/strong&gt;, pronounced &lt;em&gt;dee-ess-pie&lt;/em&gt;) flips the script. Instead of writing prompts, you write &lt;strong&gt;code that describes what you want&lt;/strong&gt;. DSPy handles generating, evaluating, and optimizing the actual prompts automatically.&lt;/p&gt;

&lt;p&gt;The book frames this as a natural evolution — similar to how we no longer hand-write assembly code when building apps in Python. We work at the right level of abstraction. Prompt programming is that next level for LLM apps.&lt;/p&gt;

&lt;p&gt;Here's what that looks like in practice:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;dspy&lt;/span&gt;

&lt;span class="n"&gt;lm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dspy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;LM&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;openai/gpt-4o-mini&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;api_key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;OPENAI_API_KEY&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;dspy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;settings&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;lm&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;lm&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="n"&gt;predictor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;dspy&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Predict&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;question, context -&amp;gt; answer, confidence&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;prediction&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;predictor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;question&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;What is the capital of France?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="sh"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;answer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;prediction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;confidence&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No prompt string in sight. You declare &lt;em&gt;what&lt;/em&gt; you want (a question answered with a confidence score), and DSPy figures out &lt;em&gt;how&lt;/em&gt; to ask the LLM for it. Clean, readable, testable.&lt;/p&gt;




&lt;h2&gt;
  
  
  What DSPy Actually Does Under the Hood
&lt;/h2&gt;

&lt;p&gt;This is the part I found genuinely impressive. DSPy doesn't just wrap your LLM call — it &lt;strong&gt;optimizes&lt;/strong&gt; your prompts systematically. Given a task and some evaluation criteria, it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Generates many candidate prompts automatically&lt;/li&gt;
&lt;li&gt;Evaluates each one against your metric&lt;/li&gt;
&lt;li&gt;Uses techniques like hill climbing, genetic algorithms, and Bayesian optimization to find the best performer&lt;/li&gt;
&lt;li&gt;Iterates until it converges on something strong&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The authors note that experiments pitting DSPy against &lt;em&gt;professional prompt engineers&lt;/em&gt; found DSPy produced stronger prompts in &lt;em&gt;less time&lt;/em&gt;. That's not a small claim.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Recommended Dev Workflow
&lt;/h2&gt;

&lt;p&gt;The book lays out a clean three-step process:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Baseline → Evaluate → Optimize&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You start by building a simple working version of your app. Then you evaluate it rigorously (DSPy gives you the tools for this). Then you let DSPy optimize the prompts across your full pipeline — not just one call, but &lt;em&gt;all of them together&lt;/em&gt;, tuned for the best combined outcome.&lt;/p&gt;

&lt;p&gt;This matters a lot in agentic systems, where LLM calls chain together and one weak prompt cascades into a messy failure downstream.&lt;/p&gt;




&lt;h2&gt;
  
  
  When Should You Actually Use DSPy?
&lt;/h2&gt;

&lt;p&gt;DSPy shines when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You have &lt;strong&gt;complex prompts&lt;/strong&gt; or &lt;strong&gt;multiple LLM calls&lt;/strong&gt; in a pipeline&lt;/li&gt;
&lt;li&gt;You need prompts to be reliable and production-grade&lt;/li&gt;
&lt;li&gt;You're experimenting with different LLMs and don't want to rewrite everything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For casual, one-off LLM interactions? Direct prompting is probably fine. DSPy has a learning curve — it's a framework, not a magic wand. But once you're past the basics, the payoff is real.&lt;/p&gt;




&lt;h2&gt;
  
  
  My Takeaway from Chapter 1
&lt;/h2&gt;

&lt;p&gt;What struck me most isn't the automation — it's the &lt;strong&gt;mindset shift&lt;/strong&gt;. Prompt engineering is fundamentally reactive: you write something, see what breaks, fix it. Prompt programming is systematic: you define what "good" means, and the framework finds the path there.&lt;/p&gt;

&lt;p&gt;As someone who builds production AI systems, that distinction matters enormously. Less time debugging prompts means more time shipping features.&lt;/p&gt;




&lt;h2&gt;
  
  
  What's Next
&lt;/h2&gt;

&lt;p&gt;Tomorrow I'm covering &lt;strong&gt;Chapter 2: Basic Prompting and DSPy&lt;/strong&gt; — where we get into the actual anatomy of a well-formed prompt and build our first real DSPy application. If you've ever wondered what goes into those multi-section prompt templates, that chapter breaks it down nicely.&lt;/p&gt;




&lt;p&gt;📚 &lt;strong&gt;Source:&lt;/strong&gt; &lt;em&gt;Building LLM Applications with DSPy&lt;/em&gt; by Serj Smorodinsky and William Brett Kennedy — Manning Publications, MEAP V01, 2026. &lt;a href="https://www.manning.com/books/building-llm-applications-with-dspy" rel="noopener noreferrer"&gt;manning.com/books/building-llm-applications-with-dspy&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;All concepts, examples, and code snippets referenced in this post are drawn from the book above. This series is a reader's journal, not a reproduction — pick up the book for the full depth.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;Are you still hand-writing your prompts? Drop a comment — I'm curious how many of you have tried DSPy already and what your experience was like.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>dspy</category>
      <category>ai</category>
      <category>llm</category>
      <category>python</category>
    </item>
  </channel>
</rss>
