SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2203.00357 · ACL Findings · 2022

MERIt: Meta-Path Guided Contrastive Learning for Logical Reasoning

Yangyang Guo, Liqiang Nie, Fangkai Jiao, Xuemeng Song

arXiv · PDF · Open in the Atlas

Code that ran

5 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; 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.00357.json · badge: /api/ran/2203.00357.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
sparkjiao/merit marked official in Papers with Code
Papers with Code archive
5 ran · 2 no recorded run
FunctionStatusWhere it lives
AverageMeter Ran
ran on a synthesized input · constructed an object; no result was computed
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("bae3f62db60db88a")
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, AverageMeter: 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

torch.manual_seed(0)

# AverageMeter is a simple utility class that doesn't take any constructor arguments
# It has methods: reset(), update(val, n=1), save(), and load(value: dict)
# The __init__ method takes no parameters

ARGS = {}
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 AverageMeter — 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 AverageMeter 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
LogMixin Ran
ran on a synthesized input · constructed an object; no result was computed
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("6a70f455b6a0d63e")
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, LogMixin: 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 logging

torch.manual_seed(0)

# AverageMeter and LogMetric classes are already defined in the function
class AverageMeter(object):
    """Computes and stores the average and current value."""

    def __init__(self):
        self.val = 0
        self.avg = 0
        self.sum = 0
        self.count = 0

    def reset(self):
        self.val = 0
        self.avg = 0
        self.sum = 0
        self.count = 0

    def update(self, val, n=1):
        if isinstance(val, torch.Tensor):
            val = val.item()
        if isinstance(n, torch.Tensor):
            n = n.item()
        self.val = val
        self.sum += val * n
        self.count += n
        if self.count > 0:
            self.avg = self.sum / self.count
        else:
            self.avg = 0

    def save(self):
        return {'val': self.val, 'avg': self.avg, 'sum': self.sum, 'count': self.count}

    def load(self, value: dict):
        if value is None:
            self.reset()
        self.val = value['val'] if 'val' in value else 0
        self.avg = value['avg'] if 'avg' in value else 0
        self.sum = value['sum'] if 'sum' in value else 0
        self.count = value['count'] if 'count' in value else 0

class LogMetric(object):
    """
    Record all metrics for logging.
    """

    def __init__(self, *metric_names):
        self.metrics = {key: AverageMeter() for key in metric_names}

    def update(self, metric_name, val, n=1):
        self.metrics[metric_name].update(val, n)

    def reset(self, metric_name=None):
        if metric_name is None:
            for key in self.metrics.keys():
                self.metrics[key].reset()
            return
        self.metrics[metric_name].reset()

    def get_log(self):
        log = {key: self.metrics[key].avg for key in self.metrics}
        return log

_root_name = 'FK'

def get_child_logger(child_name):
    return logging.getLogger(_root_name + '.' + child_name)

logger = get_child_logger('RoBERTa.Sent')

class LogMixin:
    eval_metrics: LogMetric = None

    def init_metric(self, *metric_names):
        self.eval_metrics = LogMetric(*metric_names)

    def get_eval_log(self, reset=False):
        if self.eval_metrics is None:
            logger.warning("The `eval_metrics` attribute hasn't been initialized.")
        results = self.eval_metrics.get_log()
        _eval_metric_log = '\t'.join([f'{k}: {v}' for k, v in results.items()])
        if reset:
            self.eval_metrics.reset()
        return (_eval_metric_log, results)


# Create an instance of LogMixin
log_mixin_instance = LogMixin()

# Initialize metrics with some example metric names
log_mixin_instance.init_metric('loss', 'accuracy', 'f1_score')

# Update metrics with some sample values
log_mixin_instance.eval_metrics.update('loss', 0.25, n=1)
log_mixin_instance.eval_metrics.update('accuracy', 0.95, n=1)
log_mixin_instance.eval_metrics.update('f1_score', 0.88, n=1)

