Prompt Evaluation Quickstart
Evaluates and compares prompt variations for sentiment classification using a RAGAS quickstart template.
What this file does
Evaluates and compares prompt variations for sentiment classification using a RAGAS quickstart template.
When to use it
- Compare different prompt phrasings for sentiment analysis
- Set up a reproducible prompt evaluation pipeline
- Add custom metrics like confidence scoring to prompt tests
- Learn RAGAS evaluation workflow with a minimal example
Assumes this stack
Prompt Evaluation Quickstart
The prompt_evals template evaluates and compares different prompt variations with sentiment analysis.
Create the Project
ragas quickstart prompt_evals
cd prompt_evals
Install Dependencies
uv sync
Set Your API Key
export OPENAI_API_KEY="your-openai-key"
Run the Evaluation
uv run python evals.py
Project Structure
prompt_evals/
├── README.md # Project documentation
├── pyproject.toml # Project configuration
├── prompt.py # Prompt implementation
├── evals.py # Evaluation workflow
├── __init__.py # Python package marker
└── evals/
├── datasets/ # Test datasets
├── experiments/ # Evaluation results
└── logs/ # Execution logs
What It Evaluates
The template evaluates prompt effectiveness for sentiment classification:
- Task: Sentiment analysis (positive/negative)
- Test Cases: Movie reviews with expected sentiment labels
- Metric: Binary accuracy (pass/fail)
Understanding the Code
The Prompt (prompt.py)
Implements the sentiment analysis prompt:
from prompt import run_prompt
sentiment = run_prompt("I loved the movie! It was fantastic.")
# Returns: "positive" or "negative"
The Evaluation (evals.py)
Tests prompt accuracy:
@discrete_metric(name="accuracy", allowed_values=["pass", "fail"])
def my_metric(prediction: str, actual: str):
return (
MetricResult(value="pass", reason="")
if prediction == actual
else MetricResult(value="fail", reason="")
)
Test Data
The dataset includes movie reviews:
dataset_dict = [
{"text": "I loved the movie! It was fantastic.", "label": "positive"},
{"text": "The movie was terrible and boring.", "label": "negative"},
# More examples...
]
Customization
Test Different Prompts
Modify prompt.py to test variations:
# Version 1: Simple
prompt = f"Is this positive or negative: {text}"
# Version 2: With examples
prompt = f"""Classify sentiment:
Examples:
- "Great movie" -> positive
- "Boring film" -> negative
Text: {text}
Sentiment:"""
# Compare results across versions
Add More Metrics
Evaluate additional aspects:
from ragas.metrics import NumericalMetric
confidence = NumericalMetric(
name="confidence",
prompt="Rate confidence 1-5 in this classification: {prediction}",
allowed_values=(1, 5),
)
Next Steps
- Judge Alignment - Measure LLM-as-judge alignment
- LLM Benchmarking - Compare different models
What's inside
5 code blocks, 1 project structure tree, 1 dataset example, 2 customization sections
Change this for your project
- Replace
"your-openai-key"with your actual OpenAI API key - Replace dataset examples in
dataset_dictwith your own test cases - Modify prompt templates in
prompt.pyfor your classification task
Where it goes
Keep alongside your test suite. Used to define and score model evaluations.
Worth borrowing
- Separate prompt definition from evaluation logic into distinct files
- Use a discrete metric decorator to enforce allowed values like pass/fail
Related Documents
IATA BCBP Standard Compliance
Documents which IATA BCBP fields and barcode formats a Swift library implements, including Version 8 gender code support.
Evaluating AI Agent Systems: Metrics, Benchmarks, and Quality Assurance (2024-2026)
Surveys 2024-2026 metrics, benchmarks, and monitoring tools for evaluating AI agent systems, with recommendations for a self-improving coding agent.
Voice AI Leaderboards, Benchmarks, and Evaluation Gaps (Jan 2025 -- Feb 2026)
Surveys 20+ voice AI benchmarks from Jan 2025, Feb 2026, identifies evaluation gaps, and provides leaderboard data for STT, TTS, and end-to-end voice agents.
LLM Evaluation — Deep Dive
Covers why LLM evaluation is hard, benchmark taxonomy, LLM-as-judge methodology, contamination, robustness, and designing an eval suite for a product.