You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FT] Build in a way to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split #634
When creating a custom task, the few-shot samples can be specified via a split from the dataset. However, it would be convenient if there were a way to make it so I can specify samples from the split that will be used as the examples, similar to what LM Evaluation Harness does here in its yaml config:
@dataclass
class LightevalTaskConfig:
"""Stored configuration of a given [`LightevalTask`].
Arguments:
...
hf_subset (str): Subset used for the current task, will be default if none is selected.
hf_avail_splits (list[str]): All the available splits in the evaluation dataset
evaluation_splits (list[str]): List of the splits actually used for this evaluation
few_shots_split (str): Name of the split from which to sample few-shot examples
few_shots_id_column (str): Column name in the dataset to use for the few_shot_id_list
few_shots_id_list (list[str]): List of unique identifiers corresponding to the samples in the dataset, based on matching these IDs with the values in few_shots_id_column.
few_shots_select (str): Method with which to sample few-shot examples
...
"""
The new arguments would be few_shots_id_column and few_shots_id_list, and wrote a rough description of what they would look like.
changed the title [-][FT] Built in method to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split[/-][+][FT] Build in a way to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split[/+]on Mar 21, 2025
Hi @NathanHB , I'd like to take this one. Plan: add few_shots_id_column and few_shots_id_list to LightevalTaskConfig; when set, those samples become the few-shot examples (used in listed order, defaulting few_shots_select to sequential). Defaults stay None so existing tasks are unaffected. Will open a PR shortly.
I'd like to take this on. Before opening a PR, here's the design I'm planning to follow — flagging it first since it touches LightevalTaskConfig and the few-shot sampling path.
New config fields (LightevalTaskConfig, alongside few_shots_split / few_shots_select):
few_shots_id_column: str | None = None — name of the column in the raw dataset row holding a unique identifier.
few_shots_id_list: ListLike[str] | None = None — list of identifier values (compared as strings) to use as the few-shot pool.
Sampling:
When few_shots_id_list is set, FewShotSampler builds its pool by filtering task.fewshot_docs() to only the docs whose source row has str(item[few_shots_id_column]) in few_shots_id_list, preserving the order given in few_shots_id_list. This bypasses balanced/random/sequential sorting (id-based selection is deterministic by construction), but few_shots_select can still be left as-is for backward compatibility (it's simply ignored when few_shots_id_list is provided).
To make the source row's identifier available on Doc, _get_docs_from_split will need to stash item[few_shots_id_column] (e.g. as doc.specific["__id_column_value"] or a small new Doc attribute) when few_shots_id_column is configured.
Out of scope for the first PR: I'd leave out the exclude_from_task behavior from the LM-Eval-Harness config shown in the issue (i.e. removing the selected few-shot rows from the eval split itself) — that's a separate concern and can be a follow-up if there's interest, to keep this PR focused and reviewable.
Let me know if this direction looks right, or if you'd prefer a different shape (e.g. a dedicated FewShotSelection.id_list enum member vs. a separate code path) before I start implementing.
Activity
[-][FT] Built in method to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split[/-][+][FT] Build in a way to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split[/+]atharvjairath commentedon May 26, 2026
Hi @NathanHB , I'd like to take this one. Plan: add
few_shots_id_columnandfew_shots_id_listtoLightevalTaskConfig; when set, those samples become the few-shot examples (used in listed order, defaultingfew_shots_selectto sequential). Defaults stayNoneso existing tasks are unaffected. Will open a PR shortly.nuthalapativarun commentedon Jun 14, 2026
I'd like to take this on. Before opening a PR, here's the design I'm planning to follow — flagging it first since it touches
LightevalTaskConfigand the few-shot sampling path.New config fields (
LightevalTaskConfig, alongsidefew_shots_split/few_shots_select):few_shots_id_column: str | None = None— name of the column in the raw dataset row holding a unique identifier.few_shots_id_list: ListLike[str] | None = None— list of identifier values (compared as strings) to use as the few-shot pool.Sampling:
few_shots_id_listis set,FewShotSamplerbuilds its pool by filteringtask.fewshot_docs()to only the docs whose source row hasstr(item[few_shots_id_column])infew_shots_id_list, preserving the order given infew_shots_id_list. This bypassesbalanced/random/sequentialsorting (id-based selection is deterministic by construction), butfew_shots_selectcan still be left as-is for backward compatibility (it's simply ignored whenfew_shots_id_listis provided).Doc,_get_docs_from_splitwill need to stashitem[few_shots_id_column](e.g. asdoc.specific["__id_column_value"]or a small newDocattribute) whenfew_shots_id_columnis configured.Out of scope for the first PR: I'd leave out the
exclude_from_taskbehavior from the LM-Eval-Harness config shown in the issue (i.e. removing the selected few-shot rows from the eval split itself) — that's a separate concern and can be a follow-up if there's interest, to keep this PR focused and reviewable.Let me know if this direction looks right, or if you'd prefer a different shape (e.g. a dedicated
FewShotSelection.id_listenum member vs. a separate code path) before I start implementing.sohammmmm10 commentedon Jun 16, 2026
Hi @NathanHB, I'd like to take this on. I see previous interest but no PR has been
submitted yet.
My plan:
few_shots_id_columnandfew_shots_id_listtoLightevalTaskConfigFewShotSampler._init_fewshot_pool()doc.specific["__fewshot_id"]exclude_from_taskout of scope (follow-up if needed)Will have a PR ready within 48 hours.