# LogMixin has no parameters in __init__, so ARGS should be empty or contain instance state
ARGS = {}
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 LogMixin — 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 LogMixin 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
extract_sent_tokens Ran
ran; our contract draft was wrong, not the code
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("b90c2f73ba830814")
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 4, dtype family int; 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
from torch import nn, Tensor

torch.manual_seed(0)

# Set up small tensors with distinct dimensions for clarity
batch = 2
seq_len = 5
max_sent_num = 3
max_sent_len = 4
path_len = 2

# source: [batch, seq_len] - token IDs from the source sequence
source = torch.randint(0, 10, (batch, seq_len), dtype=torch.long)

# sentence_index: [batch, max_sent_num, max_sent_len]
# Contains indices into the source tensor
sentence_index = torch.randint(0, seq_len, (batch, max_sent_num, max_sent_len), dtype=torch.long)

# sent_token_mask: [batch, max_sent_num, max_sent_len]
# Boolean mask indicating valid tokens in each sentence
sent_token_mask = torch.rand(batch, max_sent_num, max_sent_len) > 0.3

# sentence_ids: [batch, path_len]
# Indices into the sentence dimension (max_sent_num)
sentence_ids = torch.randint(0, max_sent_num, (batch, path_len), dtype=torch.long)

# sentence_ids_mask: [batch, path_len]
# Boolean mask for valid sentence IDs
sentence_ids_mask = torch.rand(batch, path_len) > 0.2

ARGS = {
    "source": source,
    "sentence_index": sentence_index,
    "sent_token_mask": sent_token_mask,
    "sentence_ids": sentence_ids,
    "sentence_ids_mask": sentence_ids_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, ndim 4, dtype family int — 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
get_accuracy Ran
ran; our contract draft was wrong, not the code
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("15b69fa520a0583e")
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
from torch import nn, Tensor

torch.manual_seed(0)

# Create small tensors
# logits: shape (batch_size, ..., num_classes)
# labels: shape (batch_size, ...)
# The function calls logits.max(dim=-1) and compares pred == labels
# So we need logits with a class dimension at the end

batch_size = 2
num_classes = 4
logits = torch.randn(batch_size, num_classes)
labels = torch.randint(0, num_classes, (batch_size,))

ARGS = {
    "logits": logits,
    "labels": labels,
}
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
get_child_logger Ran
ran; our contract draft was wrong, not the code
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("477a33ae801770b3")
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 Logger. 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 logging

_root_name = 'FK'

def get_child_logger(child_name):
    return logging.getLogger(_root_name + '.' + child_name)

ARGS = {
    'child_name': 'test_module'
}
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 Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger 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
LogMetric Not yet run
unverified (harvested, no recorded run)
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("490e26c4efc3d75f")
How it ran

no invocation recorded.

RobertaSentForMultipleChoice Not yet run
unverified (harvested, no recorded run)
sparkjiao/merit/models/roberta_sent_att_sup.py
code served (permissive licence) · get_code("f81e954124a605c1")
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, 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 7 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-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

Logical reasoning is of vital importance to natural language understanding. Previous studies either employ graph-based models to incorporate prior knowledge about logical relations, or introduce symbolic logic into neural models through data augmentation. These methods, however, heavily depend on annotated training data, and thus suffer from overfitting and poor generalization problems due to the dataset sparsity. To address these two problems, in this paper, we propose MERIt, a MEta-path guided contrastive learning method for logical ReasonIng of text, to perform selfsupervised pre-training on abundant unlabeled text data. Two novel strategies serve as indispensable components of our method. In particular, a strategy based on meta-path is devised to discover the logical structure in natural texts, followed by a counterfactual data augmentation strategy to eliminate the information shortcut induced by pre-training. The experimental results on two challenging logical reasoning benchmarks, i.e., ReClor and LogiQA, demonstrate that our method outperforms the SOTA baselines with significant improvements. 1

For agents

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

get_harvested_code_for_paper("2203.00357")
get_code_for_paper("2203.00357")
have("2203.00357")

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

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

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

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

Connect an agent — have() is free.