Skip to content

[FT] Build in a way to specify specific IDs/Lines in Dataset to use as few-shot examples in the same split #634

Description

@EdwardSJ151

Solution/Feature

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:

test_split: train
fewshot_split: train
fewshot_config:
  sampler: id_sampler
  sampler_config:
    id_list: ["2022_21", "2022_88", "2022_143"]
    id_column: id
    exclude_from_task: true

Something along the lines of:

@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.

Activity

  1. 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
  2. added theissue type on May 15, 2025
  3. atharvjairath commented on May 26, 2026

    @atharvjairath

    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.

  4. nuthalapativarun commented on Jun 14, 2026

    @nuthalapativarun

    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.

  5. sohammmmm10 commented on Jun 16, 2026

    @sohammmmm10

    Hi @NathanHB, I'd like to take this on. I see previous interest but no PR has been
    submitted yet.

    My plan:

    • Add few_shots_id_column and few_shots_id_list to LightevalTaskConfig
    • Wire ID-based filtering through FewShotSampler._init_fewshot_pool()
    • Store ID column value on Doc via doc.specific["__fewshot_id"]
    • Keep exclude_from_task out of scope (follow-up if needed)
    • Add unit tests

    Will have a PR ready within 48 hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions