SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2405.10548 · ACL · 2024

Language Models can Exploit Cross-Task In-context Learning for Data-Scarce Novel Tasks

Subhabrata Dutta, Tanmoy Chakraborty, Anwoy Chatterjee, Eshaan Tanwar

arXiv · PDF · Open in the Atlas

Code that ran

7 of 9 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; 2 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 4 failures of our instrument; 2 no recorded run), measured 2026-11-23; 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/2405.10548.json · badge: /api/ran/2405.10548.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
C-anwoy/Cross-Task-ICL canonical (classifier label)
classifier basis: census
7 ran · 2 no recorded run
FunctionStatusWhere it lives
call_model Ran
ran; our contract draft was wrong, not the code
C-anwoy/Cross-Task-ICL/LLAMA-abalations-random.py
code served (permissive licence) · get_code("00eba4d4d2e34691")
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
import torch.nn as nn

torch.manual_seed(0)

class MockTokenizer:
    def __init__(self):
        self.model_max_length = 2048
        self.eos_token_id = 2
        self.vocab_size = 100
    
    def __call__(self, prompt, return_tensors=None, truncation=False, max_length=None):
        # Simulate tokenization: return a simple batch with input_ids and attention_mask
        input_ids = torch.randint(0, self.vocab_size, (1, 10), dtype=torch.long)
        attention_mask = torch.ones((1, 10), dtype=torch.long)
        return MockTokenizerOutput(input_ids, attention_mask)
    
    def decode(self, token_ids):
        # Simple mock decode: just return a string based on token content
        if isinstance(token_ids, torch.Tensor):
            token_ids = token_ids.tolist()
        return "This is a test output"

class MockTokenizerOutput:
    def __init__(self, input_ids, attention_mask):
        self.input_ids = input_ids
        self.attention_mask = attention_mask
    
    def to(self, device):
        self.input_ids = self.input_ids.to(device)
        self.attention_mask = self.attention_mask.to(device)
        return self

class MockModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 4)
    
    def generate(self, input_ids, attention_mask, pad_token_id, max_new_tokens, num_beams, do_sample):
        # Return a simple tensor of generated token ids
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1] + max_new_tokens
        return torch.randint(0, 100, (batch_size, seq_len), dtype=torch.long)

prompt = "Hello, how are you?"
model = MockModel()
tokenizer = MockTokenizer()
device = "cpu"

ARGS = {
    "prompt": prompt,
    "model": model,
    "tokenizer": tokenizer,
    "device": device,
    "max_new_tokens": 10,
    "model_max_length": 2048
}
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
create_embedding Ran
ran, honoured the contract we drafted
C-anwoy/Cross-Task-ICL/utils/llm.py
code served (permissive licence) · get_code("64ac3a4563570515")
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 2, dtype family float, shape (1, 8) 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
import torch.nn as nn

torch.manual_seed(0)

class MockEmbeddingModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 8)
    
    def encode(self, data, convert_to_tensor=False):
        # Simulate encoding: take input and return a tensor
        if isinstance(data, str):
            # If data is string, create a dummy tensor
            output = torch.randn(1, 8)
        else:
            # If data is already a tensor
            output = self.linear(data)
        return output

# Create mock model
model = MockEmbeddingModel()

# Create mock data - can be a string or tensor
data = "sample text"

