SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2211.04486 · EMNLP · 2022

Active Example Selection for In-Context Learning

Shi Feng, Yiming Zhang, Chenhao Tan

arXiv · PDF · Open in the Atlas

Code that ran

10 of 16 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; 1 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 6 failures of our instrument; 6 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2211.04486.json · badge: /api/ran/2211.04486.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
chicagohai/active-example-selection marked official in Papers with Code
Papers with Code archive
10 ran · 6 no recorded run
FunctionStatusWhere it lives
DummyCache Ran
ran on a synthesized input · constructed an object; no result was computed
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("ba11f7925fceb188")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, DummyCache: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# Since DummyCache.__init__, get(), and set() all accept *args and **kwargs
# and don't actually use them (pass statements), we can pass anything.
# We'll keep it simple with no arguments.

ARGS = {
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DummyCache — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a DummyCache output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
GenerationOutput Ran
ran on a synthesized input · constructed an object; no result was computed
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("4dbcdfc42cf48596")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, GenerationOutput: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn.functional as F

torch.manual_seed(0)

# Create small tensors for the function
logits = torch.randn(4)  # Small logits tensor
perplexity = torch.tensor(2.5)  # Scalar perplexity
hidden_states = torch.randn(2, 4)  # Small hidden states tensor
completion = "Hello world"

# Compute probs from logits
probs = F.softmax(logits, dim=0)

ARGS = {
    "completion": completion,
    "probs": probs,
    "logits": logits,
    "perplexity": perplexity,
    "hidden_states": hidden_states,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type GenerationOutput — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a GenerationOutput output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
PromptTooLongError Ran
ran on a synthesized input · constructed an object; no result was computed
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("139c2397c626a5ae")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, PromptTooLongError: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# PromptTooLongError is a simple Exception subclass with no custom __init__
# It inherits from Exception, which accepts optional message arguments
# We need to provide arguments that would be passed to Exception.__init__

ARGS = {
    # Exception can take a message as its first positional argument
    # We'll provide a descriptive error message
}

# If called with no arguments, it will work fine as Exception()
# If called with arguments, Exception accepts them via *args

# To be thorough and test the exception properly:
ARGS = {}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type PromptTooLongError — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a PromptTooLongError output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
deterministic_hash Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("a306bbb5821e4026")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned int, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import hashlib

# The function takes a single parameter 's' which is a string
# It encodes the string to UTF-8, computes SHA512 hash, and converts to int

ARGS = {
    "s": "hello world"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
deterministic_random Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("35440e3dc405d3ac")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Random. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import random

ARGS = {
    "seed": 42
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Random — a Random output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Random output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
entropy Ran
ran, honoured the contract we drafted
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("1425a704ec322a88")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Tensor, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# The function takes a probability tensor and computes entropy
# It uses: multiplication (*), log2, nansum operations
# So we need a valid probability distribution tensor

probs = torch.tensor([
    [0.5, 0.3, 0.15, 0.05],
    [0.25, 0.25, 0.25, 0.25]
], dtype=torch.float32)

ARGS = {
    "probs": probs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float, shape () — shape () as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
extract_completion Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("f20f556e35d766b1")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn

torch.manual_seed(0)

# The function extract_completion takes a single parameter: gpt_output (a string)
# It simply calls .strip() on it, so we need a valid string input

gpt_output = "  Hello, this is a test completion.  \n"

ARGS = {
    "gpt_output": gpt_output
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
print_json Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("7d151daf94139a93")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned str. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
from typing import Any, Dict, Optional

def print_json(d: Dict, indent: Optional[int]=2) -> str:
    return json.dumps(d, indent=indent) + '\n'

# Construct arguments for print_json
test_dict = {
    "name": "example",
    "value": 42,
    "nested": {
        "key": "value",
        "list": [1, 2, 3]
    }
}

ARGS = {
    "d": test_dict,
    "indent": 2
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
read_json_file Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("c7e900c72688b821")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import json
import tempfile
import os

# Create a temporary JSON file with valid content
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test.json")

test_data = {
    "key1": "value1",
    "key2": 42,
    "key3": [1, 2, 3],
    "key4": {"nested": "dict"}
}

with open(temp_file, 'w') as f:
    json.dump(test_data, f)

ARGS = {
    "path": temp_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
to_device Ran
ran; our contract draft was wrong, not the code
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("fc32f59c23dbf003")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned dict. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch

torch.manual_seed(0)

# Create a small tensor dictionary with CPU tensors
tensor_dict = {
    'input': torch.randn(2, 4),
    'target': torch.randn(2, 3),
    'mask': torch.ones(2, 4)
}

# Define the device as a string (CPU device)
device = 'cpu'

# Construct ARGS dictionary mapping all parameters
ARGS = {
    'tensor_dict': tensor_dict,
    'device': device
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BaseProcessor Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("9774b3d0c806c454")
How it ran

no invocation recorded.

BaseStrategy Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("35aa183a5e712bbc")
How it ran

no invocation recorded.

GPT2Wrapper Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("2c1d90531acc1316")
How it ran

no invocation recorded.

GreedyStrategy Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("b7e78ffc8b787c70")
How it ran

no invocation recorded.

MaxEntropyStrategy Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("9bc9d1d77e4260f8")
How it ran

no invocation recorded.

Prompt Not yet run
unverified (harvested, no recorded run)
chicagohai/active-example-selection/src/prompting/strategies/greedy_strategies.py
code served (permissive licence) · get_code("5c27cd49d2cb1b0d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 14 are also present in other papers whose code we hold (14 with at least one paper dated earlier, 0 the same month, 0 later) and 2 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.

FunctionAlso present inEarliest-datedOthers named
BaseProcessor
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
BaseStrategy
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
DummyCache
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
GPT2Wrapper
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
GenerationOutput
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
Prompt
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
PromptTooLongError
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
deterministic_hash
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
deterministic_random
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
entropy
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
extract_completion
brick of this paper's assembly: helper
1 other paper
1 dated earlier · 1 only as an assembly brick
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
print_json
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
read_json_file
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity
to_device
brick of this paper's assembly: helper
1 other paper
1 dated earlier
2104.08786 (2021-04)
Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity

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

Repositories linked to this paper

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

Abstract

With a handful of demonstration examples, large-scale language models show strong capability to perform various tasks by in-context learning from these examples, without any finetuning. We demonstrate that in-context learning performance can be highly unstable across samples of examples, indicating the idiosyncrasies of how language models acquire information. We formulate example selection for in-context learning as a sequential decision problem, and propose a reinforcement learning algorithm for identifying generalizable policies to select demonstration examples. For GPT-2, our learned policies demonstrate strong abilities of generalizing to unseen tasks in training, with a 5.8% improvement on average. Examples selected from our learned policies can even achieve a small improvement on GPT-3 Ada. However, the improvement diminishes on larger GPT-3 models, suggesting emerging capabilities of large language models.

For agents

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

get_harvested_code_for_paper("2211.04486")
get_code_for_paper("2211.04486")
have("2211.04486")

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

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

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

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

Connect an agent — have() is free.