SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1905.05583 · 2019

How to Fine-Tune BERT for Text Classification?

arXiv · PDF · Open in the Atlas

Code that ran

12 of 18 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 6 have no contract verdict; 5 failures of our instrument; 6 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/1905.05583.json · badge: /api/ran/1905.05583.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
xuyige/BERT4doc-Classification canonical (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
soarsmu/BiasFinder community (classifier label)
classifier basis not recorded on the link
5 ran · 5 no recorded run
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data extension (classifier label)
classifier basis: classifier_2025
4 ran · 1 no recorded run
ongunuzaymacar/comparatively-finetuning-bert community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
uzaymacar/comparatively-finetuning-bert extension (classifier label)
classifier basis: classifier_2025
1 ran · 0 no recorded run
FunctionStatusWhere it lives
accuracy Ran
ran, honoured the contract we drafted
xuyige/BERT4doc-Classification/codes/fine-tuning/run_classifier.py
code served (permissive licence) · get_code("eb725d5794b15f6b")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned int64, ndim 0, dtype family int, 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

# Create sample outputs from a model (e.g., logits for 2 samples, 5 classes)
out = np.array([
    [0.1, 0.3, 0.8, 0.2, 0.1],  # argmax = 2
    [0.9, 0.1, 0.2, 0.3, 0.05]  # argmax = 0
])

# Create corresponding labels
labels = np.array([2, 0])

ARGS = {
    'out': out,
    'labels': labels
}
Setup block drafted by
a language model, Claude Sonnet 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 int64, ndim 0, dtype family int, 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
binary_accuracy Ran
ran on a synthesized input
ongunuzaymacar/comparatively-finetuning-bert/utils/model_utils.py
code served (permissive licence) · get_code("195884f8c99c2ded")
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

torch.manual_seed(0)

# y_pred: logits tensor with shape (batch_size, num_classes)
# The function uses torch.argmax(y_pred, dim=-1) to get predictions
# and compares with y_true
y_pred = torch.randn(2, 4)  # batch_size=2, num_classes=4

# y_true: ground truth labels with shape (batch_size,)
# The function compares argmax(y_pred) == y_true
y_true = torch.tensor([0, 2])  # batch_size=2, class indices

ARGS = {
    "y_pred": y_pred,
    "y_true": y_true,
}
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
clean_corpus Ran
ran; our contract draft was wrong, not the code
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data/encode_text.py
pointer only (licence: NONE) · get_code("580f29066c394fc3")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data 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.

compute_metrics Ran
ran on a synthesized input
soarsmu/BiasFinder/codes/fine-tuning/fine_tune.py
code served (permissive licence) · get_code("4e3b097142759615")
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 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 numpy as np
import torch

torch.manual_seed(0)

# The function expects a tuple (pred, labels) where:
# - pred: numpy array of shape (batch_size, num_classes) with logits/probabilities
# - labels: numpy array of shape (batch_size,) with integer class labels
# For binary classification, we need at least 2 classes

batch_size = 2
num_classes = 2

# Create prediction logits (batch_size, num_classes)
predictions = np.random.randn(batch_size, num_classes).astype(np.float32)

# Create binary labels (0 or 1)
labels = np.array([0, 1], dtype=np.int64)

# Bundle into tuple as expected by compute_metrics
p = (predictions, labels)

ARGS = {
    'p': p
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, 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
evaluate_btc Ran
ran on a synthesized input
soarsmu/BiasFinder/codes/evaluation/metric.py
code served (permissive licence) · get_code("6beb1e09719d4c71")
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 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 pandas as pd
import numpy as np

# Analyze the function to understand what each parameter needs:
# - labels: list-like, converted to list, used in DataFrame
# - predictions: list-like, converted to list, used in DataFrame, values converted to int
# - mutants: list-like, converted to list, used in DataFrame
# - templates: list-like, converted to list, used in DataFrame, converted to category
# - identifier: string, used as column name and for grouping
# - identifiers: list-like, used as column values

# Create small test data
num_samples = 8

labels = [0, 1, 0, 1, 0, 1, 0, 1]

predictions = [1, 1, 0, 1, 0, 0, 1, 0]

mutants = ['mut_a', 'mut_b', 'mut_a', 'mut_b', 'mut_a', 'mut_b', 'mut_a', 'mut_b']

templates = ['template1', 'template1', 'template1', 'template1', 'template2', 'template2', 'template2', 'template2']

identifier = 'gender'

identifiers = ['male', 'female', 'male', 'female', 'male', 'female', 'male', 'female']

ARGS = {
    'labels': labels,
    'predictions': predictions,
    'mutants': mutants,
    'templates': templates,
    'identifier': identifier,
    'identifiers': identifiers
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — 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
evaluate_btc_mtnlp Ran
ran on a synthesized input
soarsmu/BiasFinder/codes/evaluation/metric.py
code served (permissive licence) · get_code("d77f3f4547950237")
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 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 pandas as pd
import numpy as np

# Construct a minimal DataFrame that satisfies the function's requirements
df = pd.DataFrame({
    'template': ['A', 'B', 'A', 'C'],  # 3 unique templates
    'mutant': [1, 2, 3, 4],  # 4 mutant values
    'original': ['X', 'Y', 'X', 'Z'],  # 3 unique originals
    'prediction': [0, 1, 0, 1],  # predictions for fairness violation check
    'original_prediction': [0, 1, 1, 1]  # original predictions (different from prediction in row 2)
})

ARGS = {
    'df': df
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — 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
evaluate_fairness_violation Ran
ran on a synthesized input
soarsmu/BiasFinder/codes/evaluation/metric.py
code served (permissive licence) · get_code("7a20a049db60aecb")
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 int, ndim 0, dtype family int, 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 pandas as pd

torch.manual_seed(0)

# The function compares two lists/arrays of predictions element-wise
# and counts mismatches. We need two sequences of comparable values.

predictions = [0, 1, 0, 1]
original_predictions = [0, 1, 1, 0]

ARGS = {
    'predictions': predictions,
    'original_predictions': original_predictions
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type int, ndim 0, dtype family int, 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
gelu Ran
ran; our contract draft was wrong, not the code
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data/run_hbm.py
pointer only (licence: NONE) · get_code("835ff702d75feb5b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data 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.

get_features Ran
ran; our contract draft was wrong, not the code
uzaymacar/comparatively-finetuning-bert/utils/data_utils.py
code served (permissive licence) · get_code("a9ecfcb35141c0d8")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Sonnet 4.5, prompt python_fixture_v1) and returned tuple, ndim 3, 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

torch.manual_seed(0)

class StandInTokenizer:
    def convert_tokens_to_ids(self, token):
        if token == '[PAD]':
            return 0
        return 1

batch_size = 2
seq_length = 6

# Create input_ids with some padding
# First example: [1, 2, 3, 0, 0, 0] (3 real tokens, 3 padding)
# Second example: [4, 5, 6, 7, 0, 0] (4 real tokens, 2 padding)
input_ids = torch.tensor([
    [1, 2, 3, 0, 0, 0],
    [4, 5, 6, 7, 0, 0]
])

tokenizer = StandInTokenizer()
device = torch.device('cpu')

ARGS = {
    'input_ids': input_ids,
    'tokenizer': tokenizer,
    'device': device
}
Setup block drafted by
a language model, Claude Sonnet 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 tuple, ndim 3, 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
load_pickle Ran
ran on a synthesized input
soarsmu/BiasFinder/codes/evaluation/utils.py
code served (permissive licence) · get_code("902448ea901f1299")
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 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 pickle
import tempfile
import os

# Create a temporary pickle file with some sample data
temp_dir = tempfile.mkdtemp()
temp_file = os.path.join(temp_dir, "test_data.pkl")

# Create sample data to pickle
sample_data = {
    "predictions": [0.1, 0.2, 0.3],
    "labels": [0, 1, 0],
    "scores": 0.95
}

# Write the pickle file
with open(temp_file, 'wb') as f:
    pickle.dump(sample_data, f)

ARGS = {
    "fpath": temp_file
}
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 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
read_data Ran
ran; our contract draft was wrong, not the code
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data/encode_text.py
pointer only (licence: NONE) · get_code("3361330ad8f7f29b")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data 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.

sizeof_fmt Ran
ran; our contract draft was wrong, not the code
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data/run_hbm.py
pointer only (licence: NONE) · get_code("b6bef72aa7ff57a5")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data 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.

accuracy Not yet run
unverified (harvested, no recorded run)
soarsmu/BiasFinder/codes/evaluation/utils.py
code served (permissive licence) · get_code("89f8ce05994500e0")
How it ran

no invocation recorded.

calculate_test_accuracy Not yet run
unverified (harvested, no recorded run)
soarsmu/BiasFinder/codes/evaluation/utils.py
code served (permissive licence) · get_code("80e450cb7f0ae6aa")
How it ran

no invocation recorded.

feminineToMasculinePronoun Not yet run
unverified (harvested, no recorded run)
soarsmu/BiasFinder/codes/module/utils.py
code served (permissive licence) · get_code("20afd375d0a736a2")
How it ran

no invocation recorded.

import_data Not yet run
unverified (harvested, no recorded run)
GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data/run_hbm.py
pointer only (licence: NONE) · get_code("e0395b2222399e6e")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, GeorgeLuImmortal/Hierarchical-BERT-Model-with-Limited-Labelled-Data 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.

masculineToFemininePronoun Not yet run
unverified (harvested, no recorded run)
soarsmu/BiasFinder/codes/module/utils.py
code served (permissive licence) · get_code("d8cdad2983e65801")
How it ran

no invocation recorded.

masculineToFeminineSalutation Not yet run
unverified (harvested, no recorded run)
soarsmu/BiasFinder/codes/module/utils.py
code served (permissive licence) · get_code("0f466f60939c8876")
How it ran

no invocation recorded.

Also present in other papers' code

Of 18 samples lifted from this paper's linked repositories, 18 carry a function identity and 0 do not. Of the 18 distinct functions with an identity, 3 are also present in other papers whose code we hold (2 with at least one paper dated earlier, 1 the same month, 3 later) and 15 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
gelu 198 other papers
7 dated earlier, 191 later · 32 only as an assembly brick
1408.5882 (2014-08)
Convolutional Neural Networks for Sentence Classification
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.10125 (2019-01)
Glyce: Glyph-vectors for Chinese Character Representations
and 195 more not named here
accuracy 21 other papers
5 dated earlier, 2 the same month, 14 later
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.08746 (2019-01)
BioBERT: a pre-trained biomedical language representation model for biomedical text mining
1904.03323 (2019-04)
Publicly Available Clinical BERT Embeddings
and 18 more not named here
sizeof_fmt 1 other paper
1 later
1911.03584 (2019-11)
On the Relationship between Self-Attention and Convolutional Layers

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

Language model pre-training has proven to be useful in learning universal language representations. As a state-of-the-art language model pre-training model, BERT (Bidirectional Encoder Representations from Transformers) has achieved amazing results in many language understanding tasks. In this paper, we conduct exhaustive experiments to investigate different fine-tuning methods of BERT on text classification task and provide a general solution for BERT fine-tuning. Finally, the proposed solution obtains new state-of-the-art results on eight widely-studied text classification datasets.

For agents

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

get_harvested_code_for_paper("1905.05583")
get_code_for_paper("1905.05583")
have("1905.05583")

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

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

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

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

Connect an agent — have() is free.