SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.02135 · ACL · 2022

Continual Few-shot Relation Learning via Embedding Space Regularization and Data Augmentation

Shafiq Joty, Chengwei Qin

arXiv · PDF · Open in the Atlas

Code that ran

9 of 11 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, 3 violated it and 3 have no contract verdict; 3 failures of our instrument; 2 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/2203.02135.json · badge: /api/ran/2203.02135.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
qcwthu/Continual_Fewshot_Relation_Learning canonical (classifier label)
classifier basis not recorded on the link
9 ran · 2 no recorded run
FunctionStatusWhere it lives
Embedding Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
qcwthu/Continual_Fewshot_Relation_Learning/encode.py
code served (permissive licence) · get_code("7497a06fca17f761")
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, Embedding: 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)

ARGS = {
    "num_embeddings": 10,
    "embedding_dim": 4,
    "padding_idx": 0,
}
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 Embedding — 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 Embedding 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
Linear Ran
ran; our contract draft was wrong, not the code · constructed an object; no result was computed
qcwthu/Continual_Fewshot_Relation_Learning/encode.py
code served (permissive licence) · get_code("7c9c467b89b5d13a")
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, Linear: 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)

ARGS = {
    "in_features": 4,
    "out_features": 3,
    "bias": True,
    "uniform": True,
}
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 Linear — 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 Linear 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_data_loader Ran
ran on a synthesized input
qcwthu/Continual_Fewshot_Relation_Learning/dataprocess.py
code served (permissive licence) · get_code("5edf8da61fe5e77f")
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 DataLoader. 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
from torch.utils.data import Dataset, DataLoader

torch.manual_seed(0)

# Create sample data matching the expected structure
# Each item has 12 elements as expected by collate_fn
sample_data = [
    (
        0,  # labels
        [1, 2],  # neg_labels
        [10, 11, 12],  # sentences
        [20, 21],  # firstent
        [30],  # firstentindex
        [40, 41],  # secondent
        [50],  # secondentindex
        "head_id_1",  # headid
        "tail_id_1",  # tailid
        "raw text 1",  # rawtext
        5,  # lengths
        0  # typelabels
    ),
    (
        1,  # labels
        [3, 4],  # neg_labels
        [13, 14, 15],  # sentences
        [22, 23],  # firstent
        [31],  # firstentindex
        [42, 43],  # secondent
        [51],  # secondentindex
        "head_id_2",  # headid
        "tail_id_2",  # tailid
        "raw text 2",  # rawtext
        6,  # lengths
        1  # typelabels
    )
]

# Create config dict with required keys
config = {
    'batch_size_per_step': 2,
    'num_workers': 0
}

