SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2006.13114 · NeurIPS · 2020

Fairness without Demographics through Adversarially Reweighted Learning

Ed Chi, Preethi Lahoti, Alex Beutel, Jilin Chen, Kang Lee, Flavien Prost, Nithum Thain, Xuezhi Wang

arXiv · PDF · Open in the Atlas

Code that ran

6 of 8 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 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/2006.13114.json · badge: /api/ran/2006.13114.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
patrikken/fair-dsr community
Papers with Code archive
4 ran · 1 no recorded run
lucweytingh/ARL-UvA community
Papers with Code archive
2 ran · 1 no recorded run
FunctionStatusWhere it lives
AdversaryNN Ran
ran on a synthesized input · constructed an object; no result was computed
patrikken/fair-dsr/src/ARL/arl.py
code served (permissive licence) · get_code("0edf6c65e388ca95")
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, AdversaryNN: 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
from torch import nn

torch.manual_seed(0)

ARGS = {
    "input_size": 97,
    "output_size": 1,
}
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 AdversaryNN — 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 AdversaryNN 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
AdversaryNN Ran
ran on a synthesized input
lucweytingh/ARL-UvA/arl.py
code served (permissive licence) · get_code("7a3cb9ffdbc5d1f6")
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 2, dtype family float, shape (2, 1) 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 AdversaryNN(nn.Module):

    def __init__(self, embedding_size, n_num_cols, n_hidden, device='cpu'):
        """
        Implements the adversary DNN.
        Args:
          embedding_size: list of tuples (n_classes, n_features) containing
                          embedding sizes for categorical columns.
          n_num_cols: number of numerical inputs.
          n_hidden: list of ints, specifies the number of units
                    in each linear layer.
        """
        super().__init__()
        self.device = device
        self.embeddings = nn.ModuleList([nn.Embedding(n_classes, n_features) for n_classes, n_features in embedding_size])
        all_layers = []
        n_cat_cols = sum((n_features for _, n_features in embedding_size))
        input_size = n_cat_cols + n_num_cols
        for dim in n_hidden:
            all_layers.append(nn.Linear(input_size, dim))
            input_size = dim
        all_layers.append(nn.Linear(n_hidden[-1], 1))
        self.layers = nn.Sequential(*all_layers)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x_cat, x_num):
        """
        The forward step for the adversary.
        """
        embedding_cols = []
        for i, emb in enumerate(self.embeddings):
            embedding_cols.append(emb(x_cat[:, i]))
        x = torch.cat(embedding_cols, dim=1)
        x = torch.cat([x, x_num], dim=1)
        x = self.layers(x)
        x = self.sigmoid(x)
        x_mean = torch.mean(x)
        x = x / torch.max(torch.Tensor([x_mean, 0.0001]))
        x = x + torch.ones_like(x)
        return x


INIT_ARGS = {
    'embedding_size': [(5, 3), (7, 4)],
    'n_num_cols': 6,
    'n_hidden': [16, 8],
    'device': 'cpu'
}

ARGS = {
    'x_cat': torch.randint(0, 5, (2, 2)),
    'x_num': torch.randn(2, 6)
}

if __name__ == '__main__':
    model = AdversaryNN(**INIT_ARGS)
    output = model(**ARGS)
    print(f"Output shape: {output.shape}")
    print(f"Output: {output}")
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 2, dtype family float, shape (2, 1) — shape (2, 1) 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)
DemParityMetric Ran
ran on a synthesized input · constructed an object; no result was computed
patrikken/fair-dsr/src/ARL/arl.py
code served (permissive licence) · get_code("5d4863c2ec25fc37")
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, DemParityMetric: 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
from torchmetrics import Metric

torch.manual_seed(0)

# Setup for DemParityMetric
# The metric expects preds and sensitive_features in the update method
# preds: predictions (floats to be thresholded)
# sensitive_features: binary sensitive attributes (0 or 1)

