hung-phan/ml-skills/evaluation-patterns

Claude Code and agent skill by hung-phan/ml-skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Test case and evaluation harness design for DSPy optimization. Use when constructing dspy.Example datasets, designing LLM-as-judge metrics, or structuring train/val splits.

Install

npx vskill@latest install hung-phan/ml-skills/evaluation-patterns

SKILL.md

The same SKILL.md was published earlier as hung-phan/ml-skills/evaluation-patterns.

Evaluation Patterns

Why This Exists

Problem: Knowing whether your DSPy program improved after optimization requires evaluating on a held-out devset with the right metric — without this you're flying blind and may be overfit to the trainset or regressed on edge cases.

Key insight: dspy.Example separates what the module receives (inputs) from what the metric compares against (gold labels) using with_inputs(), making it the atomic unit for both training and evaluation.

Reach for this when: You need to construct a trainset or devset for DSPy, design an LLM-as-judge metric, or run a before/after comparison to validate an optimizer's effect.

Evaluation Approach Comparison

ApproachMetric typeCostWhen to use
Exact match / token F1bool or floatCheapFactoid QA, entity extraction
Rule-based compositefloatCheapFormat + content checks
LLM-as-judgefloatMediumOpen-ended generation, semantic quality
Multi-dimensional LLM judgePrediction(score, feedback)MediumGEPA optimization

dspy.Example Construction

python
example = dspy.Example(
query="Play something like Radiohead",
context="User wants music similar to Radiohead's style",
).with_inputs("query") # fields in with_inputs() = module input; rest = gold labels

Key rule: with_inputs() separates what the module sees (input) from what metrics compare against (gold).

Test Case Taxonomy

Single-turn
python
dspy.Example(query="Play Taylor Swift", context="Explicit artist request").with_inputs("query")
Multi-turn
python
dspy.Example(
query="play more like this",
history="Now playing: 'Blinding Lights' by The Weeknd",
context="Wants similar synth-pop continuation",
).with_inputs("query", "history")
Edge cases
python
# Misspelling
dspy.Example(query="play biyonsay", context="Beyoncé request (misspelled)").with_inputs("query")
# Negation
dspy.Example(query="anything but country", context="Exclude country genre").with_inputs("query")
# Vague
dspy.Example(query="play something good", context="No preference, use history").with_inputs("query")

LLM-as-Judge Pattern

python
class JudgeSignature(dspy.Signature):
gold_context: str = dspy.InputField()
predicted_context: str = dspy.InputField()
reasoning: str = dspy.OutputField()
score: int = dspy.OutputField(desc="1-10")
def metric(example, pred, trace=None):
result = dspy.ChainOfThought(JudgeSignature)(
gold_context=example.context, predicted_context=pred.context
)
score = float(result.score) / 10.0
if trace is not None:
return score >= 0.7
return score

Multi-Dimensional Scoring

python
def metric(example, pred, trace=None):
score = (
0.4 * intent_accuracy(example, pred) +
0.3 * completeness(example, pred) +
0.2 * specificity(pred) +
0.1 * conciseness(pred)
) / 10.0
return score >= 0.6 if trace else score

Evaluate Harness

python
evaluator = dspy.Evaluate(devset=valset, metric=metric, num_threads=8, failure_score=0.0)
result = evaluator(program) # returns dspy.EvaluationResult
score = result.score # float percentage, e.g. 67.30; result.results is list of (example, prediction, score) tuples

Gotchas

  • Minimum 6-8 examples for MIPROv2 — fewer and bootstrapping fails
  • 20 diverse cases > 50 similar cases
  • Gold context should be concise — judges compare semantics not wording
  • Use a stronger model as judge than the target model
  • with_inputs() is required — without it DSPy doesn't know input vs gold

References

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/hung-phan/ml-skills/evaluation-patterns/badge)](https://verified-skill.com/skills/hung-phan/ml-skills/evaluation-patterns)

Something wrong with this skill or its page? Tell us.