ARGS = {
    'config': config,
    'data': sample_data,
    'shuffle': True,
    'drop_last': False,
    'batch_size': None
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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_data_loader_bert Ran
ran on a synthesized input
qcwthu/Continual_Fewshot_Relation_Learning/dataprocess.py
code served (permissive licence) · get_code("1d30aff6c872ffdd")
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 DataLoader. 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
from torch.utils.data import Dataset, DataLoader

torch.manual_seed(0)

# Create sample data matching the expected structure
# Each item should have 13 elements (0-12)
sample_data = []
for i in range(2):  # 2 samples
    item = (
        0,  # labels (item[0])
        [1, 2],  # neg_labels (item[1])
        torch.randint(0, 100, (5,)),  # sentences (item[2])
        torch.randint(0, 50, (3,)),  # firstent (item[3])
        torch.randint(0, 10, (2,)),  # firstentindex (item[4])
        torch.randint(0, 50, (3,)),  # secondent (item[5])
        torch.randint(0, 10, (2,)),  # secondentindex (item[6])
        "head_entity_123",  # headid (item[7])
        "tail_entity_456",  # tailid (item[8])
        "This is a raw text example",  # rawtext (item[9])
        5,  # lenghts (item[10])
        1,  # typelabels (item[11])
        torch.ones(5),  # masks (item[12])
    )
    sample_data.append(item)

# Create a config dict with required keys
config = {
    'batch_size_per_step': 2,
    'num_workers': 0,
}

ARGS = {
    'config': config,
    'data': sample_data,
    'shuffle': True,
    'drop_last': False,
    'batch_size': None,
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
is_control Ran
ran, violated the contract we drafted
qcwthu/Continual_Fewshot_Relation_Learning/tokenizer_utils.py
code served (permissive licence) · get_code("f1abdadc8b1d945f")
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 bool, 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 unicodedata

ARGS = {
    'char': '\t'
}
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 bool, 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
is_punctuation Ran
ran, violated the contract we drafted
qcwthu/Continual_Fewshot_Relation_Learning/tokenizer_utils.py
code served (permissive licence) · get_code("d03ac46217ff786c")
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 bool, 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 unicodedata

def is_punctuation(char):
    """ Checks whether `chars` is a punctuation character.
        We treat all non-letter/number ASCII as punctuation. Characters such as "^", "$", and "`" are not in the Unicode.
        Punctuation class but we treat them as punctuation anyways, for consistency.
    """
    cp = ord(char)
    if cp >= 33 and cp <= 47 or (cp >= 58 and cp <= 64) or (cp >= 91 and cp <= 96) or (cp >= 123 and cp <= 126):
        return True
    cat = unicodedata.category(char)
    if cat.startswith('P'):
        return True
    return False

ARGS = {
    "char": "."
}
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 bool, 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
is_whitespace Ran
ran, violated the contract we drafted
qcwthu/Continual_Fewshot_Relation_Learning/tokenizer_utils.py
code served (permissive licence) · get_code("718becf254f28728")
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 bool, 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 unicodedata

def is_whitespace(char):
    """    Checks whether `chars` is a whitespace character.
        	, 
, and \r are technically contorl characters but we treat them
        as whitespace since they are generally considered as such.
    """
    if char == ' ' or char == '\t' or char == '\n' or (char == '\r'):
        return True
    cat = unicodedata.category(char)
    if cat == 'Zs':
        return True
    return False


ARGS = {
    'char': ' '
}
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 bool, 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
readtrain Ran
ran on a synthesized input
qcwthu/Continual_Fewshot_Relation_Learning/util.py
code served (permissive licence) · get_code("7b5724cc4fff4df2")
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 tempfile
import os

# Create a temporary file with valid tab-separated data
# Format: rel\tfield2\tfield3\tfield4\tfield5\tfield6\tfield7\tfield8\tfield9
temp_file = tempfile.NamedTemporaryFile(mode='w', delete=False, suffix='.txt')
temp_filename = temp_file.name

# Write test data with 9 tab-separated fields
# rel (int) followed by 8 other fields
temp_file.write("1\tdata1\tdata2\tdata3\tdata4\tdata5\tdata6\tdata7\tdata8\n")
temp_file.write("1\tdata9\tdata10\tdata11\tdata12\tdata13\tdata14\tdata15\tdata16\n")
temp_file.write("2\tdata17\tdata18\tdata19\tdata20\tdata21\tdata22\tdata23\tdata24\n")
temp_file.write("1\tdata25\tdata26\tdata27\tdata28\tdata29\tdata30\tdata31\tdata32\n")
temp_file.close()

ARGS = {
    "filename": temp_filename
}
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
scaled_attention Ran
ran; our contract draft was wrong, not the code
qcwthu/Continual_Fewshot_Relation_Learning/encode.py
code served (permissive licence) · get_code("b3efa486a955e3d6")
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. 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.functional as F
import math

torch.manual_seed(0)

# Construct tensors for scaled_attention
batch_size = 2
seq_len = 3
d_k = 4

query = torch.randn(batch_size, seq_len, d_k)
key = torch.randn(batch_size, seq_len, d_k)
value = torch.randn(batch_size, seq_len, d_k)

# Create a mask tensor with shape (batch_size, seq_len, seq_len)
# False means don't mask, True means mask (set to -inf)
mask = torch.zeros(batch_size, seq_len, seq_len, dtype=torch.bool)
# Mask out future positions (causal mask)
for i in range(seq_len):
    mask[:, i, i+1:] = True

ARGS = {
    "query": query,
    "key": key,
    "value": value,
    "mask": mask
}
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 — a tuple output has no array shape of its own; none is 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
getnegfrombatch Not yet run
unverified (harvested, no recorded run)
qcwthu/Continual_Fewshot_Relation_Learning/util.py
code served (permissive licence) · get_code("4d6a49d8e316e10a")
How it ran

no invocation recorded.

transtonpy Not yet run
unverified (harvested, no recorded run)
qcwthu/Continual_Fewshot_Relation_Learning/util.py
code served (permissive licence) · get_code("3812b439d1dc6a6b")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 6 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 0 the same month, 4 later) and 5 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
Linear 4 other papers
3 dated earlier, 1 later · 1 only as an assembly brick
1905.05621 (2019-05)
Style Transformer: Unpaired Text Style Transfer without Disentangled Latent Representation
2002.03912 (2020-02)
A Probabilistic Formulation of Unsupervised Text Style Transfer
2106.02210 (2021-06)
NAST: A Non-Autoregressive Generator with Word Alignment for Unsupervised Text Style Transfer
and 1 more not named here
Embedding 3 other papers
3 dated earlier · 1 only as an assembly brick
1905.05621 (2019-05)
Style Transformer: Unpaired Text Style Transfer without Disentangled Latent Representation
2002.03912 (2020-02)
A Probabilistic Formulation of Unsupervised Text Style Transfer
2106.02210 (2021-06)
NAST: A Non-Autoregressive Generator with Word Alignment for Unsupervised Text Style Transfer
scaled_attention 3 other papers
3 dated earlier · 1 only as an assembly brick
1905.05621 (2019-05)
Style Transformer: Unpaired Text Style Transfer without Disentangled Latent Representation
2002.03912 (2020-02)
A Probabilistic Formulation of Unsupervised Text Style Transfer
2106.02210 (2021-06)
NAST: A Non-Autoregressive Generator with Word Alignment for Unsupervised Text Style Transfer
is_control 1 other paper
1 later
2309.07311 (2023-09)
Sudden Drops in the Loss: Syntax Acquisition, Phase Transitions, and Simplicity Bias in MLMs
is_punctuation 1 other paper
1 later
2309.07311 (2023-09)
Sudden Drops in the Loss: Syntax Acquisition, Phase Transitions, and Simplicity Bias in MLMs
is_whitespace 1 other paper
1 later
2023.findings-emnlp.1050 (2023 (year only))
Orca: A Few-shot Benchmark for Chinese Conversational Machine Reading Comprehension

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

Existing continual relation learning (CRL) methods rely on plenty of labeled training data for learning a new task, which can be hard to acquire in real scenario as getting large and representative labeled data is often expensive and time-consuming. It is therefore necessary for the model to learn novel relational patterns with very few labeled data while avoiding catastrophic forgetting of previous task knowledge. In this paper, we formulate this challenging yet practical problem as continual few-shot relation learning (CFRL). Based on the finding that learning for new emerging few-shot tasks often results in feature distributions that are incompatible with previous tasks' learned distributions, we propose a novel method based on embedding space regularization and data augmentation. Our method generalizes to new fewshot tasks and avoids catastrophic forgetting of previous tasks by enforcing extra constraints on the relational embeddings and by adding extra relevant data in a self-supervised manner. With extensive experiments we demonstrate that our method can significantly outperform previous state-of-the-art methods in CFRL task settings. 1

For agents

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

get_harvested_code_for_paper("2203.02135")
get_code_for_paper("2203.02135")
have("2203.02135")

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

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

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

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

Connect an agent — have() is free.