SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.09137 · ACL · 2023

Pre-Training to Learn in Context

Furu Wei, Minlie Huang, Li Dong, Yuxian Gu

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 8 have no contract verdict; 2 failures of our instrument; 3 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/2305.09137.json · badge: /api/ran/2305.09137.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
thu-coai/picl canonical (classifier label)
classifier basis: census
11 ran · 3 no recorded run
FunctionStatusWhere it lives
add_hp_args Ran
ran on a synthesized input
thu-coai/picl/arguments.py
code served (permissive licence) · get_code("a57d1ac3e1420421")
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 ArgumentParser. 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 argparse
import torch
import numpy as np

torch.manual_seed(0)

parser = argparse.ArgumentParser()

ARGS = {
    'parser': parser,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
add_model_config_args Ran
ran on a synthesized input
thu-coai/picl/arguments.py
code served (permissive licence) · get_code("e707419fdbd20b49")
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 ArgumentParser. 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 argparse

def add_model_config_args(parser: argparse.ArgumentParser):
    """Model arguments"""
    group = parser.add_argument_group('model', 'model configuration')
    group.add_argument('--model-dir', type=str, help='model configuration file')
    group.add_argument('--ckpt-name', type=str)
    group.add_argument('--n-gpu', type=int, default=1)
    group.add_argument('--model-type', type=str, default='gpt2')
    return parser

parser = argparse.ArgumentParser()

ARGS = {
    'parser': parser
}
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 ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
add_runtime_args Ran
ran on a synthesized input
thu-coai/picl/arguments.py
code served (permissive licence) · get_code("ec0de3378caad0a1")
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 ArgumentParser. 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 argparse
import torch
import torch.nn as nn

torch.manual_seed(0)

ARGS = {
    'parser': argparse.ArgumentParser()
}
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 ArgumentParser — a ArgumentParser output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a ArgumentParser 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
code Ran
ran, honoured the contract we drafted
thu-coai/picl/data_utils/distributed_indexed.py
code served (permissive licence) · get_code("18d94355ea8f1c39")
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 int, 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 numpy as np

dtypes = {1: np.uint8, 2: np.int8, 3: np.int16, 4: np.int32, 5: np.int64, 6: np.float32, 7: np.double, 8: np.uint16}

def code(dtype):
    for k in dtypes.keys():
        if dtypes[k] == dtype:
            return k
    raise ValueError(dtype)

# Test with np.float32
ARGS = {
    "dtype": np.float32
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — 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 int, 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
compute_rank_metrics Ran
ran on a synthesized input
thu-coai/picl/retriever.py
code served (permissive licence) · get_code("b5d10cd57d671759")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 small tensors for the function
# pred_scores: shape (batch_size, num_classes) - prediction scores
# target_labels: shape (batch_size,) - target class indices
# ks: list of k values for metrics like precision@k

batch_size = 2
num_classes = 4

# pred_scores: (2, 4) tensor of prediction scores
pred_scores = torch.randn(batch_size, num_classes)

# target_labels: (2,) tensor of target indices, each in range [0, num_classes)
target_labels = torch.tensor([1, 2])

# ks: list of cutoff values for rank metrics
ks = [1, 3]

ARGS = {
    "pred_scores": pred_scores,
    "target_labels": target_labels,
    "ks": ks,
}
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 tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
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
data_file_path Ran
ran; our contract draft was wrong, not the code
thu-coai/picl/data_utils/distributed_indexed.py
code served (permissive licence) · get_code("bdf28f9492a770dc")
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

torch.manual_seed(0)

ARGS = {
    "prefix_path": "/tmp/data_file"
}
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
evaluate Ran
ran on a synthesized input
thu-coai/picl/retriever.py
code served (permissive licence) · get_code("544c348e808ef820")
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
import torch.nn as nn

torch.manual_seed(0)

# Build a minimal model that matches what evaluate() expects
class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def forward(self, input_ids=None, pos_ctx_indices=None, **kwargs):
        batch_size = input_ids.size(0) if input_ids is not None else 2
        num_contexts = 3
        
        # Return the expected output dict
        return {
            'loss': torch.tensor(0.5),
            'sim_scores': torch.randn(batch_size, num_contexts),
            'query_repr': torch.randn(batch_size, 4),
            'context_repr': torch.randn(num_contexts, 4),
        }

# Build a minimal tokenizer
class MockTokenizer:
    pass

# Build a minimal eval_dataset with to_device method
class MockEvalDataset:
    def to_device(self, batch, device):
        # Move tensors in batch to device
        result = {}
        for key, val in batch.items():
            if isinstance(val, torch.Tensor):
                result[key] = val.to(device)
            else:
                result[key] = val
        return result

# Create eval_dataloader: list of batches
# Each batch should have 'input_ids' and 'pos_ctx_indices'
eval_dataloader = [
    {
        'input_ids': torch.randint(0, 100, (2, 4)),
        'pos_ctx_indices': torch.tensor([1, 0]),
    },
    {
        'input_ids': torch.randint(0, 100, (2, 4)),
        'pos_ctx_indices': torch.tensor([2, 1]),
    },
]

ARGS = {
    'args': type('Args', (), {'learning_rate': 0.001})(),
    'model': MockModel(),
    'tokenizer': MockTokenizer(),
    'eval_dataset': MockEvalDataset(),
    'eval_dataloader': eval_dataloader,
    'device': torch.device('cpu'),
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, tqdm — 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
get_optimizer_params Ran
ran on a synthesized input
thu-coai/picl/modeling/retriever_modeling.py
code served (permissive licence) · get_code("d039f1b6885abd3d")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# Create a simple model with parameters including bias and LayerNorm
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear1 = nn.Linear(4, 3)
        self.layer_norm = nn.LayerNorm(3)
        self.linear2 = nn.Linear(3, 2)
    
    def forward(self, x):
        x = self.linear1(x)
        x = self.layer_norm(x)
        x = self.linear2(x)
        return x

# Create model instance
model = SimpleModel()

# Create args object with weight_decay parameter
class Args:
    def __init__(self):
        self.weight_decay = 0.01

args = Args()

ARGS = {
    'args': args,
    'model': model
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
get_optimizer_params Ran
ran on a synthesized input
thu-coai/picl/utils.py
code served (permissive licence) · get_code("68777624ad9b2270")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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)

# Build a minimal model that has named parameters with 'bias', 'ln_f.weight', 
# 'ln_1.weight', 'ln_2.weight', 'ln_cross_attn' and some regular params
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        # Regular parameters (will have decay)
        self.linear1 = nn.Linear(4, 3)
        self.linear2 = nn.Linear(3, 2)
        
        # No decay parameters
        self.ln_f = nn.LayerNorm(2)
        self.ln_1 = nn.LayerNorm(2)
        self.ln_2 = nn.LayerNorm(2)
        self.ln_cross_attn = nn.LayerNorm(2)
        
    def forward(self, x):
        x = self.linear1(x)
        x = self.linear2(x)
        x = self.ln_f(x)
        return x

model = SimpleModel()

# Build args dict - the function only needs 'args' and 'model'
# Looking at the function body, 'args' is not actually used, but we must provide it
class Args:
    pass

args = Args()

ARGS = {
    'args': args,
    'model': model
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
index_file_path Ran
ran; our contract draft was wrong, not the code
thu-coai/picl/data_utils/distributed_indexed.py
code served (permissive licence) · get_code("8b1a74a6db32c163")
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

torch.manual_seed(0)

ARGS = {
    "prefix_path": "/tmp/test_index"
}
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
string_to_float Ran
ran on a synthesized input
thu-coai/picl/data_utils/data_config.py
code served (permissive licence) · get_code("6ee4fbcc1ffaa48e")
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 tuple, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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 converts preds and labels to lists of floats
# preds and labels should be iterables of values convertible to float
preds = [1, 2, 3, 4]
labels = [1.5, 2.5, 3.5, 4.5]

ARGS = {
    "preds": preds,
    "labels": labels
}
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 tuple, ndim 2, dtype family float — a tuple output has no array shape of its own; none is stated
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
get_model Not yet run
unverified (harvested, no recorded run)
thu-coai/picl/evaluate_cls.py
code served (permissive licence) · get_code("e245194711edcd44")
How it ran

no invocation recorded.

get_tokenizer Not yet run
unverified (harvested, no recorded run)
thu-coai/picl/evaluate_cls.py
code served (permissive licence) · get_code("dbe327e3880535a1")
How it ran

no invocation recorded.

train Not yet run
unverified (harvested, no recorded run)
thu-coai/picl/retriever.py
code served (permissive licence) · get_code("175056e6e7c4fe4a")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 3 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 3 later) and 11 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
data_file_path 8 other papers
2 dated earlier, 6 later
2022.emnlp-demos.40 (2022 (year only))
BMCook: A Task-agnostic Compression Toolkit for Big Models
2302.13939 (2023-02)
SpikeGPT: Generative Pre-trained Language Model with Spiking Neural Networks
2307.15504 (2023-07)
Exploring Format Consistency for Instruction Tuning
and 5 more not named here
index_file_path 8 other papers
2 dated earlier, 6 later
2022.emnlp-demos.40 (2022 (year only))
BMCook: A Task-agnostic Compression Toolkit for Big Models
2302.13939 (2023-02)
SpikeGPT: Generative Pre-trained Language Model with Spiking Neural Networks
2307.15504 (2023-07)
Exploring Format Consistency for Instruction Tuning
and 5 more not named here
code 7 other papers
1 dated earlier, 6 later
2022.emnlp-demos.40 (2022 (year only))
BMCook: A Task-agnostic Compression Toolkit for Big Models
2307.15504 (2023-07)
Exploring Format Consistency for Instruction Tuning
2312.02406 (2023-12)
Efficient Online Data Mixing For Language Model Pre-Training
and 4 more not named here

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

In-context learning, where pre-trained language models learn to perform tasks from task examples and instructions in their contexts, has attracted much attention in the NLP community. However, the ability of in-context learning is not fully exploited because language models are not explicitly trained to learn in context. To this end, we propose PICL (Pretraining for In-Context Learning), a framework to enhance the language models' in-context learning ability by pre-training the model on a large collection of "intrinsic tasks" in the general plain-text corpus using the simple language modeling objective. PICL encourages the model to infer and perform tasks by conditioning on the contexts while maintaining task generalization of pre-trained models. We evaluate the in-context learning performance of the model trained with PICL on seven widelyused text classification datasets and the SUPER-NATURALINSTRCTIONS benchmark, which contains 100+ NLP tasks formulated to text generation. Our experiments show that PICL is more effective and task-generalizable than a range of baselines, outperforming larger language models with nearly 4x parameters. The code is publicly available at https://github. com/thu-coai/PICL.

For agents

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

get_harvested_code_for_paper("2305.09137")
get_code_for_paper("2305.09137")
have("2305.09137")

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

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

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

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

Connect an agent — have() is free.