Repository navigation
Allow selecting few-shot examples by explicit ids - #1489
Open
amalsaidov wants to merge 1 commit into
Open
amalsaidov wants to merge 1 commit into
amalsaidov wants to merge 1 commit into
Conversation
Add `few_shots_id_column` and `few_shots_id_list` to LightevalTaskConfig so a task can pin which samples from the few-shot split are used as few-shot examples, matching them against a dataset column (similar to the id_sampler in LM Evaluation Harness). When `few_shots_id_list` is set, the few-shot pool is restricted to the samples whose `few_shots_id_column` value is in the list; evaluation docs are unaffected. Validation errors are raised when the column is missing or when the list is given without a column, and a warning is logged for requested ids that are not found. Fixes huggingface#634 Co-Authored-By: Claude Opus 4.8 <[email protected]>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #634
What
Adds two optional fields to
LightevalTaskConfig:few_shots_id_column(str | None): dataset column used to identify few-shot samples.few_shots_id_list(list[str] | None): explicit list of identifiers restricting which samples from the few-shot split may be used as few-shot examples.When
few_shots_id_listis set, the few-shot pool is restricted to the samples whosefew_shots_id_columnvalue is in the list. This mirrors theid_samplerbehavior requested in the issue (and available in LM Evaluation Harness), letting you pin exactly which rows are used as in-context examples.Why
Previously few-shot examples could only be chosen via a split + a selection strategy (balanced/random/sequential). There was no way to specify exact samples, which makes reproducing a fixed few-shot prompt across runs impossible. See #634.
Behavior / safety
ValueErroris raised at config time iffew_shots_id_listis given withoutfew_shots_id_column.KeyErroris raised if the configured column is absent from the dataset.None.How tested
tests/unit/tasks/test_lighteval_task.py:test_few_shots_id_list_selection— only the listed ids end up in the few-shot pool, eval docs unchanged.test_few_shots_id_list_without_column_raises— config validation.test_few_shots_id_list_missing_column_raises— missing column raises.python -m pytest tests/unit/tasks/test_lighteval_task.py→ 6 passed.ruff checkandruff format --check→ clean.🤖 Generated with Claude Code