Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Workflow:Explodinggradients Ragas LLM Benchmarking

From Leeroopedia


Knowledge Sources
Domains LLMs, Evaluation, Benchmarking
Last Updated 2026-02-10 06:00 GMT

Overview

End-to-end process for benchmarking and comparing multiple LLM models on a specific task using Ragas experiments and custom metrics.

Description

This workflow covers the systematic comparison of different LLM models on a domain-specific task. It involves preparing a standardized benchmark dataset, defining task-specific evaluation metrics, running separate experiments for each model under identical conditions, and comparing results across models. The Ragas experiment framework handles parallel execution, result persistence, and structured comparison. This enables data-driven model selection for production deployments.

Usage

Execute this workflow when you need to choose between multiple LLM providers or model versions for a specific use case. You should have a well-defined task (e.g., discount calculations, code generation, classification) with a labeled dataset and clear success criteria. This workflow is essential before committing to a production LLM provider, when evaluating cost-performance tradeoffs, or when a new model version becomes available.

Execution Steps

Step 1: Prepare the Benchmark Dataset

Create or load a standardized dataset that represents the target task. Each sample should include the input prompt, expected output, and any additional context needed. The dataset should cover diverse scenarios and edge cases to ensure comprehensive model comparison.

Key considerations:

  • Use the Dataset class with a typed Pydantic model for schema enforcement
  • Include sufficient samples for statistical significance
  • Cover edge cases and diverse difficulty levels
  • The same dataset is used across all model experiments for fair comparison

Step 2: Define the Benchmark Prompt and Metrics

Create the task prompt that will be sent to each LLM, and define metrics for scoring responses. The prompt should be model-agnostic (no model-specific formatting). Metrics can be discrete (correct/incorrect) for accuracy measurement or numeric for graded scoring.

Key considerations:

  • Task prompts should use consistent formatting across models
  • DiscreteMetric works well for pass/fail accuracy benchmarks
  • NumericMetric works well for graded quality assessments
  • Metrics can combine LLM-based evaluation with deterministic checks

Step 3: Run Per-Model Experiments

Execute a separate experiment for each LLM model being benchmarked. Each experiment uses the same dataset and metrics but targets a different model via the model parameter. The @experiment decorator handles async execution, result collection, and persistence.

Key considerations:

  • Pass the model name as a parameter to the experiment function
  • Use llm_factory() to create model-specific LLM instances
  • Each experiment is saved with a unique name (e.g., "benchmark_gpt4o", "benchmark_claude")
  • Experiments run asynchronously for efficiency

Step 4: Aggregate and Compare Results

Load results from all model experiments and combine them for comparison. Align results by sample ID, compute per-model accuracy or aggregate scores, and generate comparison tables. Identify which model performs best overall and on specific subsets.

Key considerations:

  • Results can be exported to pandas DataFrames and merged on a common ID field
  • Calculate per-model accuracy as the fraction of correct responses
  • The CLI provides rich formatted tables with delta indicators for comparison
  • Export combined results to CSV for further analysis or reporting

Step 5: Select Model and Document Decision

Based on the comparison results, select the best-performing model for the target use case. Consider not just accuracy but also latency, cost, and failure modes. Document the decision and benchmark results for future reference using experiment versioning.

Key considerations:

  • Use version_experiment() to create git commits tracking the benchmark
  • Consider cost-performance tradeoffs (cheaper models may be acceptable for some tasks)
  • Analyze failure patterns to understand model-specific weaknesses
  • Re-run benchmarks when new model versions are released

Execution Diagram

GitHub URL

Workflow Repository