-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add --examples
Argument for Fine-Grained Task Evaluation in lm-evaluation-harness
. This feature is the first step towards efficient multi-prompt evaluation with PromptEval [1,2]
#2520
Open
felipemaiapolo
wants to merge
10
commits into
EleutherAI:main
Choose a base branch
from
mirianfsilva:examples-arg
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f06ea84
added option --examples
felipemaiapolo 8f6de73
specifying examples in dictionary
felipemaiapolo 4863977
run pre-commit - fix arg type
mirianfsilva 28c322a
fixing bug when examples==None
felipemaiapolo 724612d
fixing bug when examples==None
felipemaiapolo 7613990
limit or examples must be None in simple_evaluate.py and in evaluator.py
felipemaiapolo a7a566c
Merge branch 'main' into examples-arg
StellaAthena 15a324d
run pre-commit (fix formatting)
mirianfsilva 0878678
Merge branch 'main' into examples-arg
mirianfsilva a7b3d4a
merge main and run pre-commit (fix formatting)
mirianfsilva 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 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 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 |
---|---|---|
|
@@ -374,6 +374,7 @@ def build_all_requests( | |
self, | ||
*, | ||
limit: Union[int, None] = None, | ||
examples: Optional[List[int]] = None, | ||
rank: int = 0, | ||
world_size: int = 1, | ||
cache_requests: bool = False, | ||
|
@@ -426,7 +427,9 @@ def build_all_requests( | |
limit = None | ||
|
||
doc_id_docs = list( | ||
self.doc_iterator(rank=rank, limit=limit, world_size=world_size) | ||
self.doc_iterator( | ||
rank=rank, limit=limit, examples=examples, world_size=world_size | ||
) | ||
) | ||
|
||
num_docs = len(doc_id_docs) | ||
|
@@ -678,15 +681,38 @@ def eval_docs(self) -> Union[datasets.Dataset, List[dict]]: | |
) | ||
|
||
def doc_iterator( | ||
self, *, rank: int = 0, limit: Union[int, None] = None, world_size: int = 1 | ||
self, | ||
*, | ||
rank: int = 0, | ||
limit: Union[int, None] = None, | ||
examples: Optional[List[int]] = None, | ||
world_size: int = 1, | ||
) -> Iterator[Tuple[int, Any]]: | ||
limit = int(limit) if limit else None | ||
doc_iterator = utils.create_iterator( | ||
enumerate(self.eval_docs), | ||
rank=int(rank), | ||
limit=limit, | ||
world_size=int(world_size), | ||
) | ||
if examples: | ||
n = self.eval_docs.to_pandas().shape[0] | ||
assert all( | ||
[e < n for e in examples] | ||
), f"Elements of --examples should be in the interval [0,k-1] where k is the number of total examples. In this case, k={n}." | ||
doc_iterator = utils.create_iterator( | ||
enumerate( | ||
datasets.Dataset.from_pandas( | ||
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. should be able to use normal list methods, something like |
||
self.eval_docs.to_pandas() | ||
.iloc[examples, :] | ||
.reset_index(drop=True) | ||
) | ||
), | ||
rank=int(rank), | ||
limit=None, # limit does not matter here since we are selecting samples directly | ||
world_size=int(world_size), | ||
) | ||
else: | ||
limit = int(limit) if limit else None | ||
doc_iterator = utils.create_iterator( | ||
enumerate(self.eval_docs), | ||
rank=int(rank), | ||
limit=limit, | ||
world_size=int(world_size), | ||
) | ||
return doc_iterator | ||
|
||
|
||
|
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
limit and examples can be undefined left here.
I should also add a test for
main
so errors like this are caught.