SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2007.12223 · NeurIPS · 2020

The Lottery Ticket Hypothesis for Pre-trained BERT Networks

Tianlong Chen, Zhangyang Wang, Jonathan Frankle, Sijia Liu, Shiyu Chang, Yang Zhang, Michael Carbin

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 (0 of them constructed an object rather than computing a result; 4 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 5 failures of our instrument; 2 no recorded run); 2 of them were also run on the host, not in the jail, by the peer-agreement lane that set their level, 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/2007.12223.json · badge: /api/ran/2007.12223.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
TAMU-VITA/BERT-Tickets canonical (classifier label)
classifier basis: plan_row
7 ran · 2 no recorded run
VITA-Group/BERT-Tickets canonical (classifier label)
classifier basis: classifier_2025
2 ran · 0 no recorded run
FunctionStatusWhere it lives
to_list Ran
ran; our contract draft was wrong, not the code
TAMU-VITA/BERT-Tickets/LT_squad.py
pointer only (licence: MIT); the stored copy get_code serves, from AI-secure/InfoBERT, is pointer only (licence: NONE) · get_code("9df40357afea56cc")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from AI-secure/InfoBERT, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

whitespace_tokenize Ran
ran; our contract draft was wrong, not the code
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/tokenization_bert.py
code served (permissive licence) · get_code("cf9ffa02a42184af")
How it ran

Ran in Syntology's jail on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1) and returned list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The comparison behind this sample's level is a different run: the peer-agreement lane ran it again on the host, not in the jail (report dated 2026-09-05T02:55:57Z). 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
import numpy as np

def whitespace_tokenize(text):
    """Runs basic whitespace cleaning and splitting on a piece of text."""
    text = text.strip()
    if not text:
        return []
    tokens = text.split()
    return tokens

# Setup code
torch.manual_seed(0)

# The function takes a single parameter: text (a string)
# It performs basic whitespace cleaning and splitting
# We need to provide a valid string argument

