Skip to main content

run-evals

Run an Opik evaluation for an example in this repo — metrics (evaluate) and/or assertions (run_tests) against a dataset/test suite. Use when the user says "run the eval", "evaluate the example", "run the test suite", "score the model", "check the metrics", "what's the pass rate", or wants to measure an example's quality in Opik. Covers the credentials/DRY_RUN gate, metric selection, experiment naming, and reading results. Require a target example; refuse to guess which one.

来源信息

仓库
comet-ml/opik-examples
最近来源活动
2026年6月22日 19:33
检测到的 SKILL.md 语言
英语
星标
8
分支
4

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
run-evals
description
Run an Opik evaluation for an example in this repo — metrics (evaluate) and/or assertions (run_tests) against a dataset/test suite. Use when the user says "run the eval", "evaluate the example", "run the test suite", "score the model", "check the metrics", "what's the pass rate", or wants to measure an example's quality in Opik. Covers the credentials/DRY_RUN gate, metric selection, experiment naming, and reading results. Require a target example; refuse to guess which one.
# Run an Opik evaluation Two complementary scorers, usually run together: - **`run_tests(test_suite, ...)`** — judges the plain-English assertions in a test suite. Returns `.pass_rate` and `.experiment_url`. - **`evaluate(dataset, ...)`** — runs numeric `scoring_metrics` over a dataset. Reference: `run_eval` in [`evaluation.py`](../../../use-cases/f1_radio_rag/src/f1_radio_rag/evaluation.py); CLI [`cli.py`](../../../use-cases/f1_radio_rag/src/f1_radio_rag/cli.py) `eval` command. ## When to refuse Need a **target example** (folder + its dataset/suite). If the repo has several, ask which. Don't run evals blindly — they call LLM-judge models and cost tokens/time. ## Step 1 — Credentials gate `evaluate` / `run_tests` need `OPIK_API_KEY` + `OPIK_WORKSPACE`, and the judge/generation models need their provider key (e.g. `ANTHROPIC_API_KEY`). Without Opik creds the example runs in `DRY_RUN` and prints what it would create. Run the dry-run first to confirm the dataset/suite content, then set creds for the real run. ```bash cd use-cases/f1_radio_rag uv run f1rag eval # DRY_RUN: lists dataset items + assertions export ANTHROPIC_API_KEY=... OPIK_API_KEY=... OPIK_WORKSPACE=... uv run f1rag eval # real run: prints pass rate + experiment URL ``` ## Step 2 — The task and the shape it returns The evaluation task is `(item: dict) -> dict`. It runs the live app on the item and returns the fields the metrics consume — for RAG: `{"input", "output", "context"}`. Reuse the example's existing task (don't reimplement the app inside the eval). ```python from opik.evaluation import evaluate, run_tests from opik.evaluation.metrics import ContextRecall, Hallucination def task(item: dict) -> dict: return app_under_test(item["query"]) # -> {"input","output","context"} ``` ## Step 3 — Pick metrics that match the failure modes - `ContextRecall` — did retrieval surface the needed context? (RAG retrieval quality) - `Hallucination` — is the answer faithful to the context? (faithfulness) - `AnswerRelevance` — does the answer address the question? - Add others from `opik.evaluation.metrics` as the use case needs. Each LLM-judge metric takes `model=...`. ```python run_tests(test_suite=suite, task=task, model=JUDGE_MODEL, experiment_name=experiment_name()) evaluate(dataset=dataset, task=task, scoring_metrics=[ContextRecall(model=JUDGE_MODEL), Hallucination(model=JUDGE_MODEL)], experiment_name=experiment_name()) ``` Use a unique `experiment_name` per run (the example does `f"{project}-{secrets.token_hex(3)}"`) so runs don't overwrite each other in the UI. ## Step 4 — Read results - `suite_result.pass_rate` — fraction of suite items passing their assertions. - `suite_result.experiment_url` / `result.get(...)` — link to the run in Opik for per-item drill-down. Surface the URL to the user. ## Verify - Dry-run lists the expected dataset/suite content before the real run. - Real run prints a pass rate and an experiment URL; open it to confirm per-item scores. - If the task throws `KeyError`, a dataset item is missing a key the task/metrics read — fix the data (see the `add-dataset-items` skill), not the task.
在 GitHub 查看