ARGS = {
    "data": data,
    "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 Tensor, ndim 2, dtype family float, shape (1, 8) — shape (1, 8) 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
get_combined_source_dataset Ran
ran; our contract draft was wrong, not the code
C-anwoy/Cross-Task-ICL/LLAMA-abalations.py
code served (permissive licence) · get_code("5de5f3647524eb25")
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 numpy as np

# Build the nested dictionary structure required by the function
prompts_in_dataset = {
    'source1': {
        'instruction-source': 'Translate English to French',
        'prompts': [
            {
                'source-demonstrations': ['Example 1: Hello -> Bonjour'],
                'target-input': 'Good morning',
                'id': 'id_001',
                'label': 'translation'
            },
            {
                'source-demonstrations': ['Example 2: Goodbye -> Au revoir'],
                'target-input': 'See you later',
                'id': 'id_002',
                'label': 'translation'
            }
        ]
    },
    'source2': {
        'instruction-source': 'Summarize text',
        'prompts': [
            {
                'source-demonstrations': ['Long text -> Short summary'],
                'target-input': 'Summary input 1',
                'id': 'id_001',
                'label': 'summary'
            },
            {
                'source-demonstrations': ['Another long text -> Another summary'],
                'target-input': 'Summary input 2',
                'id': 'id_002',
                'label': 'summary'
            }
        ]
    },
    'source3': {
        'instruction-source': 'Generate questions',
        'prompts': [
            {
                'source-demonstrations': ['Text -> Question about text'],
                'target-input': 'Question input 1',
                'id': 'id_001',
                'label': 'qa'
            },
            {
                'source-demonstrations': ['More text -> More questions'],
                'target-input': 'Question input 2',
                'id': 'id_002',
                'label': 'qa'
            }
        ]
    },
    'source4': {
        'instruction-source': 'Classify sentiment',
        'prompts': [
            {
                'source-demonstrations': ['Positive text -> Positive'],
                'target-input': 'Sentiment input 1',
                'id': 'id_001',
                'label': 'sentiment'
            },
            {
                'source-demonstrations': ['Negative text -> Negative'],
                'target-input': 'Sentiment input 2',
                'id': 'id_002',
                'label': 'sentiment'
            }
        ]
    }
}

source_dataset_names = ['source1', 'source2', 'source3', 'source4']

target_instruction = 'Perform multi-task learning'

ARGS = {
    'prompts_in_dataset': prompts_in_dataset,
    'source_dataset_names': source_dataset_names,
    'target_instruction': target_instruction
}
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 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_llm_emb Ran
ran, honoured the contract we drafted
C-anwoy/Cross-Task-ICL/utils/llm.py
code served (permissive licence) · get_code("909d7f2bdccf6dfe")
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
import torch.nn as nn

torch.manual_seed(0)

# Create a minimal LLM model that returns hidden_states
class MinimalLLM(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.embedding = nn.Embedding(100, hidden_size)
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, input_ids, attention_mask=None, output_hidden_states=False, return_dict=False):
        # Create embeddings from input_ids
        x = self.embedding(input_ids)  # shape: (batch, seq_len, hidden_size)
        x = self.linear(x)
        
        # Return object with hidden_states attribute
        class Output:
            def __init__(self, hidden_states):
                self.hidden_states = hidden_states
        
        # hidden_states is a tuple of tensors, last one is the final layer output
        if output_hidden_states and return_dict:
            return Output(hidden_states=(x,))
        return Output(hidden_states=(x,))

# Create a minimal tokenizer that returns input_ids and attention_mask
class MinimalTokenizer:
    def __call__(self, text, return_tensors=None):
        # Simple tokenization: just map each character to a token id
        if isinstance(text, str):
            token_ids = [ord(c) % 100 for c in text[:10]]  # Keep it short, map to 0-99
        else:
            token_ids = [1, 2, 3, 4]  # fallback
        
        input_ids = torch.tensor([token_ids], dtype=torch.long)
        attention_mask = torch.ones_like(input_ids)
        
        class TokenizerOutput:
            def __init__(self, input_ids, attention_mask):
                self.input_ids = input_ids
                self.attention_mask = attention_mask
            
            def to(self, device):
                return self
            
            def keys(self):
                return ['input_ids', 'attention_mask']
            
            def __getitem__(self, key):
                if key == 'input_ids':
                    return self.input_ids
                elif key == 'attention_mask':
                    return self.attention_mask
        
        return TokenizerOutput(input_ids, attention_mask)

llm_model = MinimalLLM(hidden_size=4)
llm_tokenizer = MinimalTokenizer()
text = "hello world"
device = 'cpu'

ARGS = {
    'text': text,
    'llm_model': llm_model,
    'llm_tokenizer': llm_tokenizer,
    '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 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
load_dataset Ran
ran on a synthesized input
C-anwoy/Cross-Task-ICL/utils/data.py
code served (permissive licence) · get_code("982e3655e9695d47")
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 pickle
import tempfile
import os

# Create a temporary directory structure for the test
temp_dir = tempfile.mkdtemp()
data_dir = os.path.join(temp_dir, 'data', 'benchmark1')
os.makedirs(data_dir, exist_ok=True)

# Create a mock dataset and save it as pickle
mock_dataset = {
    'samples': [1, 2, 3, 4, 5],
    'labels': ['a', 'b', 'c', 'd', 'e']
}

pkl_path = os.path.join(data_dir, 'dataset1_train.pkl')
with open(pkl_path, 'wb') as f:
    pickle.dump(mock_dataset, f)

# Change to temp directory so relative paths work
original_dir = os.getcwd()
os.chdir(temp_dir)

ARGS = {
    'benchmark': 'benchmark1',
    'dataset_name': 'dataset1',
    'set': 'train'
}
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
load_prompts Ran
ran; our contract draft was wrong, not the code
C-anwoy/Cross-Task-ICL/utils/data.py
code served (permissive licence) · get_code("e401d40128e5c42a")
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 pickle
import tempfile
import os

# Create a temporary directory and a mock pickle file
temp_dir = tempfile.mkdtemp()
data_dir = os.path.join(temp_dir, 'data', 'target-prompts')
os.makedirs(data_dir, exist_ok=True)

# Create a mock test_set (could be a list, dict, or any pickle-able object)
mock_test_set = [
    {'prompt': 'What is AI?', 'response': 'AI is artificial intelligence'},
    {'prompt': 'What is ML?', 'response': 'ML is machine learning'},
    {'prompt': 'What is DL?', 'response': 'DL is deep learning'},
    {'prompt': 'What is NLP?', 'response': 'NLP is natural language processing'},
]

# Save the mock test_set to a pickle file
pickle_path = os.path.join(data_dir, 'test_prompts_k=4.pkl')
with open(pickle_path, 'wb') as f:
    pickle.dump(mock_test_set, f)

# Change to the temporary directory so relative paths work
original_dir = os.getcwd()
os.chdir(temp_dir)

ARGS = {
    'dataset_name': 'test',
    'path_d': 'target-prompts',
    'k': 4,
}
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 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
make_prompt Ran
ran; our contract draft was wrong, not the code
C-anwoy/Cross-Task-ICL/LLAMA-psudo.py
code served (permissive licence) · get_code("64e4f9b4c5d53a6b")
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 numpy as np

torch.manual_seed(0)

# Analyze the function usage:
# - source_prompts: indexed with [:k], so needs to be a list/sequence of strings
# - source_instruction: string concatenated with 'Definition: '
# - target_prompts: string concatenated in input_part
# - target_instruction: string concatenated with 'Definition: '
# - k: integer used for slicing source_prompts[:k]
# - task_demo: string concatenated in input_part (default '')
# - demo: boolean that controls conditional logic (default False)

ARGS = {
    'source_prompts': [
        'The quick brown fox jumps over the lazy dog',
        'A cat sat on the mat',
        'Birds fly in the sky',
        'Fish swim in water'
    ],
    'source_instruction': 'Translate English to French',
    'target_prompts': 'The dog runs fast',
    'target_instruction': 'Translate English to Spanish',
    'k': 2,
    'task_demo': 'Example: ',
    'demo': True
}
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 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
force_decode Not yet run
unverified (harvested, no recorded run)
C-anwoy/Cross-Task-ICL/force_decode.py
code served (permissive licence) · get_code("83f6c004d81e3857")
How it ran

no invocation recorded.

get_combined_source_dataset Not yet run
unverified (harvested, no recorded run)
C-anwoy/Cross-Task-ICL/LLAMA-abalations-random.py
code served (permissive licence) · get_code("fb8470d7386eb6b5")
How it ran

no invocation recorded.

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 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 9 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-23.

Repositories linked to this paper

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

Abstract

Large Language Models (LLMs) have transformed NLP with their remarkable In-context Learning (ICL) capabilities. Automated assistants based on LLMs are gaining popularity; however, adapting them to novel tasks is still challenging. While colossal models excel in zero-shot performance, their computational demands limit widespread use, and smaller language models struggle without context. This paper investigates whether LLMs can generalize from labeled examples of predefined tasks to novel tasks. Drawing inspiration from biological neurons and the mechanistic interpretation of the Transformer architecture, we explore the potential for information sharing across tasks. We design a cross-task prompting setup with three LLMs and show that LLMs achieve significant performance improvements despite no examples from the target task in the context. Cross-task prompting leads to a remarkable performance boost of 107% for LLaMA-2 7B, 18.6% for LLaMA-2 13B, and 3.2% for GPT 3.5 on average over zeroshot prompting, and performs comparable to standard in-context learning. The effectiveness of generating pseudo-labels for in-task examples is demonstrated, and our analyses reveal a strong correlation between the effect of crosstask examples and model activation similarities in source and target input tokens. This paper offers a first-of-its-kind exploration of LLMs' ability to solve novel tasks based on contextual signals from different task examples.

For agents

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

get_harvested_code_for_paper("2405.10548")
get_code_for_paper("2405.10548")
have("2405.10548")

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

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

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

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

Connect an agent — have() is free.