ARGS = {
    "text": "  hello world  this is a test  "
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list 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
gelu Ran
ran, honoured the contract we drafted
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/modeling_tf_bert.py
code served (permissive licence) · get_code("9bc31d06256e1691")
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 EagerTensor, 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 tensorflow as tf
import numpy as np

# Create a small TensorFlow tensor as input
# The function expects a tensor and applies element-wise operations
x = tf.constant([[-2.0, -1.0, 0.0, 1.0], [2.0, 3.0, -0.5, 0.5]], dtype=tf.float32)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
gelu_new Ran
ran, honoured the contract we drafted
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/modeling_tf_bert.py
code served (permissive licence) · get_code("83257a2b015273fa")
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 EagerTensor, 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 tensorflow as tf

# Create a small TensorFlow tensor for testing
x = tf.constant([[1.0, 2.0, 0.5, -1.0],
                 [0.1, -0.5, 1.5, 0.0]], dtype=tf.float32)

ARGS = {
    "x": x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
load_vocab Ran
ran; our contract draft was wrong, not the code
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/tokenization_bert.py
code served (permissive licence) · get_code("e7fbc7a74a3457c7")
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 OrderedDict. 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 collections
import tempfile
import os

# Create a temporary vocabulary file
temp_dir = tempfile.mkdtemp()
vocab_file = os.path.join(temp_dir, 'vocab.txt')

# Write some sample tokens to the vocab file
sample_tokens = ['[PAD]', '[UNK]', '[CLS]', '[SEP]', 'the', 'quick', 'brown', 'fox']
with open(vocab_file, 'w', encoding='utf-8') as f:
    for token in sample_tokens:
        f.write(token + '\n')

ARGS = {
    'vocab_file': vocab_file
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
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 OrderedDict — a OrderedDict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a OrderedDict 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
mish Ran
ran; our contract draft was wrong, not the code
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/modeling_bert.py
pointer only (licence: MIT); the stored copy get_code serves, from llyx97/sparse-and-robust-PLM, is pointer only (licence: NONE) · get_code("060527bb34794b59")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from llyx97/sparse-and-robust-PLM, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

rewind Ran
ran; our contract draft was wrong, not the code
VITA-Group/BERT-Tickets/LT_pretrain.py
code served (permissive licence) · get_code("654ccfd8e73d5328")
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 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 torch
import torch.nn as nn

torch.manual_seed(0)

# Create a pre_weight dictionary that simulates a BERT model state dict
pre_weight = {}

# Add BERT encoder layer weights (12 layers, each with query, key, value, attention output, intermediate, and output dense layers)
for ii in range(12):
    # Query, key, value weights
    pre_weight[f'bert.encoder.layer.{ii}.attention.self.query.weight'] = torch.randn(4, 3)
    pre_weight[f'bert.encoder.layer.{ii}.attention.self.key.weight'] = torch.randn(4, 3)
    pre_weight[f'bert.encoder.layer.{ii}.attention.self.value.weight'] = torch.randn(4, 3)
    
    # Attention output dense weight
    pre_weight[f'bert.encoder.layer.{ii}.attention.output.dense.weight'] = torch.randn(4, 3)
    
    # Intermediate dense weight
    pre_weight[f'bert.encoder.layer.{ii}.intermediate.dense.weight'] = torch.randn(4, 3)
    
    # Output dense weight
    pre_weight[f'bert.encoder.layer.{ii}.output.dense.weight'] = torch.randn(4, 3)

# Add pooler dense weight
pre_weight['bert.pooler.dense.weight'] = torch.randn(4, 3)

# Add some non-BERT keys to test the filtering logic
pre_weight['classifier.weight'] = torch.randn(2, 4)
pre_weight['classifier.bias'] = torch.randn(2)

# Add a BERT key that is NOT in the name_list to test the else branch
pre_weight['bert.embeddings.word_embeddings.weight'] = torch.randn(5, 3)

ARGS = {
    'pre_weight': pre_weight
}
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 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
see_weight_rate Ran
ran, honoured the contract we drafted
VITA-Group/BERT-Tickets/LT_pretrain.py
code served (permissive licence) · get_code("a6e4665d84898ce9")
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 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 torch.nn as nn

torch.manual_seed(0)

class SelfAttention(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.query = nn.Linear(hidden_size, hidden_size)
        self.key = nn.Linear(hidden_size, hidden_size)
        self.value = nn.Linear(hidden_size, hidden_size)

class AttentionOutput(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.dense = nn.Linear(hidden_size, hidden_size)

class Attention(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.self = SelfAttention(hidden_size)
        self.output = AttentionOutput(hidden_size)

class Intermediate(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.dense = nn.Linear(hidden_size, hidden_size)

class Output(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.dense = nn.Linear(hidden_size, hidden_size)

class EncoderLayer(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.attention = Attention(hidden_size)
        self.intermediate = Intermediate(hidden_size)
        self.output = Output(hidden_size)

class Encoder(nn.Module):
    def __init__(self, num_layers=12, hidden_size=4):
        super().__init__()
        self.layer = nn.ModuleList([EncoderLayer(hidden_size) for _ in range(num_layers)])

class Pooler(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.dense = nn.Linear(hidden_size, hidden_size)

class BERT(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.encoder = Encoder(num_layers=12, hidden_size=hidden_size)
        self.pooler = Pooler(hidden_size)

class BERTModel(nn.Module):
    def __init__(self, hidden_size=4):
        super().__init__()
        self.bert = BERT(hidden_size)

model = BERTModel(hidden_size=4)

ARGS = {
    "model": model
}
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 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
swish Ran
ran, honoured the contract we drafted
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/modeling_tf_bert.py
code served (permissive licence) · get_code("86d13b9f67274f19")
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 EagerTensor, 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 tensorflow as tf
import numpy as np

# Create a small TensorFlow tensor for testing
x = tf.constant([[1.0, 2.0, 3.0, 4.0],
                 [0.5, 1.5, 2.5, 3.5]], dtype=tf.float32)

ARGS = {
    'x': x
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, 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
convert_pytorch_checkpoint_to_tf Not yet run
unverified (harvested, no recorded run)
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/convert_bert_pytorch_checkpoint_to_original_tf.py
code served (permissive licence) · get_code("d772ba25f4de22b0")
How it ran

no invocation recorded.

load_tf_weights_in_bert Not yet run
unverified (harvested, no recorded run)
TAMU-VITA/BERT-Tickets/transformers-master/src/transformers/modeling_bert.py
pointer only (licence: MIT); the stored copy get_code serves, from llyx97/sparse-and-robust-PLM, is pointer only (licence: NONE) · get_code("0766f48ad6e01b56")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from llyx97/sparse-and-robust-PLM, and GitHub detected no licence in that repository when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. 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, 9 are also present in other papers whose code we hold (9 with at least one paper dated earlier, 1 the same month, 8 later) and 2 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
whitespace_tokenize 43 other papers
8 dated earlier, 35 later
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1906.01698 (2019-06)
Open Sesame: Getting Inside BERT's Linguistic Knowledge
and 40 more not named here
to_list 41 other papers
10 dated earlier, 1 the same month, 30 later
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
1910.06188 (2019-10)
Q8BERT: Quantized 8Bit BERT
1911.02984 (2019-11)
The TechQA Dataset
and 38 more not named here
load_vocab 29 other papers
4 dated earlier, 25 later
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2004.09297 (2020-04)
MPNet: Masked and Permuted Pre-training for Language Understanding
and 26 more not named here
mish 19 other papers
1 dated earlier, 18 later
2006.04884 (2020-06)
On the Stability of Fine-tuning BERT: Misconceptions, Explanations, and Strong Baselines
2012.07463 (2020-12)
Parameter-Efficient Transfer Learning with Diff Pruning
2021.acl-long.390 (2021 (year only))
Few-Shot Text Ranking with Meta Adapted Synthetic Weak Supervision
and 16 more not named here
load_tf_weights_in_bert 16 other papers
1 dated earlier, 15 later
2006.04884 (2020-06)
On the Stability of Fine-tuning BERT: Misconceptions, Explanations, and Strong Baselines
2012.07463 (2020-12)
Parameter-Efficient Transfer Learning with Diff Pruning
2021.acl-long.390 (2021 (year only))
Few-Shot Text Ranking with Meta Adapted Synthetic Weak Supervision
and 13 more not named here
swish 8 other papers
5 dated earlier, 3 later · 2 only as an assembly brick
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1902.08408 (2019-02)
PhysNet: A Neural Network for Predicting Energies, Forces, Dipole Moments and Partial Charges
1910.01108 (2019-10)
DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
and 5 more not named here
gelu 6 other papers
4 dated earlier, 2 later · 1 only as an assembly brick
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1910.01108 (2019-10)
DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
2006.04558 (2020-06)
FastSpeech 2: Fast and High-Quality End-to-End Text to Speech
and 3 more not named here
gelu_new 6 other papers
4 dated earlier, 2 later · 1 only as an assembly brick
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1910.01108 (2019-10)
DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter
2006.04558 (2020-06)
FastSpeech 2: Fast and High-Quality End-to-End Text to Speech
and 3 more not named here
convert_pytorch_checkpoint_to_tf 1 other paper
1 dated earlier
2006.04884 (2020-06)
On the Stability of Fine-tuning BERT: Misconceptions, Explanations, and Strong Baselines

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

In natural language processing (NLP), enormous pre-trained models like BERT have become the standard starting point for training on a range of downstream tasks, and similar trends are emerging in other areas of deep learning. In parallel, work on the lottery ticket hypothesis has shown that models for NLP and computer vision contain smaller matching subnetworks capable of training in isolation to full accuracy and transferring to other tasks. In this work, we combine these observations to assess whether such trainable, transferrable subnetworks exist in pre-trained BERT models. For a range of downstream tasks, we indeed find matching subnetworks at 40% to 90% sparsity. We find these subnetworks at (pre-trained) initialization, a deviation from prior NLP research where they emerge only after some amount of training. Subnetworks found on the masked language modeling task (the same task used to pre-train the model) transfer universally; those found on other tasks transfer in a limited fashion if at all. As large-scale pre-training becomes an increasingly central paradigm in deep learning, our results demonstrate that the main lottery ticket observations remain relevant in this context. Codes available at https://github.com/VITA-Group/BERT-Tickets.

For agents

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

get_harvested_code_for_paper("2007.12223")
get_code_for_paper("2007.12223")
have("2007.12223")

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

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

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

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

Connect an agent — have() is free.