SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2009.13891 · 2020

Towards Effective Context for Meta-Reinforcement Learning: an Approach based on Contrastive Learning

arXiv · PDF · Open in the Atlas

Code that ran

4 of 5 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; 0 honoured the contract we drafted, 0 violated it and 3 have no contract verdict; 1 failure of our instrument; 1 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/2009.13891.json · badge: /api/ran/2009.13891.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
TJU-DRL-LAB/self-supervised-rl canonical (classifier label)
classifier basis: census
4 ran · 1 no recorded run
FunctionStatusWhere it lives
deep_update_dict Ran
ran; our contract draft was wrong, not the code
TJU-DRL-LAB/self-supervised-rl/RL_with_Environment_Representation/ccm/launch_experiment.py
code served (permissive licence) · get_code("e937b70b07bfc9d1")
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) 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 numpy as np

torch.manual_seed(0)

# Analyze the function:
# - deep_update_dict(fr, to) takes two parameters
# - It iterates over items in 'fr' dict
# - For each value, if it's a dict, recursively calls deep_update_dict(v, to[k])
# - Otherwise, updates to[k] = v
# - Returns the updated 'to' dict

# Construct test arguments:
# 'fr' should be a dict with nested dicts and scalar values
# 'to' should be a dict with matching structure to be updated

fr = {
    "model": {
        "learning_rate": 0.001,
        "batch_size": 32,
        "layers": {
            "hidden_dim": 128,
            "dropout": 0.5
        }
    },
    "training": {
        "epochs": 10,
        "optimizer": "adam"
    },
    "seed": 42
}

to = {
    "model": {
        "learning_rate": 0.01,
        "batch_size": 16,
        "layers": {
            "hidden_dim": 64,
            "dropout": 0.3
        }
    },
    "training": {
        "epochs": 5,
        "optimizer": "sgd"
    },
    "seed": 0
}

ARGS = {
    "fr": fr,
    "to": to
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, 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
make_one_hot Ran
ran on a synthesized input
TJU-DRL-LAB/self-supervised-rl/RL_with_Environment_Representation/PAnDR/env_utils.py
code served (permissive licence) · get_code("94587585389ef56a")
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 (2, 4) 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)

# x should be a tensor containing integer indices
# Looking at the function:
# - x is reshaped to (batch_size, 1)
# - y.long() is called on it
# - scatter_ is used with it as indices
# So x should be a 1D or 2D tensor of integers

batch_size = 2
nb_digits = 4

# Create a small tensor of integer indices (values should be < nb_digits)
x = torch.tensor([0, 2], dtype=torch.long)

ARGS = {
    "x": x,
    "nb_digits": nb_digits,
    "batch_size": batch_size,
}
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 (2, 4) — shape (2, 4) 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
post_process Ran
ran on a synthesized input
TJU-DRL-LAB/self-supervised-rl/RL_with_Environment_Representation/ccm/plot_csv.py
code served (permissive licence) · get_code("a26c4433e3e83ea7")
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 numpy as np
import argparse
import sys
from io import StringIO

# Mock sys.argv to provide command-line arguments
sys.argv = ['script.py', '--seed', '0', '--max_m', '100', '--smooth_coeff', '25', 
            '--env_name', 'mt10', '--log_dir', './log', '--id', 'origin', 
            '--output_dir', './fig', '--entry', 'Running_Average_Rewards', '--add_tag', '']

def get_args():
    parser = argparse.ArgumentParser(description='RL')
    parser.add_argument('--seed', type=int, nargs='+', default=(0,), help='random seed (default: (0,))')
    parser.add_argument('--max_m', type=int, default=None, help='maximum million')
    parser.add_argument('--smooth_coeff', type=int, default=25, help='smooth coeff')
    parser.add_argument('--env_name', type=str, default='mt10', help='environment trained on (default: mt10)')
    parser.add_argument('--log_dir', type=str, default='./log', help='directory for tensorboard logs (default: ./log)')
    parser.add_argument('--id', type=str, nargs='+', default=('origin',), help='id for tensorboard')
    parser.add_argument('--tags', type=str, nargs='+', default=None, help='id for tensorboard')
    parser.add_argument('--output_dir', type=str, default='./fig', help='directory for plot output (default: ./fig)')
    parser.add_argument('--entry', type=str, default='Running_Average_Rewards', help='Record Entry')
    parser.add_argument('--add_tag', type=str, default='', help='added tag')
    args = parser.parse_args()
    return args

