SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.13545 · ICLR · 2023

Learning Hyper Label Model for Programmatic Weak Supervision

Jieyu Zhang, Renzhi Wu, Shen-En Chen, Xu Chu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 14 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 3 have no contract verdict; 2 failures of our instrument; 8 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/2207.13545.json · badge: /api/ran/2207.13545.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
wurenzhi/hyper_label_model canonical (classifier label)
classifier basis: classifier_2025
6 ran · 8 no recorded run
FunctionStatusWhere it lives
BCEMask Ran
ran on a synthesized input
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("2b52155705102677")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, 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

class BCEMask(nn.Module):
    """binary cross entropy loss with mask
    """

    def __init__(self):
        super().__init__()
        self.loss = nn.BCELoss(reduction='none')

    def forward(self, input, y_true, mask):
        l = self.loss(input, y_true[:, :input.shape[1]])
        l = torch.mean(l[mask])
        return l


INIT_ARGS = {}

ARGS = {
    'input': torch.sigmoid(torch.randn(2, 4)),
    'y_true': torch.randint(0, 2, (2, 6)).float(),
    'mask': torch.tensor([[True, False, True, False],
                          [False, True, True, False]])
}

if __name__ == '__main__':
    model = BCEMask(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output: {output}")
    print(f"Output shape: {output.shape}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
BCEMaskWeighted Ran
ran on a synthesized input
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("aaf8423ced44b1ed")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, 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

class BCEMaskWeighted(nn.Module):
    """weighted binary cross entropy loss (with mask), 
    this is used when fine-tuning LELA on unbalanced datasets 
    """

    def __init__(self, weights=None):
        super().__init__()
        self.weights = weights

    def forward_no_mask(self, output, target):
        if self.weights is not None:
            assert len(self.weights) == 2
            loss = self.weights[1] * (target * torch.log(output)) + self.weights[0] * ((1 - target) * torch.log(1 - output))
        else:
            loss = target * torch.log(output) + (1 - target) * torch.log(1 - output)
        return torch.neg(loss)

    def forward(self, input, y_true, mask):
        l = self.forward_no_mask(input, y_true[:, :input.shape[1]])
        l = torch.mean(l[mask])
        return l


INIT_ARGS = {
    'weights': [0.3, 0.7]
}

ARGS = {
    'input': torch.sigmoid(torch.randn(2, 4)),
    'y_true': torch.randint(0, 2, (2, 6)).float(),
    'mask': torch.tensor([[True, True, False, True], [True, False, True, True]])
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
GNNLayer Ran
ran on a synthesized input
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("7766c5d05db3f70d")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) 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 as nn

def sparse_mean(index, value, expand=True):
    """obtain the mean of values that share the same index (e.g. same row or column in label matrix X) 

    Args:
        index: The indices of the elements, the first dimension is batch size 
        value : The values of the elements, the first dimension is batch size
        expand (bool, optional): if true expand the output to have the same size as index

    Returns:
        mean values
    """
    output_batch = []
    ind_max = int(index.max() + 1)
    for i_batch in range(value.shape[0]):
        output = torch.zeros((ind_max, value.shape[2])).float().to(value.device).index_add_(0, index[i_batch], value[i_batch])
        norm = torch.zeros(ind_max).to(value.device).float().index_add_(0, index[i_batch], torch.ones_like(index[i_batch]).float()) + 1e-09
        output = output / norm[:, None].float()
        if expand:
            output = torch.index_select(output, 0, index[i_batch])
        output_batch.append(output)
    return torch.stack(output_batch)

class GNNLayer(nn.Module):
    """One GNN layer
    Args:
        in_features: embedding dimension of the input
        out_features: embedding dimension of the output
    """

    def __init__(self, in_features, out_features):
        super(GNNLayer, self).__init__()
        self.activation = nn.LeakyReLU()
        self.linear = nn.Linear(in_features * 4, out_features)
        self.linear_row = nn.Linear(in_features, in_features)
        self.linear_col = nn.Linear(in_features, in_features)
        self.linear_global = nn.Linear(in_features, in_features)
        self.linear_self = nn.Linear(in_features, in_features)

    def forward(self, index, value):
        pooled = [self.linear_row(sparse_mean(index[:, :, 0], value)), self.linear_col(sparse_mean(index[:, :, 1], value)), self.linear_global(torch.mean(value, dim=1)).unsqueeze(1).expand_as(value)]
        stacked = torch.cat([self.linear_self(value)] + pooled, dim=2)
        return (index, self.activation(self.linear(stacked)))

INIT_ARGS = {
    'in_features': 6,
    'out_features': 8
}

batch_size = 2
num_elements = 5
in_features = 6

index = torch.randint(0, 3, (batch_size, num_elements, 2))
value = torch.randn(batch_size, num_elements, in_features)

ARGS = {
    'index': index,
    'value': value
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
calibrate_probs Ran
ran, honoured the contract we drafted
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("b29df98e19dac58d")
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 ndarray, 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 numpy as np

# Create a small probability matrix with shape (batch_size=2, n_class=4)
# Each row should sum to 1 (valid probability distribution)
probs = np.array([
    [0.1, 0.2, 0.3, 0.4],
    [0.25, 0.25, 0.25, 0.25]
], dtype=np.float32)

ARGS = {
    "probs": probs
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, 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
sparse_mean Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("b271955b279280b5")
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 Tensor, ndim 3, dtype family float, shape (2, 5, 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
import torch.nn as nn
import numpy as np

torch.manual_seed(0)

# Create small test tensors
batch_size = 2
num_elements = 5
feature_dim = 4

# index: shape (batch_size, num_elements) - indices into the aggregation dimension
# Values should be in range [0, ind_max)
index = torch.tensor([
    [0, 1, 0, 2, 1],
    [1, 0, 2, 1, 0]
], dtype=torch.long)

# value: shape (batch_size, num_elements, feature_dim) - the values to aggregate
value = torch.randn(batch_size, num_elements, feature_dim, dtype=torch.float32)

# expand parameter
expand = True

ARGS = {
    "index": index,
    "value": value,
    "expand": expand
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, scipy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 3, dtype family float, shape (2, 5, 4) — shape (2, 5, 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
sparse_mean Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("1faacaf7f2fbb5e7")
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 Tensor, ndim 3, dtype family float, shape (2, 4, 3) 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)

# Construct valid arguments for sparse_mean
# index: shape (batch_size, num_elements) - indices for aggregation
# value: shape (batch_size, num_elements, feature_dim) - values to aggregate
# expand: bool - whether to expand output back to input size

batch_size = 2
num_elements = 4
feature_dim = 3
max_index = 3

# Create index tensor with values in range [0, max_index)
index = torch.tensor([
    [0, 1, 2, 0],
    [1, 2, 0, 1]
], dtype=torch.long)

# Create value tensor with shape (batch_size, num_elements, feature_dim)
value = torch.randn(batch_size, num_elements, feature_dim)

# expand parameter
expand = True

ARGS = {
    "index": index,
    "value": value,
    "expand": expand
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 3, dtype family float, shape (2, 4, 3) — shape (2, 4, 3) 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
HyperLMSemi Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("07b827b2fdfe4d9a")
How it ran

no invocation recorded.

HyperLMSemi Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("bd4073aa5af6607c")
How it ran

no invocation recorded.

HyperLabelModel Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("27d6c888ad81598c")
How it ran

no invocation recorded.

LELAGNN Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("d36681e097a6f580")
How it ran

no invocation recorded.

SemisupervisedHelper Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("a2ecd152d2ec1eed")
How it ran

no invocation recorded.

SequentialMultiArg Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("784e58a2b95d6b9e")
How it ran

no invocation recorded.

UnsupervisedWraper Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("a148c0ed3b3869d3")
How it ran

no invocation recorded.

calibrate_probs Not yet run
unverified (harvested, no recorded run)
wurenzhi/hyper_label_model/src/hyperlm/hyper_label_model.py
code served (permissive licence) · get_code("1a1da68368748bda")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

Also present in other papers' code

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

To reduce the human annotation efforts, the programmatic weak supervision (PWS) paradigm abstracts weak supervision sources as labeling functions (LFs) and involves a label model to aggregate the output of multiple LFs to produce training labels. Most existing label models require a parameter learning step for each dataset. In this work, we present a hyper label model that (once learned) infers the ground-truth labels for each dataset in a single forward pass without dataset-specific parameter learning. The hyper label model approximates an optimal analytical (yet computationally intractable) solution of the ground-truth labels. We train the model on synthetic data generated in the way that ensures the model approximates the analytical optimal solution, and build the model upon Graph Neural Network (GNN) to ensure the model prediction being invariant (or equivariant) to the permutation of LFs (or data points). On 14 real-world datasets, our hyper label model outperforms the best existing methods in both accuracy (by 1.4 points on average) and efficiency (by six times on average). Our code is available at https://github.com/wurenzhi/hyper label model

For agents

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

get_harvested_code_for_paper("2207.13545")
get_code_for_paper("2207.13545")
have("2207.13545")

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

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

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

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

Connect an agent — have() is free.