# Create small tensors for testing
batch_size = 4
preds = torch.rand(batch_size)  # Random predictions between 0 and 1
sensitive_features = torch.tensor([0, 1, 0, 1], dtype=torch.long)  # Binary sensitive feature

ARGS = {
    'treshold': 0.5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchmetrics — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type DemParityMetric — 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 DemParityMetric 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
EqualOpportunity Ran
ran on a synthesized input · constructed an object; no result was computed
patrikken/fair-dsr/src/ARL/arl.py
code served (permissive licence) · get_code("cd3c47ac6974b37c")
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, EqualOpportunity: 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
from torchmetrics import Metric

torch.manual_seed(0)

ARGS = {
    'treshold': 0.5
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torchmetrics — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EqualOpportunity — 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 EqualOpportunity 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
EqualizedOdds Ran
ran on a synthesized input
patrikken/fair-dsr/src/ARL/arl.py
code served (permissive licence) · get_code("75c30c9c6fb81781")
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 NoneType. 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 torchmetrics import Metric

class EqualizedOdds(Metric):
    """Calculate the equalized odds difference.

    The sum of two metrics: `true_positive_rate_difference` and
    `false_positive_rate_difference`. The former is the difference between the
    largest and smallest of :math:`P[h(X)=1 | A=a, Y=1]`, across all values :math:`a`
    of the sensitive feature(s). The latter is defined similarly, but for
    :math:`P[h(X)=1 | A=a, Y=0]`.
    The equalized odds difference of 0 means that all groups have the same
    true positive, true negative, false positive, and false negative rates.

    Parameters
    ----------
    preds : array-like
        Predicted labels :math:`h(X)` returned by the classifier.

    y_true : array-like
        Ground truth (correct) labels. 

    sensitive_features :
        The sensitive features over which demographic parity should be assessed 

    Returns
    -------
    float
        The equalized odds difference
    """
    is_differentiable: False
    higher_is_better: False
    full_state_update: bool = True

    def __init__(self, treshold=0.5):
        super().__init__()
        self.add_state('tp_0', default=torch.tensor(0.0), dist_reduce_fx='sum')
        self.add_state('tp_1', default=torch.tensor(0.0), dist_reduce_fx='sum')
        self.add_state('fp_0', default=torch.tensor(0.0), dist_reduce_fx='sum')
        self.add_state('fp_1', default=torch.tensor(0.0), dist_reduce_fx='sum')
        self.treshold = treshold

    def update(self, preds: torch.Tensor, target: torch.Tensor, sensitive_features: torch.Tensor):
        assert preds.shape == sensitive_features.shape
        y_pred, y_true, s = ((preds > self.treshold).long(), target, sensitive_features)
        self.tp_0 = torch.sum(torch.logical_and(y_pred == 1, torch.logical_and(y_true == 1, s == 0))) / torch.sum(torch.logical_and(y_true == 1, s == 0)).float()
        self.tp_1 = torch.sum(torch.logical_and(y_pred == 1, torch.logical_and(y_true == 1, s == 1))) / torch.sum(torch.logical_and(y_true == 1, s == 1)).float()
        self.fp_0 = torch.sum(torch.logical_and(y_pred == 1, torch.logical_and(y_true == 0, s == 0))) / torch.sum(torch.logical_and(y_true == 0, s == 0)).float()
        self.fp_1 = torch.sum(torch.logical_and(y_pred == 1, torch.logical_and(y_true == 0, s == 1))) / torch.sum(torch.logical_and(y_true == 0, s == 1)).float()

    def compute(self):
        return torch.max(torch.abs(self.tp_1 - self.tp_0), torch.abs(self.fp_0 - self.fp_1))


INIT_ARGS = {
    'treshold': 0.5
}

ARGS = {
    'preds': torch.tensor([0.2, 0.7, 0.3, 0.8, 0.1, 0.9]),
    'target': torch.tensor([0, 1, 0, 1, 0, 1]),
    'sensitive_features': torch.tensor([0, 0, 1, 1, 0, 1])
}

METHOD = 'update'

metric = EqualizedOdds(**INIT_ARGS)
metric.update(**ARGS)
result = metric.compute()
print(f"Equalized Odds Difference: {result}")
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, torchmetrics — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type NoneType — a NoneType output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a NoneType 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: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
LearnerNN Ran
ran on a synthesized input
lucweytingh/ARL-UvA/arl.py
code served (permissive licence) · get_code("9f285e060e7712e1")
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

class LearnerNN(nn.Module):

    def __init__(self, embedding_size, n_num_cols, n_hidden, activation_fn=nn.ReLU, device='cpu'):
        """
        Implements the learner DNN.
        Args:
          embedding_size: list of tuples (n_classes, n_features) containing
                           embedding sizes for categorical columns.
          n_num_cols: number of numerical inputs.
          n_hidden: list of ints, specifies the number of units
                    in each linear layer.
          activation_fn: the activation function to use.
        """
        super().__init__()
        self.device = device
        self.embeddings = nn.ModuleList([nn.Embedding(n_classes, n_features) for n_classes, n_features in embedding_size])
        all_layers = []
        n_cat_cols = sum((n_features for _, n_features in embedding_size))
        input_size = n_cat_cols + n_num_cols
        for dim in n_hidden:
            all_layers.append(nn.Linear(input_size, dim))
            all_layers.append(activation_fn())
            input_size = dim
        all_layers.append(nn.Linear(n_hidden[-1], 1))
        self.layers = nn.Sequential(*all_layers)
        self.sigmoid = nn.Sigmoid()

    def forward(self, x_cat, x_num):
        """
        The forward step for the learner.
        """
        embedding_cols = []
        for i, emb in enumerate(self.embeddings):
            embedding_cols.append(emb(x_cat[:, i]))
        x = torch.cat(embedding_cols, dim=1)
        x = torch.cat([x, x_num], dim=1)
        logits = self.layers(x)
        sigmoid_output = self.sigmoid(logits)
        sigmoid_output.to(self.device)
        class_predictions = torch.where(sigmoid_output > 0.5, torch.tensor(1, dtype=torch.float32).to(self.device), torch.tensor(0, dtype=torch.float32).to(self.device))
        return (logits, sigmoid_output, class_predictions)


INIT_ARGS = {
    'embedding_size': [(10, 3), (8, 4)],
    'n_num_cols': 5,
    'n_hidden': [16, 8],
    'activation_fn': nn.ReLU,
    'device': 'cpu'
}

ARGS = {
    'x_cat': torch.randint(0, 10, (2, 2)),
    'x_num': torch.randn(2, 5)
}

model = LearnerNN(**INIT_ARGS)
output = model(**ARGS)
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)
ARL Not yet run
unverified (harvested, no recorded run)
patrikken/fair-dsr/src/ARL/arl.py
code served (permissive licence) · get_code("148bff5c92294183")
How it ran

no invocation recorded.

ARL Not yet run
unverified (harvested, no recorded run)
lucweytingh/ARL-UvA/arl.py
code served (permissive licence) · get_code("9dd8c5a15928b973")
How it ran

no invocation recorded.

Also present in other papers' code

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

Much of the previous machine learning (ML) fairness literature assumes that protected features such as race and sex are present in the dataset, and relies upon them to mitigate fairness concerns. However, in practice factors like privacy and regulation often preclude the collection of protected features, or their use for training or inference, severely limiting the applicability of traditional fairness research. Therefore we ask: How can we train an ML model to improve fairness when we do not even know the protected group memberships? In this work we address this problem by proposing Adversarially Reweighted Learning (ARL). In particular, we hypothesize that non-protected features and task labels are valuable for identifying fairness issues, and can be used to co-train an adversarial reweighting approach for improving fairness. Our results show that ARL improves Rawlsian Max-Min fairness, with notable AUC improvements for worst-case protected groups in multiple datasets, outperforming state-of-the-art alternatives.

For agents

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

get_harvested_code_for_paper("2006.13114")
get_code_for_paper("2006.13114")
have("2006.13114")

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

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

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

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

Connect an agent — have() is free.