args = get_args()

def post_process(array):
    smoth_para = args.smooth_coeff
    new_array = []
    for i in range(len(array)):
        if i < len(array) - smoth_para:
            new_array.append(np.mean(array[i:i + smoth_para]))
        else:
            new_array.append(np.mean(array[i:None]))
    return new_array

# Create test data for the post_process function
test_array = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 
                       11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 19.0, 20.0,
                       21.0, 22.0, 23.0, 24.0, 25.0, 26.0, 27.0, 28.0, 29.0, 30.0])

ARGS = {
    'array': test_array
}
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 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
save_model Ran
ran on a synthesized input
TJU-DRL-LAB/self-supervised-rl/RL_with_Environment_Representation/PAnDR/pandr_utils.py
code served (permissive licence) · get_code("a89da1a0ff56ede9")
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
import tempfile
import os

torch.manual_seed(0)

# Create a minimal model
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)
    
    def forward(self, x):
        return self.linear(x)

# Create a minimal optimizer
model = MinimalModel()
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)

# Create a minimal args object with __dict__
class Args:
    def __init__(self):
        self.learning_rate = 0.01
        self.batch_size = 2
        self.epochs = 10

args = Args()

# Create temporary save directory
save_dir = tempfile.mkdtemp()

ARGS = {
    'prefix': 'model_checkpoint',
    'model': model,
    'optimizer': optimizer,
    'num_epoch': 5,
    'args': args,
    'suffix': '_final',
    'policy_embedding': True,
    'save_dir': save_dir
}
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
torch_load Not yet run
unverified (harvested, no recorded run)
TJU-DRL-LAB/self-supervised-rl/RL_with_Environment_Representation/PAnDR/pandr_utils.py
code served (permissive licence) · get_code("f500cf83b3947999")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (1 with at least one paper dated earlier, 0 the same month, 1 later) and 4 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
deep_update_dict 13 other papers
2 dated earlier, 11 later
1903.08254 (2019-03)
Efficient Off-Policy Meta-Reinforcement Learning via Probabilistic Context Variables
2006.08170 (2020-06)
MetaCURE: Meta Reinforcement Learning with Empowerment-Driven Exploration
2010.01112 (2020-10)
FOCAL: Efficient Fully-Offline Meta-Reinforcement Learning via Distance Metric Learning and Behavior Regularization
and 10 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-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

Context, the embedding of previous collected trajectories, is a powerful construct for Meta-Reinforcement Learning (Meta-RL) algorithms. By conditioning on an effective context, Meta-RL policies can easily generalize to new tasks within a few adaptation steps. We argue that improving the quality of context involves answering two questions: 1. How to train a compact and sufficient encoder that can embed the task-specific information contained in prior trajectories? 2. How to collect informative trajectories of which the corresponding context reflects the specification of tasks? To this end, we propose a novel Meta-RL framework called CCM (Contrastive learning augmented Context-based Meta-RL). We first focus on the contrastive nature behind different tasks and leverage it to train a compact and sufficient context encoder. Further, we train a separate exploration policy and theoretically derive a new information-gain-based objective which aims to collect informative trajectories in a few steps. Empirically, we evaluate our approaches on common benchmarks as well as several complex sparse-reward environments. The experimental results show that CCM outperforms state-of-the-art algorithms by addressing previously mentioned problems respectively.

For agents

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

get_harvested_code_for_paper("2009.13891")
get_code_for_paper("2009.13891")
have("2009.13891")

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

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

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

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

Connect an agent — have() is free.