-
Notifications
You must be signed in to change notification settings - Fork 16
Various small refactors #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| """ | ||
| Base adapter interface for Eval Protocol. | ||
| """ | ||
|
|
||
| from abc import ABC, abstractmethod | ||
| from typing import List | ||
|
|
||
| from eval_protocol.models import EvaluationRow | ||
|
|
||
|
|
||
| class BaseAdapter(ABC): | ||
| """Abstract base class for all Eval Protocol adapters.""" | ||
|
|
||
| @abstractmethod | ||
| def get_evaluation_rows(self, *args, **kwargs) -> List[EvaluationRow]: | ||
| """Get evaluation rows from the data source.""" | ||
| pass | ||
|
|
||
| def push_scores(self, rows: List[EvaluationRow], model_name: str, mean_score: float) -> None: | ||
|
xzrderek marked this conversation as resolved.
Outdated
|
||
| """Push evaluation scores back to the data source for tracking and analysis.""" | ||
| pass | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,65 +2,23 @@ | |
| Default LLM judge for Eval Protocol. Inspired by Arena-Hard-Auto. | ||
| """ | ||
|
|
||
| from collections.abc import Awaitable, Callable | ||
| import os | ||
| from datetime import datetime | ||
| from typing import List, Dict, Any, Optional | ||
| from typing_extensions import cast | ||
| from tqdm import tqdm | ||
| from typing import Optional | ||
|
|
||
| import pytest | ||
|
|
||
| from eval_protocol.models import EvaluateResult, EvaluationRow, MetricResult | ||
| from eval_protocol.pytest import evaluation_test | ||
| from eval_protocol.pytest.default_single_turn_rollout_process import SingleTurnRolloutProcessor | ||
| from eval_protocol.models import EvaluationRow | ||
| from eval_protocol.adapters.base import BaseAdapter | ||
| from eval_protocol.quickstart.utils import ( | ||
| split_multi_turn_rows, | ||
| JUDGE_CONFIGS, | ||
| calculate_bootstrap_scores, | ||
| run_judgment_async, | ||
| ) | ||
| import asyncio | ||
| from openai import AsyncOpenAI | ||
| from eval_protocol.adapters.langfuse import create_langfuse_adapter | ||
|
|
||
| adapter = create_langfuse_adapter() | ||
|
|
||
|
|
||
| @pytest.mark.asyncio | ||
| @evaluation_test( | ||
| input_rows=[ | ||
| adapter.get_evaluation_rows( | ||
| to_timestamp=datetime(2025, 9, 12, 0, 11, 18), | ||
| limit=711, | ||
| sample_size=50, | ||
| sleep_between_gets=3.0, | ||
| max_retries=5, | ||
| ) | ||
| ], | ||
| completion_params=[ | ||
| {"model": "gpt-4.1"}, | ||
| { | ||
| "max_tokens": 131000, | ||
| "extra_body": {"reasoning_effort": "medium"}, | ||
| "model": "fireworks_ai/accounts/fireworks/models/gpt-oss-120b", | ||
| }, | ||
| { | ||
| "max_tokens": 131000, | ||
| "extra_body": {"reasoning_effort": "low"}, | ||
| "model": "fireworks_ai/accounts/fireworks/models/gpt-oss-20b", | ||
| }, | ||
| ], | ||
| rollout_processor=SingleTurnRolloutProcessor(), | ||
| preprocess_fn=split_multi_turn_rows, | ||
| max_concurrent_rollouts=64, | ||
| mode="all", | ||
| ) | ||
| async def test_llm_judge(rows: list[EvaluationRow]) -> list[EvaluationRow]: | ||
| return await aha_judge(rows) | ||
|
Comment on lines
-59
to
-60
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes thank you |
||
|
|
||
|
|
||
| async def aha_judge(rows: list[EvaluationRow], judge_name: str = "gemini-2.5-pro") -> list[EvaluationRow]: | ||
| async def aha_judge( | ||
| rows: list[EvaluationRow], judge_name: str = "gemini-2.5-pro", adapter: Optional[BaseAdapter] = None | ||
| ) -> list[EvaluationRow]: | ||
|
Comment on lines
+19
to
+21
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly |
||
| """ | ||
| LLM Judge evaluation using Arena-Hard-Auto style pairwise comparisons. | ||
|
|
||
|
|
@@ -73,6 +31,8 @@ async def aha_judge(rows: list[EvaluationRow], judge_name: str = "gemini-2.5-pro | |
|
|
||
| Args: | ||
| rows: List of EvaluationRow objects with messages, ground_truth, and tools | ||
| judge_name: Name of the judge configuration to use | ||
| adapter: Optional adapter to push scores back to (if provided) | ||
|
|
||
| Returns: | ||
| Same rows with updated evaluation_result containing scores and judgments | ||
|
|
@@ -133,7 +93,8 @@ async def run_judgment(row): | |
| if row.evaluation_result: | ||
| row.evaluation_result.score = mean_score | ||
|
|
||
| # Optional, push scores back to Langfuse. Note that one score per model will be pushed back onto same trace. | ||
| adapter.push_scores(rows, model_name, mean_score) | ||
| # Push scores back to adapter if provided. Note that one score per model will be pushed back onto same trace. | ||
| if adapter: | ||
| adapter.push_scores(rows, model_name, mean_score) | ||
|
|
||
| return rows | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.