llm-evaluation-toolkit
LLMの出力を評価するための軽量Pythonライブラリです。BLEU・ROUGE・意味的類似度・LLM-as-a-Judgeの4種類の評価指標を、統一されたAPIで利用できます。
A lightweight Python toolkit for evaluating LLM outputs. Supports BLEU, ROUGE, semantic similarity, and LLM-as-a-Judge — all with a unified API.
なぜ llm-evaluation-toolkit なのか? / Why llm-evaluation-toolkit?
既存の評価ライブラリは研究用途に特化していたり、セットアップが複雑すぎる問題がありました。このライブラリは、実際の開発ワークフローでLLMの出力を素早く評価したい開発者のために設計されています。
Existing evaluation libraries are either too research-focused or require complex setup. This toolkit is designed for developers who need to evaluate LLM outputs quickly in real workflows.
- 統一API — すべての評価指標が同じインターフェースを持つ / Unified API — all metrics share the same interface
- 複数プロバイダ対応 — OpenAI・Anthropicをすぐに利用可能 / Multiple providers — OpenAI and Anthropic out of the box
- 正解テキスト不要 — LLM-as-a-Judgeは参照テキストなしで評価可能 / No reference needed — LLM-as-a-Judge works without ground truth
- 軽量設計 — 必要な機能だけインストールできる / Lightweight — install only what you need
インストール / Installation
# 基本インストール / Base installation
pip install llm-evaluation-toolkit
# OpenAI対応 / With OpenAI support
pip install llm-evaluation-toolkit[openai]
# Anthropic対応 / With Anthropic support
pip install llm-evaluation-toolkit[anthropic]
# 意味的類似度対応 / With semantic similarity support
pip install llm-evaluation-toolkit[semantic]
# 全機能 / All features
pip install llm-evaluation-toolkit[openai,anthropic,semantic]
クイックスタート / Quick Start
基本的な評価 / Basic evaluation
from llm_eval import BLEUMetric, ROUGEMetric, SemanticSimilarityMetric
predictions = [
"The cat is on the mat",
"A dog was running in the park",
]
references = [
"A cat is sitting on a mat",
"The dog ran through the park",
]
bleu = BLEUMetric()
rouge = ROUGEMetric()
semantic = SemanticSimilarityMetric()
print(bleu.compute(predictions, references))
# EvalResult(metric=bleu, score=0.4231)
print(rouge.compute(predictions, references))
# EvalResult(metric=rouge, score=0.6842)
print(semantic.compute(predictions, references))
# EvalResult(metric=semantic_similarity, score=0.8923)
正解テキストなしで評価(LLM-as-a-Judge) / Evaluate without reference texts
from llm_eval import LLMJudgeMetric
# 正解テキストなしで出力品質を評価できる
# Evaluate output quality without any reference text
judge = LLMJudgeMetric(judge_model="gpt-4o-mini")
questions = ["日本の首都はどこですか?"]
answers = ["日本の首都は東京です。政治・経済・文化の中心地として機能しています。"]
result = judge.compute(answers, questions)
print(result)
# EvalResult(metric=llm_judge, score=0.9)
複数の評価指標を一括実行 / Run multiple metrics at once
from llm_eval import BaseEvaluator, BLEUMetric, ROUGEMetric, SemanticSimilarityMetric
evaluator = BaseEvaluator(metrics=[
BLEUMetric(),
ROUGEMetric(),
SemanticSimilarityMetric(),
])
results = evaluator.evaluate(predictions, references)
for metric_name, result in results.items():
print(f"{metric_name}: {result.score:.4f}")
LLMプロバイダとの連携 / Use with LLM providers
from llm_eval import OpenAIProvider, GenerationConfig, BLEUMetric
# LLMで回答を生成してそのまま評価する
# Generate predictions from LLM and evaluate directly
provider = OpenAIProvider(
model="gpt-4o-mini",
config=GenerationConfig(temperature=0.0, max_tokens=256),
)
questions = ["機械学習とは何ですか?", "ニューラルネットワークを説明してください。"]
predictions = provider.generate_batch(questions)
references = [
"機械学習はデータから学習するAIの一分野です。",
"ニューラルネットワークは人間の脳を模倣した計算システムです。",
]
result = BLEUMetric().compute(predictions, references)
print(result)
ベンチマークデータセットの利用 / Load benchmark datasets
from llm_eval import DatasetLoader
# 組み込みベンチマークを使う / Use built-in benchmarks
squad = DatasetLoader.load_squad(max_samples=50)
print(squad)
# EvalDataset(name=squad, size=50)
# 自前データを使う / Use your own data
dataset = DatasetLoader.from_dict(
name="my_dataset",
questions=["質問1", "質問2"],
references=["回答1", "回答2"],
)
対応評価指標 / Supported Metrics
| 指標 / Metric | 正解テキスト / Reference | 適したタスク / Best for |
|---|---|---|
| BLEU | 必要 / Yes | 翻訳・固定フォーマット生成 / Translation, fixed-format generation |
| ROUGE | 必要 / Yes | 要約 / Summarization |
| Semantic Similarity | 必要 / Yes | 言い換えを含むタスク / Paraphrase-heavy tasks |
| LLM-as-a-Judge | 不要 / No | 自由記述生成 / Open-ended generation |
対応プロバイダ / Supported Providers
| プロバイダ / Provider | インストール / Install | モデル例 / Models |
|---|---|---|
| OpenAI | pip install llm-evaluation-toolkit[openai] |
gpt-4o, gpt-4o-mini |
| Anthropic | pip install llm-evaluation-toolkit[anthropic] |
claude-opus-4-6, claude-haiku-4-5 |
環境変数 / Environment Variables
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
開発環境のセットアップ / Development Setup
git clone https://github.com/swoswoyuu1156/llm-evaluation-toolkit.git
cd llm-evaluation-toolkit
python -m venv .venv
# Mac/Linux
source .venv/bin/activate
# Windows
.venv\Scripts\activate
pip install -e ".[dev]"
# テスト実行 / Run tests
pytest tests/ -v --cov=src/llm_eval
# リント実行 / Run linter
ruff check src/ tests/
コントリビューション / Contributing
コントリビューションを歓迎します!まず CONTRIBUTING.md をご確認ください。
Contributions are welcome! Please read CONTRIBUTING.md first.
ライセンス / License
MIT License — 詳細は LICENSE をご確認ください。
MIT License — see LICENSE for details.
デモ / Demo
関連記事 / Articles
Metadata
Release files for llm-evaluation-toolkit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llm_evaluation_toolkit-0.1.1.tar.gz | 1.5 MB | Without provenance | Details for llm_evaluation_toolkit-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llm_evaluation_toolkit-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for llm_evaluation_toolkit-0.1.1-py3-none-any.whl |
Total release size: 1.5 MB
Release files / llm_evaluation_toolkit-0.1.1.tar.gz
| Download URL | llm_evaluation_toolkit-0.1.1.tar.gz |
|---|---|
| Size | 1.5 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87b6f70b57de99d23c867e82b522d11a7f910bd84bb1253d8336bce4efea15e4
|
|
BLAKE2b-256 checksum How to use checksums |
4df4cf0199b5346092d796410978753e079ebd44003e05eee48338a83a9033e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Release files / llm_evaluation_toolkit-0.1.1-py3-none-any.whl
| Download URL | llm_evaluation_toolkit-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
eb0587074ed638b3bd94b53ba81a4ee64b08f984fad47aba72ab766501232ee5
|
|
BLAKE2b-256 checksum How to use checksums |
051eea7c424ae17b1b68df2b5d6227fec9ec9c7d7f478cf7615334920e9163b0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.15
|
Security for llm-evaluation-toolkit 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.