SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2603.13459 · 2026

Reconciling In-Context and In-Weight Learning via Dual Representation Space Encoding

Tianren Zhang, Feng Chen, Guanyu Chen, Ruichen Wang

arXiv · PDF · Open in the Atlas

Code that ran

3 of 4 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 0 have no contract verdict; 2 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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/2603.13459.json · badge: /api/ran/2603.13459.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
McGuinnessChen/dual-representation-space-encoding canonical (classifier label)
classifier basis: census
3 ran · 1 no recorded run
FunctionStatusWhere it lives
custom_evaluation Ran
ran, honoured the contract we drafted
McGuinnessChen/dual-representation-space-encoding/conditional_pseudo_arithmetic.py
code served (permissive licence) · get_code("da0540e83b4ef8ad")
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 float, 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
import torch.nn as nn

torch.manual_seed(0)

# Define a minimal model that matches the function's usage
class MinimalModel(nn.Module):
    def __init__(self, vocab_size=100, hidden_size=4):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_size)
        self.linear = nn.Linear(hidden_size, vocab_size)
    
    def forward(self, input_ids, attention_mask, segment_ids):
        # Return logits with shape [batch_size, seq_len, vocab_size]
        x = self.embedding(input_ids)
        logits = self.linear(x)
        return (logits,)  # Return tuple to match outputs[0] indexing

# Define a minimal tokenizer (not actually used in the function)
class MinimalTokenizer:
    pass

# Create tiny eval dataset
eval_dataset = [
    {
        'input_ids': torch.tensor([1, 2, 3, 4]),
        'attention_mask': torch.tensor([1, 1, 1, 1]),
        'segment_ids': torch.tensor([0, 0, 1, 1]),
        'meta_prompt': 'prompt1',
        'meta_target': 'target1',
    },
    {
        'input_ids': torch.tensor([5, 6, 7, 8]),
        'attention_mask': torch.tensor([1, 1, 1, 0]),
        'segment_ids': torch.tensor([0, 1, 1, 0]),
        'meta_prompt': 'prompt2',
        'meta_target': 'target2',
    },
]

model = MinimalModel(vocab_size=100, hidden_size=4)
tokenizer = MinimalTokenizer()
device = 'cpu'

ARGS = {
    'model': model,
    'tokenizer': tokenizer,
    'eval_dataset': eval_dataset,
    'device': device,
    'batch_size': 2,
    'desc': 'Test Evaluation',
    'silent': False,
}
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 float, 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
prepare_seqs_for_transformer Ran
ran; our contract draft was wrong, not the code
McGuinnessChen/dual-representation-space-encoding/datasets/utils.py
code served (permissive licence) · get_code("8b429927b4700512")
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 _FlatMapDataset. 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 tensorflow.compat.v2 as tf

# Create a small dataset with the expected structure
def create_test_dataset():
    # Create sample data: batch_size=2, seq_len=3, height=8, width=8, channels=1
    examples = tf.constant(
        tf.random.uniform((2, 3, 8, 8, 1), dtype=tf.float32),
        dtype=tf.float32
    )
    labels = tf.constant([[1, 0, 1], [1, 1, 0]], dtype=tf.int32)
    
    # Create a dataset with the required structure
    def gen():
        yield {'example': examples, 'label': labels}
    
    ds = tf.data.Dataset.from_generator(
        gen,
        output_signature={
            'example': tf.TensorSpec(shape=(2, 3, 8, 8, 1), dtype=tf.float32),
            'label': tf.TensorSpec(shape=(2, 3), dtype=tf.int32)
        }
    )
    return ds

# Build the dataset
test_ds = create_test_dataset()

# Define arguments for the function
ARGS = {
    'ds': test_ds,
    'use_constant_labels': False,
    'interleave_targets': True,
    'downsample': False
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type _FlatMapDataset — a _FlatMapDataset output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a _FlatMapDataset 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
reduce_fn Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
McGuinnessChen/dual-representation-space-encoding/modules/losses.py
code served (permissive licence) · get_code("34959b5d69981166")
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 ArrayImpl, 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 jax.numpy as jnp
import numpy as np

# Create a simple numeric array/list to reduce
x = np.array([1.0, 2.0, 3.0, 4.0])

# Test with different reduction modes
ARGS = {
    'x': x,
    'mode': 'mean'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ArrayImpl, 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
get_pos_start Not yet run
unverified (harvested, no recorded run)
McGuinnessChen/dual-representation-space-encoding/modules/transformer_core.py
code served (permissive licence) · get_code("4821ab9352b9a1c1")
How it ran

no invocation recorded.

Also present in other papers' code

Of 4 samples lifted from this paper's linked repositories, 4 carry a function identity and 0 do not. Of the 4 distinct functions with an identity, 2 are also present in other papers whose code we hold (2 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
get_pos_start 1 other paper
1 dated earlier
2205.05055 (2022-05)
Data Distributional Properties Drive Emergent In-Context Learning in Transformers
reduce_fn 1 other paper
1 dated earlier
2205.05055 (2022-05)
Data Distributional Properties Drive Emergent In-Context Learning in Transformers

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 (ICL) is a valuable capability exhibited by Transformers pretrained on diverse sequence tasks. However, previous studies have observed that ICL often conflicts with the model's inherent in-weight learning (IWL) ability. By examining the representation space learned by a toy model in synthetic experiments, we identify the shared encoding space for context and samples in Transformers as a potential source of this conflict. To address this, we modify the model architecture to separately encode the context and samples into two distinct spaces: a task representation space and a sample representation space. We model these two spaces under a simple yet principled framework, assuming a linear representational structure and treating them as a pair of dual spaces. Both theoretical analysis and empirical results demonstrate the effectiveness of our proposed architecture, CoQE, in the single-value answer setting. It not only enhances ICL performance through improved representation learning, but also successfully reconciles ICL and IWL capabilities across synthetic fewshot classification and a newly designed pseudo-arithmetic task. The code is available at: https://github.com/McGuinnessChen/dual-representation-space-encoding. However, recent studies suggest that there exists an inherent conflict between ICL and IWL (Park et al., 2025;Nguyen & Reddy, 2025). This leads to a notable performance degradation when the demonstration examples deviate from the training distribution (Chan et al., 2025), thereby limiting the generalization ability † Co-corresponding authors.

For agents

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

get_harvested_code_for_paper("2603.13459")
get_code_for_paper("2603.13459")
have("2603.13459")

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

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

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

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

Connect an agent — have() is free.