PROJECT TEMPLATE: LLM Evaluation Benchmark¶
Comprehensive evaluation framework for LLMs.
Project Structure¶
llm-evaluation-benchmark/
โโโ README.md
โโโ pyproject.toml
โโโ uv.lock
โโโ config/
โ โโโ models_config.yaml
โ โโโ benchmarks_config.yaml
โ โโโ metrics_config.yaml
โโโ src/
โ โโโ __init__.py
โ โโโ models/
โ โ โโโ __init__.py
โ โ โโโ huggingface.py
โ โ โโโ openai.py
โ โ โโโ local.py
โ โโโ benchmarks/
โ โ โโโ __init__.py
โ โ โโโ mmlu.py # MMLU benchmark
โ โ โโโ truthfulqa.py # TruthfulQA
โ โ โโโ gsm8k.py # Math reasoning
โ โ โโโ custom.py # Custom benchmarks
โ โโโ metrics/
โ โ โโโ __init__.py
โ โ โโโ perplexity.py
โ โ โโโ bleu.py
โ โ โโโ rouge.py
โ โ โโโ accuracy.py
โ โโโ evaluators/
โ โ โโโ __init__.py
โ โ โโโ single_model.py
โ โ โโโ comparison.py
โ โโโ reporters/
โ โ โโโ __init__.py
โ โ โโโ console.py
โ โ โโโ html.py
โ โ โโโ json.py
โ โโโ runner.py # Evaluation runner
โโโ data/
โ โโโ benchmarks/
โ โโโ results/
โโโ scripts/
โ โโโ run_benchmark.py
โ โโโ compare_models.py
โ โโโ generate_report.py
โโโ tests/
โโโ test_evaluation.py
Features¶
- Multiple benchmark support
- Various metrics
- Model comparison
- HTML reports
- Leaderboard generation
Quick Start¶
Run Single Benchmark¶
from src.runner import EvaluationRunner
from src.models.huggingface import HuggingFaceModel
model = HuggingFaceModel("gpt2")
runner = EvaluationRunner(model)
results = runner.run_benchmark("mmlu")
print(results)
Compare Models¶
python scripts/compare_models.py \
--models gpt2,phi-2,distilgpt2 \
--benchmarks mmlu,gsm8k \
--output results/comparison.json
Custom Benchmark¶
from src.benchmarks.custom import CustomBenchmark
benchmark = CustomBenchmark(
name="my_benchmark",
questions=question_list,
evaluator=answer_checker
)
results = benchmark.evaluate(model)
Available Benchmarks¶
- MMLU: General knowledge
- TruthfulQA: Truthfulness
- GSM8K: Math reasoning
- HellaSwag: Common sense
- PIQA: Physical reasoning
- Custom: Your own benchmarks
Metrics¶
| Category | Metrics |
|---|---|
| Language Model | Perplexity, BPC |
| Generation | BLEU, ROUGE, METEOR |
| Classification | Accuracy, F1, Precision/Recall |
| Reasoning | Exact match, Step accuracy |
Reports¶
Generate HTML report:
python scripts/generate_report.py \
--input results/ \
--output report.html \
--format html
Configuration¶
config/models_config.yaml:
models:
- name: "gpt2"
type: "huggingface"
path: "gpt2"
- name: "gpt-4"
type: "openai"
model: "gpt-4"
config/benchmarks_config.yaml:
benchmarks:
mmlu:
subjects: ["math", "cs", "history"]
num_shots: 5
gsm8k:
grade_school_math: true
show_work: true
Leaderboard¶
from src.evaluators.comparison import ModelComparison
comparison = ModelComparison(
models=["gpt2", "phi-2", "distilgpt2"],
benchmarks=["mmlu", "gsm8k", "truthfulqa"]
)
leaderboard = comparison.run()
comparison.print_leaderboard(leaderboard)
Difficulty: โญโญ Intermediate
Estimated Time: 6-10 hours
Skills: Evaluation, Metrics, Benchmarking