skills/dspy-predict/SKILL.md
Use when the mapping from input to output is straightforward and does not need reasoning steps — simple classification, extraction, formatting, or Q&A where minimal latency matters. Common scenarios - simple classification tasks, basic extraction, format conversion, straightforward Q&A, or any task that does not benefit from chain-of-thought reasoning — when you want the fastest possible LM call. Related - ai-sorting, ai-parsing-data, dspy-chain-of-thought. Also used for dspy.Predict, simplest DSPy module, basic LM call in DSPy, direct prediction no reasoning, when to use Predict vs ChainOfThought, fast classification with DSPy, minimal latency LM call, simple input-output mapping, Predict vs ChainOfThought, zero overhead DSPy call, straightforward text generation, quick extraction without reasoning, one-shot prediction, basic DSPy hello world.
npx skillsauth add lebsral/dspy-programming-not-prompting-lms-skills dspy-predictInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Guide the user through using dspy.Predict -- the simplest and fastest DSPy module for calling a language model. It takes inputs, calls the LM, and returns typed outputs. No intermediate reasoning, no extra steps.
dspy.Predict is the atomic building block of every DSPy program -- one LM call, no reasoning chain, no tool loops. It takes a signature and calls the LM once to produce the output fields. Every other DSPy module (ChainOfThought, ReAct, etc.) builds on top of it.
| Use dspy.Predict when... | Use dspy.ChainOfThought when... |
|---|---|
| The task is straightforward (classification, extraction, formatting) | The task benefits from step-by-step reasoning |
| You want minimal latency and token usage | Accuracy matters more than speed |
| The mapping from input to output is direct | The LM needs to "think through" intermediate steps |
| You're building a simple sub-step inside a larger pipeline | You need to inspect the model's reasoning |
Rule of thumb: Start with Predict. If accuracy is too low, switch to ChainOfThought -- it's a one-word change.
For complex structured outputs, use a Pydantic BaseModel as the output type:
import dspy
from pydantic import BaseModel
lm = dspy.LM("openai/gpt-4o-mini")
dspy.configure(lm=lm)
class ContactInfo(BaseModel):
name: str
email: str
phone: str
class ExtractContact(dspy.Signature):
"""Extract contact information from the text."""
text: str = dspy.InputField()
contact: ContactInfo = dspy.OutputField()
extractor = dspy.Predict(ExtractContact)
result = extractor(text="Reach out to Jane Doe at [email protected] or 555-0123")
print(result.contact.name) # Jane Doe
print(result.contact.email) # [email protected]
print(result.contact.phone) # 555-0123
For async calls, use acall or aforward:
result = await predict.acall(question="What is DSPy?")
For batch processing, use the built-in batch() method instead of a Python loop:
examples = [dspy.Example(question=q).with_inputs("question") for q in questions]
results = predict.batch(examples, num_threads=8, timeout=120)
Save and load optimized predictors:
predict.save("my_predictor.json")
predict.load("my_predictor.json")
Predict surprisingly powerful. Don't underestimate it.ChainOfThought before reaching for complex solutions -- it's a one-word swap (dspy.ChainOfThought instead of dspy.Predict) and often gets you 10-20% accuracy gains on reasoning-heavy tasks.predict.batch() rather than a Python loop -- it uses dspy.Parallel internally, handles concurrency, and is significantly faster for large batches.predict("my input") raises ValueError. Always use predict(question="my input").Install any skill:
npx skills add lebsral/DSPy-Programming-not-prompting-LMs-skills --skill <name>
/dspy-signatures/dspy-chain-of-thought/dspy-modules/ai-sorting/ai-do if you do not have it — it routes any AI problem to the right skill and is the fastest way to work: npx skills add lebsral/DSPy-Programming-not-prompting-LMs-skills --skill ai-dotools
See what is happening during optimizer.compile() instead of waiting blind. Use when you want to watch optimization progress, see scores as they come in, know if your optimizer is working, check if optimization is stuck, understand why optimization is taking too long, get live progress during compile, monitor convergence, detect overfitting during optimization, interpret optimization results, or pick the right tool for watching optimization. Also used for optimizer progress bar, is my optimizer doing anything, optimization seems stuck, how long will optimization take, watch GEPA run, watch MIPROv2 run, live optimization dashboard, optimizer not improving, scores not going up, optimization taking forever, see what optimizer is doing, debug slow optimization, optimization visibility, optimizer metrics, track compile progress, optimization observability.
testing
Use when you want the highest-quality prompt optimization DSPy offers — jointly optimizes instructions and few-shot demos, with auto=light/medium/heavy presets. Common scenarios - you want the best possible accuracy from prompt optimization, jointly tuning instructions and few-shot demonstrations, using auto presets for different compute budgets, or when COPRO or BootstrapFewShot alone are not reaching your accuracy target. Related - ai-improving-accuracy, dspy-copro, dspy-bootstrap-few-shot. Also used for dspy.MIPROv2, best DSPy optimizer, highest quality optimization, auto=light medium heavy, joint instruction and demo optimization, most powerful prompt optimizer, MIPROv2 vs COPRO vs BootstrapFewShot, which optimizer should I use, state of the art prompt optimization, when to use MIPROv2, optimize both instructions and examples, heavy optimization for production, best optimizer for accuracy.
testing
Use LangWatch for DSPy auto-tracing and real-time optimizer progress. Use when you want to set up LangWatch, langwatch.dspy.init, auto-tracing DSPy, real-time optimization dashboard, optimizer progress tracking, app.langwatch.ai, or DSPy optimizer dashboard. Also used for langwatch setup, pip install langwatch, langwatch trace, optimizer progress, real-time optimization, watch optimizer run, LangWatch self-hosted, langwatch docker, langwatch vs langtrace, langwatch autotrack_dspy.
data-ai
Use when you want to optimize instructions without few-shot examples — a lightweight alternative to COPRO when you do not have or do not want to use demonstrations. Common scenarios - optimizing instructions when you do not have or do not want to use few-shot demonstrations, lightweight instruction search as a first step, tasks where examples in the prompt confuse the model, or when you want fast instruction optimization without the cost of COPRO. Related - ai-improving-accuracy, dspy-copro, dspy-miprov2. Also used for dspy.GEPA, instruction optimization without demos, lightweight prompt optimization, optimize instructions only, no few-shot examples needed, GEPA vs COPRO, quick instruction search, when demonstrations hurt performance, zero-shot optimization, instruction-only optimizer, simplest instruction tuner, fast prompt optimization, skip few-shot and just tune instructions, optimize Pydantic field descriptions, GEPA structured output, GEPA does not optimize field desc.