SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2106.01751 · ACL Findings · 2021

Reordering Examples Helps during Priming-based Few-Shot Learning

Partha Talukdar, Sawan Kumar

arXiv · PDF · Open in the Atlas

Code that ran

3 of 7 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 1 failure of our instrument; 4 no recorded run), measured 2026-11-21; 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/2106.01751.json · badge: /api/ran/2106.01751.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
ucinlp/autoprompt community
Papers with Code archive
3 ran · 1 no recorded run
SawanKumar28/pero marked official in Papers with Code
Papers with Code archive
0 ran · 3 no recorded run
FunctionStatusWhere it lives
PredictWrapper Ran
ran on a synthesized input · constructed an object; no result was computed
ucinlp/autoprompt/autoprompt/create_trigger.py
code served (permissive licence) · get_code("bfaef19b1a497d58")
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, PredictWrapper: 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)

# Create a minimal model that returns logits
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 5)
    
    def forward(self, input_ids, attention_mask=None):
        # input_ids shape: (batch_size, seq_len)
        # output logits shape: (batch_size, seq_len, vocab_size)
        batch_size, seq_len = input_ids.shape
        logits = self.linear(torch.randn(batch_size, seq_len, 4))
        return logits,

# Instantiate the model
model = MinimalModel()

# Create model_inputs dict with required keys
batch_size = 2
seq_len = 3
vocab_size = 5

model_inputs = {
    'input_ids': torch.randint(0, vocab_size, (batch_size, seq_len)),
    'attention_mask': torch.ones(batch_size, seq_len),
    'trigger_mask': torch.zeros(batch_size, seq_len, dtype=torch.bool),
    'predict_mask': torch.zeros(batch_size, seq_len, dtype=torch.bool),
}

# Set some positions to True for trigger_mask and predict_mask so operations are non-trivial
model_inputs['trigger_mask'][0, 0] = True
model_inputs['trigger_mask'][1, 1] = True
model_inputs['predict_mask'][0, 2] = True
model_inputs['predict_mask'][1, 0] = True

# Create trigger_ids tensor (num_trigger_tokens, embedding_dim)
# Using shape (1, 4) to be compatible with repeat operation
trigger_ids = torch.randint(0, vocab_size, (1, seq_len))

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 PredictWrapper — 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 PredictWrapper 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
TriggerTemplatizer Ran
ran on a synthesized input · constructed an object; no result was computed
ucinlp/autoprompt/autoprompt/create_trigger.py
code served (permissive licence) · get_code("cb904be0b5c6abc4")
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, TriggerTemplatizer: 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)

# Stand-in tokenizer class with required attributes and methods
class StandInTokenizer:
    def __init__(self):
        self.trigger_token = "[T]"
        self.trigger_token_id = 100
        self.predict_token = "[P]"
        self.predict_token_id = 101
        self.mask_token_id = 103
        self.sep_token = "[SEP]"
        self.unk_token = "[UNK]"
        self.vocab = {
            "[T]": 100,
            "[P]": 101,
            "[SEP]": 102,
            "[MASK]": 103,
            "[UNK]": 104,
            "premise": 1,
            "hypothesis": 2,
            "text": 3,
        }
    
    def tokenize(self, text):
        # Simple tokenization: return single token for valid inputs
        if text in self.vocab:
            return [text]
        return [self.unk_token]
    
    def convert_tokens_to_ids(self, tokens):
        return [self.vocab.get(t, 104) for t in tokens]
    
    def encode_plus(self, text, add_special_tokens=False, return_tensors='pt'):
        # Simple mock encoding
        input_ids = torch.tensor([[100, 1, 101, 2, 103]], dtype=torch.long)
        attention_mask = torch.tensor([[1, 1, 1, 1, 1]], dtype=torch.long)
        token_type_ids = torch.tensor([[0, 0, 0, 1, 1]], dtype=torch.long)
        return {
            'input_ids': input_ids,
            'attention_mask': attention_mask,
            'token_type_ids': token_type_ids,
        }

# Stand-in config class
class StandInConfig:
    def __init__(self):
        self.model_type = 'bert'

# Create tokenizer and config instances
tokenizer = StandInTokenizer()
config = StandInConfig()

# Template with trigger and predict placeholders
template = "[T] [T] {premise} [P] {hypothesis}"

# Label map for mapping label strings to other values
label_map = {
    "entailment": "entail",
    "neutral": "neut",
    "contradiction": "contra"
}

