agentleFS
sagullapallisagullapalli/claude-code-setup/.claude/skills/llm-evaluation/SKILL.md

LLM Evaluation Patterns

Skill4 starsChanged 10 months agoMITView on GitHub

Testing and evaluation patterns for LLM applications using DeepEval and RAGAS. Use for formal evaluation before deployment, after prompt changes, or model updates.

  • Reads credentials
  • Installs packages

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Rule: Start low, increase as system matures.

    line 149
  2. Very specific:

    Default: gpt-4 for evaluation (most accurate, most expensive)

    line 158
  3. Distinctive:

    Run multiple times for stability checks

    line 181
  4. Very specific:

    Use include_reason=True to understand scoring

    line 182

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

LLM Evaluation Patterns - Quick Reference

Principle: "Eyeballing outputs is ending" - formal evaluation is required for production AI.

Package: pip install -U deepeval


Modules

  1. 01-deepeval-setup.md - Installation & Integration
    • Installation and environment setup
    • pytest integration patterns
    • Test organization conventions
  2. 02-metrics-guide.md - Metric Selection
    • Metric selection by use case
    • Built-in vs custom metrics (GEval)
    • Threshold tuning guidelines
  3. 03-rag-evaluation.md - RAG Evaluation (DeepEval)
    • Retrieval metrics (precision, recall, relevancy)
    • Generation metrics (faithfulness, answer relevancy)
    • End-to-end RAG pipeline evaluation
  4. 04-ragas-rag-evaluation.md - RAGAS Framework
    • Reference-free RAG evaluation
    • RAGAS vs DeepEval decision guide
    • Vertex AI integration patterns
  5. 05-vertex-ai-evaluation.md - Vertex AI Gen AI Evaluation
    • GCP-native evaluation service
    • Adaptive rubrics (auto-generated criteria)
    • Agent trajectory evaluation (tool sequence analysis)
    • Pairwise model comparison

When to Evaluate

TriggerWhat to Evaluate
Before deploymentFull test suite (all metrics)
After prompt changesAffected metrics only
After model updatesRegression tests + key metrics
After RAG pipeline changesRetrieval + faithfulness metrics

Evaluation vs Unit Testing

AspectUnit TestingLLM Evaluation
PurposeCode correctnessOutput quality
DeterminismDeterministicNon-deterministic
SpeedFast (ms)Slow (seconds per test)
CostFreeLLM-as-judge costs
AssertionsExact matchSemantic scoring

Key Insight: LLM evaluation complements unit tests - both are needed.


Quick Start Pattern

from deepeval import evaluate
from deepeval.metrics import AnswerRelevancyMetric
from deepeval.test_case import LLMTestCase

# 1. Create test case
test_case = LLMTestCase(
    input="What is the return policy?",
    actual_output="We offer a 30-day full refund.",
    retrieval_context=["30 day full refund at no extra cost."]
)

# 2. Define metric with threshold
metric = AnswerRelevancyMetric(threshold=0.7)

# 3. Evaluate
evaluate([test_case], [metric])

For pytest integration, see 01-deepeval-setup.md.


Metric Quick Reference

Use CasePrimary MetricsFramework
General Q&AAnswerRelevancy, Correctness (GEval)DeepEval
RAG ApplicationsFaithfulness, ContextualPrecision, ContextualRecallDeepEval or RAGAS
RAG (reference-free)Faithfulness, ResponseRelevancy, LLMContextPrecisionRAGAS
ChatbotsConversationalGEval, RoleAdherenceDeepEval
Factual TasksHallucination, CorrectnessDeepEval
Safety/ComplianceBias, Toxicity, PIILeakageDeepEval

For detailed metric selection, see 02-metrics-guide.md. For RAGAS vs DeepEval decision, see 04-ragas-rag-evaluation.md.


Project Conventions

Test Organization

tests/
  evals/                    # LLM evaluations (separate from unit tests)
    test_rag_quality.py     # RAG pipeline evaluations
    test_chatbot_evals.py   # Chatbot evaluations
    conftest.py             # Shared fixtures, datasets
  unit/                     # Fast unit tests
  integration/              # Integration tests

Naming Convention

# Pattern: test_[feature]_[metric]_[scenario]
def test_rag_faithfulness_with_context():
    ...

def test_chatbot_relevancy_simple_query():
    ...

Thresholds

Metric TypeDevelopmentStagingProduction
Relevancy0.50.60.7
Faithfulness0.60.70.8
Precision/Recall0.50.60.7

Rule: Start low, increase as system matures.


Common Gotchas

1. LLM-as-Judge Costs

DeepEval uses LLMs to evaluate LLM outputs. Each metric = API call.

  • Set OPENAI_API_KEY or configure custom model
  • Default: gpt-4 for evaluation (most accurate, most expensive)
  • Cost-saving: Use gpt-4o-mini for development

2. Async Handling

DeepEval runs async internally. If using in async code:

# Standalone (not pytest)
import asyncio
asyncio.run(evaluate([test_case], [metric]))

3. Test Data Preparation

retrieval_context must be a list of strings, not dict:

# Wrong
retrieval_context={"doc1": "content"}

# Right
retrieval_context=["Document 1 content", "Document 2 content"]

4. Non-Deterministic Scores

Same input can produce different scores (LLM variance).

  • Run multiple times for stability checks
  • Use include_reason=True to understand scoring

Context7 Lookup

For current API syntax:

get-library-docs: /confident-ai/deepeval (topic: "metrics AnswerRelevancy")
get-library-docs: /confident-ai/deepeval (topic: "GEval custom metrics")
get-library-docs: /confident-ai/deepeval (topic: "synthesizer test data")

Cross-References

  • AI/LLM Testing: .claude/skills/testing-strategy/08-ai-llm-testing.md (semantic assertions)
  • pytest patterns: .claude/skills/testing-strategy/02-unit-testing.md
  • CI/CD integration: .claude/skills/testing-strategy/11-ci-cd-integration.md

Last Updated: 2025-12-26

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.