SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2508.19999 · EMNLP · 2025

Linear-Time Demonstration Selection for In-Context Learning via Gradient Estimation

Hongyang Zhang, Jennifer Dy, Dongyue Li, Lu Wang, 𝑖, Demo, Ziniu Zhang, Zhenshuo Zhang, 𝑆 𝑖, 𝑥 𝑗, Tr -𝜙 𝑆, 𝑖 𝑥, and 2 more

arXiv · PDF · Open in the Atlas

Code that ran

8 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 1 violated it and 3 have no contract verdict; 4 failures of our instrument; 0 no recorded run), measured 2026-11-24; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2508.19999.json · badge: /api/ran/2508.19999.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
VirtuosoResearch/ICL-GradSel community
Papers with Code archive
8 ran · 0 no recorded run
FunctionStatusWhere it lives
Config Ran
ran on a synthesized input · constructed an object; no result was computed
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("696ab31578bc6498")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

PairedTransformer Ran
ran on a synthesized input · constructed an object; no result was computed
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("d0545ab82736c5b7")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

PositionalEncoding Ran
ran on a synthesized input · constructed an object; no result was computed
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("369d943083919008")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

distinct_slot_initialization Ran
ran; our contract draft was wrong, not the code
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("88fbfd2025e9cd11")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

nonnegative_group_soft_threshold Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("3b4f7906ce383a56")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

predict_query Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("82afecfec9f9c443")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

sparse_selection_weights Ran
ran; our contract draft was wrong, not the code
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("a806866536d33ec5")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

task_compat_scores Ran
ran, violated the contract we drafted
VirtuosoResearch/ICL-GradSel/src/icl_linear_regression_group_lasso_demo_selection.py
pointer only (licence: NOASSERTION) · get_code("0e5fe33a678c4669")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, VirtuosoResearch/ICL-GradSel (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 8 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-24.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

This paper introduces an algorithm to select demonstration examples for in-context learning of a query set. Given a set of n examples, how can we quickly select k out of n to best serve as the conditioning for downstream inference? This problem has broad applications in prompt tuning and chain-of-thought reasoning. Since model weights remain fixed during in-context learning, previous work has sought to design methods based on the similarity of token embeddings. This work proposes a new approach based on gradients of the output taken in the input embedding space. Our approach estimates model outputs through a first-order approximation using the gradients. Then, we apply this estimation to multiple randomly sampled subsets. Finally, we aggregate the sampled subset outcomes to form an influence score for each demonstration, and select k most relevant examples. This procedure only requires precomputing model outputs and gradients once, resulting in a linear-time algorithm relative to model and training set sizes. Extensive experiments across various models and datasets validate the efficiency of our approach. We show that the gradient estimation procedure yields approximations of full inference with less than 1% error across six datasets. This allows us to scale up subset selection that would otherwise run full inference by up to 37.7× on models with up to 34 billion parameters, and outperform existing selection methods based on input embeddings by 11% on average.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2508.19999")
get_code_for_paper("2508.19999")
have("2508.19999")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2508.19999.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2508.19999.svg)](https://syntology.ai/paper/2508.19999)

Connect an agent — have() is free.