ARGS = {
    'template': template,
    'config': config,
    'tokenizer': tokenizer,
    'label_field': 'label',
    'label_map': label_map,
    'tokenize_labels': False,
    'add_special_tokens': False,
    'use_ctx': False,
}
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 TriggerTemplatizer — 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 TriggerTemplatizer 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
load_trigger_dataset Ran
ran; our contract draft was wrong, not the code
ucinlp/autoprompt/autoprompt/create_trigger.py
code served (permissive licence) · get_code("c8fc624ca613854e")
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 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 json
import logging
import random
import csv
from pathlib import Path
from unittest.mock import MagicMock, patch
import tempfile
import os

# Set seed for reproducibility
random.seed(0)

# Create a temporary directory and files for testing
temp_dir = tempfile.mkdtemp()

# Create a dummy JSONL file
jsonl_file = os.path.join(temp_dir, 'test.jsonl')
with open(jsonl_file, 'w') as f:
    f.write(json.dumps({'relation': 'founded', 'subject': 'Company', 'object': 'Person', 'evidences': [{'obj_surface': 'John', 'masked_sentence': 'John [MASK] the company in 2020'}]}) + '\n')
    f.write(json.dumps({'relation': 'founded', 'subject': 'Company', 'object': 'Person', 'evidences': [{'obj_surface': 'Jane', 'masked_sentence': 'Jane [MASK] another firm last year'}]}) + '\n')

# Create a dummy TSV file
tsv_file = os.path.join(temp_dir, 'test.tsv')
with open(tsv_file, 'w') as f:
    f.write('relation\tsubject\tobject\tevidences\n')
    f.write('founded\tCompany\tPerson\t{"obj_surface": "Bob", "masked_sentence": "Bob [MASK] the startup"}\n')

# Create a mock templatizer function
def mock_templatizer(x):
    # Returns tuple of (model_inputs, label_id)
    model_inputs = {'input_ids': [1, 2, 3], 'attention_mask': [1, 1, 1]}
    label_id = 0
    return model_inputs, label_id

ARGS = {
    'fname': Path(jsonl_file),
    'templatizer': mock_templatizer,
    'use_ctx': True,
    'limit': 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 list, ndim 2, 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
GA Not yet run
unverified (harvested, no recorded run)
SawanKumar28/pero/src/opt_utils.py
code served (permissive licence) · get_code("fa053ba6d77847c8")
How it ran

no invocation recorded.

PermutationHandler Not yet run
unverified (harvested, no recorded run)
SawanKumar28/pero/src/opt_utils.py
code served (permissive licence) · get_code("ce83164ae06e5fae")
How it ran

no invocation recorded.

SInstance Not yet run
unverified (harvested, no recorded run)
SawanKumar28/pero/src/opt_utils.py
code served (permissive licence) · get_code("8bda67b843418308")
How it ran

no invocation recorded.

run_model Not yet run
unverified (harvested, no recorded run)
ucinlp/autoprompt/autoprompt/create_trigger.py
code served (permissive licence) · get_code("de4d142f8cd18f36")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 6 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
run_model
brick of this paper's assembly: entry
1 other paper
1 later
2305.17826 (2023-05)
NOTABLE: Transferable Backdoor Attacks Against Prompt-based NLP Models

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

Repositories linked to this paper

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

Abstract

The ability to learn from limited data, or fewshot learning, is a desirable and often critical requirement for NLP systems. While many existing methods do poorly at learning from a handful of examples, large pretrained language models have recently been shown to be efficient few-shot learners. One approach to few-shot learning, which does not require finetuning of model parameters, is to augment the language model's input with priming text which is typically constructed using task specific descriptions and examples. In this work, we further explore priming-based few-shot learning, with focus on using examples as prompts. We show that presenting examples in the right order is key for generalization. We introduce PERO (Prompting with Examples in the Right Order), where we formulate few-shot learning as search over the set of permutations of the training examples. We show that PERO can learn to generalize efficiently using as few as 10 examples, in contrast to existing approaches. While the newline token is a natural choice for separating the examples in the prompt, we show that learning a new separator token can potentially provide further gains in performance. We demonstrate the effectiveness of the proposed method on the tasks of sentiment classification, natural language inference and fact retrieval. Finally, we analyze the learned prompts to reveal novel insights, including the idea that two training examples in the right order alone can provide competitive performance for sentiment classification and natural language inference.

For agents

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

get_harvested_code_for_paper("2106.01751")
get_code_for_paper("2106.01751")
have("2106.01751")

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

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

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

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

Connect an agent — have() is free.