Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Evaluate LLM systems using automated metrics, LLM-as-judge, and benchmarks. Use when testing prompt quality, validating RAG pipelines, measuring safety (hallucinations, bias), or comparing models for production deployment.
.claude/skills/ancoleman-evaluating-llms/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 181% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 159% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 193% | 0% |
| case-16 | ✗→✓ | ▲ Improved | 158% | 0% |
| case-06 | ✓→✓ | = Same ✓ | 246% | 0% |
Evaluate Large Language Model (LLM) systems using automated metrics, LLM-as-judge patterns, and standardized benchmarks to ensure production quality and safety.
Apply this skill when:
Common triggers:
By Task Type:
| Task Type | Primary Approach | Metrics | Tools | |-----------|------------------|---------|-------| | Classification (sentiment, intent) | Automated metrics | Accuracy, Precision, Recall, F1 | scikit-learn | | Generation (summaries, creative text) | LLM-as-judge + automated | BLEU, ROUGE, BERTScore, Quality rubric | GPT-4/Claude for judging | | Question Answering | Exact match + semantic similarity | EM, F1, Cosine similarity | Custom evaluators | | RAG Systems | RAGAS framework | Faithfulness, Answer/Context relevance | RAGAS library | | Code Generation | Unit tests + execution | Pass@K, Test pass rate | HumanEval, pytest | | Multi-step Agents | Task completion + tool accuracy | Success rate, Efficiency | Custom evaluators |
By Volume and Cost:
| Samples | Speed | Cost | Recommended Approach | |---------|-------|------|---------------------| | 1,000+ | Immediate | $0 | Automated metrics (regex, JSON validation) | | 100-1,000 | Minutes | $0.01-0.10 each | LLM-as-judge (GPT-4, Claude) | | < 100 | Hours | $1-10 each | Human evaluation (pairwise comparison) |
Layered Approach (Recommended for Production):
Test single prompt-response pairs for correctness.
Methods:
Example Use Cases:
Quick Start (Python):
pythonimport pytest from openai import OpenAI client = OpenAI() def classify_sentiment(text: str) -> str: response = client.chat.completions.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "Classify sentiment as positive, negative, or neutral. Return only the label."}, {"role": "user", "content": text} ], temperature=0 ) return response.choices[0].message.content.strip().lower() def test_positive_sentiment(): result = classify_sentiment("I love this product!") assert result == "positive"
For complete unit evaluation examples, see examples/python/unit_evaluation.py and examples/typescript/unit-evaluation.ts.
Evaluate RAG systems using RAGAS framework metrics.
Critical Metrics (Priority Order):
Quick Start (Python with RAGAS):
pythonfrom ragas import evaluate from ragas.metrics import faithfulness, answer_relevancy, context_relevancy from datasets import Dataset data = { "question": ["What is the capital of France?"], "answer": ["The capital of France is Paris."], "contexts": [["Paris is the capital of France."]], "ground_truth": ["Paris"] } dataset = Dataset.from_dict(data) results = evaluate(dataset, metrics=[faithfulness, answer_relevancy, context_relevancy]) print(f"Faithfulness: {results['faithfulness']:.2f}")
For comprehensive RAG evaluation patterns, see references/rag-evaluation.md and examples/python/ragas_example.py.
Use powerful LLMs (GPT-4, Claude Opus) to evaluate other LLM outputs.
When to Use:
Correlation with Human Judgment: 0.75-0.85 for well-designed rubrics
Best Practices:
Quick Start (Python):
pythonfrom openai import OpenAI client = OpenAI() def evaluate_quality(prompt: str, response: str) -> tuple[int, str]: """Returns (score 1-5, reasoning)""" eval_prompt = f""" Rate the following LLM response on relevance and helpfulness. USER PROMPT: {prompt} LLM RESPONSE: {response} Provide: Score: [1-5, where 5 is best] Reasoning: [1-2 sentences] """ result = client.chat.completions.create( model="gpt-4", messages=[{"role": "user", "content": eval_prompt}], temperature=0.3 ) content = result.choices[0].message.content lines = content.strip().split('\n') score = int(lines[0].split(':')[1].strip()) reasoning = lines[1].split(':', 1)[1].strip() return score, reasoning
For detailed LLM-as-judge patterns and prompt templates, see references/llm-as-judge.md and examples/python/llm_as_judge.py.
Measure hallucinations, bias, and toxicity in LLM outputs.
Methods:
Types of Bias:
Evaluation Methods:
Tools:
For comprehensive safety evaluation patterns, see references/safety-evaluation.md.
Assess model capabilities using standardized benchmarks.
Standard Benchmarks:
| Benchmark | Coverage | Format | Difficulty | Use Case | |-----------|----------|--------|------------|----------| | MMLU | 57 subjects (STEM, humanities) | Multiple choice | High school - professional | General intelligence | | HellaSwag | Sentence completion | Multiple choice | Common sense | Reasoning validation | | GPQA | PhD-level science | Multiple choice | Very high (expert-level) | Frontier model testing | | HumanEval | 164 Python problems | Code generation | Medium | Code capability | | MATH | 12,500 competition problems | Math solving | High school competitions | Math reasoning |
Domain-Specific Benchmarks:
When to Use Benchmarks:
Quick Start (lm-evaluation-harness):
bashpip install lm-eval # Evaluate GPT-4 on MMLU lm_eval --model openai-chat --model_args model=gpt-4 --tasks mmlu --num_fewshot 5
For detailed benchmark testing patterns, see references/benchmarks.md and scripts/benchmark_runner.py.
Monitor and optimize LLM quality in production environments.
Compare two LLM configurations:
Metrics:
Real-time quality monitoring:
Sample-based human evaluation:
For production evaluation patterns and monitoring strategies, see references/production-evaluation.md.
For tasks with discrete outputs (sentiment, intent, category).
Metrics:
Quick Start (Python):
pythonfrom sklearn.metrics import accuracy_score, precision_recall_fscore_support y_true = ["positive", "negative", "neutral", "positive", "negative"] y_pred = ["positive", "negative", "neutral", "neutral", "negative"] accuracy = accuracy_score(y_true, y_pred) precision, recall, f1, _ = precision_recall_fscore_support(y_true, y_pred, average='weighted') print(f"Accuracy: {accuracy:.2f}") print(f"Precision: {precision:.2f}") print(f"Recall: {recall:.2f}") print(f"F1 Score: {f1:.2f}")
For complete classification evaluation examples, see examples/python/classification_metrics.py.
For open-ended text generation (summaries, creative writing, responses).
Automated Metrics (Use with Caution):
Limitation: Automated metrics correlate weakly with human judgment for creative/subjective generation.
Recommended Approach:
For detailed generation evaluation patterns, see references/evaluation-types.md.
| If Task Is... | Use This Framework | Primary Metric | |---------------|-------------------|----------------| | RAG system | RAGAS | Faithfulness > 0.8 | | Classification | scikit-learn metrics | Accuracy, F1 | | Generation quality | LLM-as-judge | Quality rubric (1-5) | | Code generation | HumanEval | Pass@1, Test pass rate | | Model comparison | Benchmark testing | MMLU, HellaSwag scores | | Safety validation | Hallucination detection | Faithfulness, Fact-check | | Production monitoring | Online evaluation | User feedback, Business KPIs |
| Library | Use Case | Installation | |---------|----------|--------------| | RAGAS | RAG evaluation | pip install ragas | | DeepEval | General LLM evaluation, pytest integration | pip install deepeval | | LangSmith | Production monitoring, A/B testing | pip install langsmith | | lm-eval | Benchmark testing (MMLU, HumanEval) | pip install lm-eval | | scikit-learn | Classification metrics | pip install scikit-learn |
| Application | Hallucination Risk | Bias Risk | Toxicity Risk | Evaluation Priority | |-------------|-------------------|-----------|---------------|---------------------| | Customer Support | High | Medium | High | 1. Faithfulness, 2. Toxicity, 3. Bias | | Medical Diagnosis | Critical | High | Low | 1. Factual Accuracy, 2. Hallucination, 3. Bias | | Creative Writing | Low | Medium | Medium | 1. Quality/Fluency, 2. Content Policy | | Code Generation | Medium | Low | Low | 1. Functional Correctness, 2. Security | | Content Moderation | Low | Critical | Critical | 1. Bias, 2. False Positives/Negatives |
For comprehensive documentation on specific topics:
references/evaluation-types.mdreferences/rag-evaluation.mdreferences/safety-evaluation.mdreferences/benchmarks.mdreferences/llm-as-judge.mdreferences/production-evaluation.mdreferences/metrics-reference.mdPython Examples:
examples/python/unit_evaluation.py - Basic prompt testing with pytestexamples/python/ragas_example.py - RAGAS RAG evaluationexamples/python/deepeval_example.py - DeepEval framework usageexamples/python/llm_as_judge.py - GPT-4 as evaluatorexamples/python/classification_metrics.py - Accuracy, precision, recallexamples/python/benchmark_testing.py - HumanEval exampleTypeScript Examples:
examples/typescript/unit-evaluation.ts - Vitest + OpenAIexamples/typescript/llm-as-judge.ts - GPT-4 evaluationexamples/typescript/langsmith-integration.ts - Production monitoringRun evaluations without loading code into context (token-free):
scripts/run_ragas_eval.py - Run RAGAS evaluation on datasetscripts/compare_models.py - A/B test two modelsscripts/benchmark_runner.py - Run MMLU/HumanEval benchmarksscripts/hallucination_checker.py - Detect hallucinations in outputsExample usage:
bash# Run RAGAS evaluation on custom dataset python scripts/run_ragas_eval.py --dataset data/qa_dataset.json --output results.json # Compare GPT-4 vs Claude on benchmark python scripts/compare_models.py --model-a gpt-4 --model-b claude-3-opus --tasks mmlu,humaneval
Related Skills:
building-ai-chat: Evaluate AI chat applications (this skill tests what that skill builds)prompt-engineering: Test prompt quality and effectivenesstesting-strategies: Apply testing pyramid to LLM evaluation (unit → integration → E2E)observability: Production monitoring and alerting for LLM qualitybuilding-ci-pipelines: Integrate LLM evaluation into CI/CDWorkflow Integration:
prompt-engineering skill)llm-evaluation skill)building-ai-chat skill)llm-evaluation skill)deploying-applications skill)llm-evaluation + observability skills)1. Over-reliance on Automated Metrics for Generation
2. Ignoring Faithfulness in RAG Systems
3. No Production Monitoring
4. Biased LLM-as-Judge Evaluation
5. Insufficient Benchmark Coverage
6. Missing Safety Evaluation
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 21,980 | 20,970 | -5% | 1 | 1 | 0% | 3,163 | 8,371 | +165% | 0 | 0 | — |
case-02 | fail→pass | 13,404 | 6,859 | -49% | 1 | 1 | 0% | 2,069 | 5,809 | +181% | 0 | 0 | — |
case-03 | fail→fail | 16,336 | 11,403 | -30% | 1 | 1 | 0% | 2,393 | 6,457 | +170% | 0 | 0 | — |
case-04 | fail→pass | 14,588 | 7,284 | -50% | 1 | 1 | 0% | 2,237 | 5,803 | +159% | 0 | 0 | — |
case-05 | fail→fail | 16,567 | 15,996 | -3% | 1 | 1 | 0% | 2,613 | 7,312 | +180% | 0 | 0 | — |
case-06 | pass→pass | 9,970 | 7,345 | -26% | 1 | 1 | 0% | 1,751 | 6,056 | +246% | 0 | 0 | — |
case-07 | fail→pass | 13,121 | 9,935 | -24% | 1 | 1 | 0% | 2,176 | 6,373 | +193% | 0 | 0 | — |
case-08 | pass→pass | 11,414 | 8,490 | -26% | 1 | 1 | 0% | 1,752 | 6,175 | +252% | 0 | 0 | — |
case-09 | pass→pass | 26,725 | 10,460 | -61% | 1 | 1 | 0% | 2,384 | 6,373 | +167% | 0 | 0 | — |
case-10 | pass→pass | 6,504 | 5,675 | -13% | 1 | 1 | 0% | 926 | 5,536 | +498% | 0 | 0 | — |
case-11 | pass→pass | 4,360 | 4,896 | +12% | 1 | 1 | 0% | 648 | 5,527 | +753% | 0 | 0 | — |
case-12 | pass→pass | 11,570 | 7,349 | -36% | 1 | 1 | 0% | 2,042 | 5,967 | +192% | 0 | 0 | — |
case-13 | pass→pass | 12,944 | 12,877 | -1% | 1 | 1 | 0% | 2,162 | 7,063 | +227% | 0 | 0 | — |
case-14 | pass→pass | 12,836 | 7,557 | -41% | 1 | 1 | 0% | 2,137 | 5,930 | +177% | 0 | 0 | — |
case-15 | pass→pass | 10,546 | 11,125 | +5% | 1 | 1 | 0% | 1,584 | 6,603 | +317% | 0 | 0 | — |
case-16 | fail→pass | 14,898 | 8,325 | -44% | 1 | 1 | 0% | 2,343 | 6,034 | +158% | 0 | 0 | — |
case-17 | pass→pass | 16,194 | 13,559 | -16% | 1 | 1 | 0% | 2,610 | 6,891 | +164% | 0 | 0 | — |
case-18 | pass→pass | 21,758 | 22,074 | +1% | 1 | 1 | 0% | 3,258 | 8,717 | +168% | 0 | 0 | — |
case-19 | pass→pass | 13,161 | 8,441 | -36% | 1 | 1 | 0% | 1,989 | 6,079 | +206% | 0 | 0 | — |
case-20 | fail→fail | 23,243 | 19,242 | -17% | 1 | 1 | 0% | 4,436 | 8,548 | +93% | 0 | 0 | — |
case-21 | fail→fail | 17,805 | 15,224 | -14% | 1 | 1 | 0% | 3,601 | 7,560 | +110% | 0 | 0 | — |
case-22 | fail→fail | 20,619 | 18,992 | -8% | 1 | 1 | 0% | 4,162 | 8,601 | +107% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +18 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.