SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2207.12980 · ECCV · 2022

Efficient One Pass Self-distillation with Zipf 's Label Smoothing

Yao Tang, Haoqiang Fan, Jiajun Liang, Borui Zhao, Bo Lin, Linze Li, Zhaodong Bing

arXiv · PDF · Open in the Atlas

Code that ran

5 of 6 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 3 failures of our instrument; 1 no recorded run), measured 2026-11-22; 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.12980.json · badge: /api/ran/2207.12980.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
megvii-research/zipfls marked official in Papers with Code
Papers with Code archive
5 ran · 1 no recorded run
FunctionStatusWhere it lives
gen_pdf Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("a1377a500e1d96b1")
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, 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
import numpy as np
from scipy.stats import rankdata

torch.manual_seed(0)

class Args:
    def __init__(self):
        self.smallest_prob = 0.1
        self.exp_lambda = 0.5

args = Args()

n_batch = 2
n_classes = 4

logits = torch.randn(n_batch, n_classes)
feats = torch.randn(n_batch, 3)
labels = torch.tensor([0, 2])

ARGS = {
    'args': args,
    'logits': logits,
    'feats': feats,
    'labels': labels,
    'loss_mask': False,
    'distribution': 'rank_zipf',
    'dense': False,
    'rank': 'hard',
    'friend': False,
    'power': 1.0,
    'left_bound': 0.01,
    'right_bound': 1.0,
    'with_target': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
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 2, dtype family float, shape (2, 3) — shape (2, 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
gen_pdf_linear_decay Ran
ran, honoured the contract we drafted
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("37891eae608fb0e6")
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 float, 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 numpy as np

torch.manual_seed(0)

# Analyzing the function:
# - rank: appears to be an integer (used in arithmetic)
# - n_classes: appears to be an integer (used in arithmetic)
# - smallest_prob: appears to be a float (used in arithmetic)
# - rank_max: optional integer parameter (used in arithmetic, defaults to rank)

ARGS = {
    "rank": 2,
    "n_classes": 5,
    "smallest_prob": 0.1,
    "rank_max": None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type float, 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
gen_pdf_unbiased Ran
ran, honoured the contract we drafted
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("2b4cafb118bb8090")
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 float64, 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 numpy as np

ARGS = {
    "rank": 5,
    "n_classes": 10,
    "dense": False,
    "left_bound": 0.01,
    "right_bound": 1.0,
    "power": 1.0,
    "rank_max": 20
}
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 float64, 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
get_masked_distribution Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("8acc4e763cd2a6c1")
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 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
import torch

class Args:
    def __init__(self):
        self.smallest_prob = 0.01
        self.exp_lambda = 0.5

torch.manual_seed(0)
np.random.seed(0)

# Create small tensors with distinct sizes
n = 2  # batch size
c = 4  # number of classes

# rank: shape (n, c) with values from 1 to c
rank = np.tile(np.arange(1, c + 1), (n, 1)).astype(np.float32)

# mask: shape (n, c) boolean mask
mask = np.ones((n, c), dtype=bool)
mask[0, 0] = False  # Make it not all True

# rank_max: maximum rank value
rank_max = c

# Create args object with required attributes
args = Args()

ARGS = {
    'args': args,
    'rank': rank,
    'dis_type': 'rank_zipf',
    'power': 1.0,
    'dense': False,
    'left_bound': 0.01,
    'mask': mask,
    'rank_max': rank_max,
    'right_bound': 1.0,
    'with_target': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — 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
kl_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("12febd0c96d3874c")
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 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.functional as F

torch.manual_seed(0)

# Batch size: 2, number of classes: 4
batch_size = 2
num_classes = 4

# output: logits of shape (batch_size, num_classes)
output = torch.randn(batch_size, num_classes)

# label: class indices of shape (batch_size,)
label = torch.tensor([0, 2])

# pdf: probability distribution of shape (batch_size, num_classes - 1)
# This matches the shape expected by F.kl_div after processing
pdf = torch.softmax(torch.randn(batch_size, num_classes - 1), dim=1)

# do_mask: boolean flag
do_mask = False

ARGS = {
    'output': output,
    'label': label,
    'pdf': pdf,
    'do_mask': do_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 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: none by the harness; any seed is in the setup block
zipf_loss Not yet run
unverified (harvested, no recorded run)
megvii-research/zipfls/pytorch_zipfls/losses.py
code served (permissive licence) · get_code("665b785d5b8b0b8f")
How it ran

no invocation recorded.

Also present in other papers' code

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

Self-distillation exploits non-uniform soft supervision from itself during training and improves performance without any runtime cost. However, the overhead during training is often overlooked, and yet reducing time and memory overhead during training is increasingly important in the giant models' era. This paper proposes an efficient selfdistillation method named Zipf's Label Smoothing (Zipf's LS), which uses the on-the-fly prediction of a network to generate soft supervision that conforms to Zipf distribution without using any contrastive samples or auxiliary parameters. Our idea comes from an empirical observation that when the network is duly trained the output values of a network's final softmax layer, after sorting by the magnitude and averaged across samples, should follow a distribution reminiscent to Zipf's Law in the word frequency statistics of natural languages. By enforcing this property on the sample level and throughout the whole training period, we find that the prediction accuracy can be greatly improved. Using ResNet50 on the INAT21 fine-grained classification dataset, our technique achieves +3.61% accuracy gain compared to the vanilla baseline, and 0.88% more gain against the previous label smoothing or selfdistillation strategies. The implementation is publicly available at https: //github.com/megvii-research/zipfls.

For agents

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

get_harvested_code_for_paper("2207.12980")
get_code_for_paper("2207.12980")
have("2207.12980")

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

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

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

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

Connect an agent — have() is free.