SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.02401 · NeurIPS · 2023

BarcodeBERT: Transformers for Biodiversity Analyses

Graham Taylor, Austin Wang, Pablo Arias, Niousha Sadjadi, Monireh Safari, Zeming Gong, Joakim Haurum, Iuliia Zarubiieva, Dirk Steinke, Lila Kari, Angel Chang, Scott Lowe

arXiv · PDF · Open in the Atlas

Code that ran

12 of 16 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (1 of them constructed an object rather than computing a result; 1 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 9 failures of our instrument; 4 no recorded run), measured 2026-11-21; 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/2311.02401.json · badge: /api/ran/2311.02401.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
bioscan-ml/BarcodeBERT canonical (classifier label)
classifier basis: census
10 ran · 3 no recorded run
bioscan-ml/barcodebert canonical (classifier label)
classifier basis: classifier_2025
1 ran · 1 no recorded run
kari-genomics-lab/barcodebert marked official in Papers with Code
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
KmerTokenizer Ran
ran on a synthesized input · constructed an object; no result was computed
kari-genomics-lab/barcodebert/barcodebert/bzsl/models/model.py
code served (permissive licence) · get_code("5131da2c2a95f44d")
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, KmerTokenizer: 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

# KmerTokenizer only needs k and stride parameters
# Looking at the function, it takes a DNA sequence string and tokenizes it

ARGS = {
    "k": 3,
    "stride": 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 KmerTokenizer — 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 KmerTokenizer 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
categorical_cross_entropy Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/bzsl/finetuning/supervised_learning.py
code served (permissive licence) · get_code("095f7547ac0cb25e")
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 as nn

torch.manual_seed(0)

# Create small tensors for testing
batch_size = 2
num_classes = 1213
output_dim = 4

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

# target: class indices tensor of shape (batch_size,)
target = torch.tensor([0, 5], dtype=torch.long)

# num_classes parameter
num_classes_param = 1213

ARGS = {
    "outputs": outputs,
    "target": target,
    "num_classes": num_classes_param,
}
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
construct_dataloader Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
bioscan-ml/BarcodeBERT/barcodebert/bzsl/finetuning/supervised_learning.py
code served (permissive licence) · get_code("db3d69966ddebb8f")
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 tuple, ndim 1, dtype family float; 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
import numpy as np
from typing import Callable, Union

torch.manual_seed(0)

# Create small sample data
X_train = np.array(["ACGTACGT", "TGCATGCA"])
X_val = np.array(["ACGTACGT"])
y_train = np.array([0, 1], dtype=np.int64)
y_val = np.array([1], dtype=np.int64)

# Create a simple tokenizer that converts DNA strings to token tensors
def simple_tokenizer(sequences: Union[list[str], str]) -> torch.Tensor:
    """Convert DNA sequences to token indices."""
    # Map DNA bases to token IDs
    token_map = {'A': 1, 'C': 2, 'G': 3, 'T': 4}
    
    if isinstance(sequences, str):
        # Single sequence
        tokens = [token_map.get(base, 0) for base in sequences]
        return torch.tensor(tokens, dtype=torch.int64)
    else:
        # List of sequences - return list of tensors
        result = []
        for seq in sequences:
            tokens = [token_map.get(base, 0) for base in seq]
            result.append(torch.tensor(tokens, dtype=torch.int64))
        return result

ARGS = {
    "X_train": X_train,
    "X_val": X_val,
    "y_train": y_train,
    "y_val": y_val,
    "batch_size": 2,
    "tokenizer": simple_tokenizer,
    "pre_tokenize": False
}
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 tuple, ndim 1, dtype family float — 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
determine_epoch_seed Ran
ran, honoured the contract we drafted
bioscan-ml/BarcodeBERT/barcodebert/utils.py
code served (permissive licence) · get_code("da25bbcd7de8221b")
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 random

ARGS = {
    'seed': 42,
    'epoch': 5,
}
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 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
evaluate Ran
ran; our contract draft was wrong, not the code
bioscan-ml/barcodebert/barcodebert/pretraining.py
code served (permissive licence) · get_code("38d6d30dfe22d0ed")
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. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
from torch.utils.data import DataLoader
from argparse import Namespace

torch.manual_seed(0)

# Create a minimal config object
config = Namespace(
    print_interval=1,
    log_interval=1,
    global_rank=0,
    distributed=False,
    tokenize_n_nucleotide=False,
    k_mer=2
)

# Create a minimal model that returns an object with .logits attribute
class MinimalModel(nn.Module):
    def __init__(self, vocab_size=16):
        super().__init__()
        self.linear = nn.Linear(10, vocab_size)
    
    def forward(self, x, attention_mask=None):
        # x shape: (batch_size, seq_len)
        # output logits shape: (batch_size, seq_len, vocab_size)
        batch_size, seq_len = x.shape
        logits = self.linear(torch.randn(batch_size, seq_len, 10))
        
        class Output:
            pass
        
        output = Output()
        output.logits = logits
        return output

model = MinimalModel(vocab_size=16)

# Create a minimal criterion (loss function)
criterion = nn.CrossEntropyLoss()

# Create a minimal dataloader
# Each batch: (sequences, _y_true, att_mask)
# sequences: (batch_size, seq_len) with token ids
# _y_true: dummy labels
# att_mask: (batch_size, seq_len) attention mask
def create_batch():
    batch_size = 2
    seq_len = 5
    sequences = torch.randint(2, 16, (batch_size, seq_len))
    y_true = torch.zeros(batch_size)
    att_mask = torch.ones(batch_size, seq_len)
    return sequences, y_true, att_mask

dataloader = [create_batch() for _ in range(3)]

ARGS = {
    'config': config,
    'model': model,
    'criterion': criterion,
    'dataloader': dataloader,
    'mask_ratio': 0.5,
    'device': 'cpu',
    'distance_table': None,
    'n_special_tokens': 2
}
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
evaluate Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/evaluation.py
code served (permissive licence) · get_code("eba6034b65efb5e6")
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 torch
import torch.nn as nn
import torch.nn.functional as F
from torch.utils.data import DataLoader, TensorDataset
import numpy as np

torch.manual_seed(0)

# Define a minimal model that matches the function's usage
class MinimalModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(4, 3)  # 4 input features, 3 output classes
    
    def forward(self, sequences, mask=None, labels=None):
        logits = self.linear(sequences)
        # Return object with logits attribute
        class Output:
            pass
        output = Output()
        output.logits = logits
        return output

# Create a minimal dataloader
batch_size = 2
num_samples = 6
num_features = 4
num_classes = 3

sequences = torch.randn(num_samples, num_features)
labels = torch.randint(0, num_classes, (num_samples,))
attention_mask = torch.ones(num_samples, 1)

dataset = TensorDataset(sequences, labels, attention_mask)
dataloader = DataLoader(dataset, batch_size=batch_size)

# Create model and device
model = MinimalModel()
device = torch.device('cpu')

# Define all arguments
ARGS = {
    'dataloader': dataloader,
    'model': model,
    'device': device,
    'partition_name': 'Val',
    'verbosity': 1,
    'is_distributed': False,
}
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
get_dnabert_encoder Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/bzsl/models/model.py
code served (permissive licence) · get_code("5f7f1f924be9f5a9")
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 function. 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 numpy as np

class MockTokenizer:
    """Minimal tokenizer that implements encode_plus method."""
    def encode_plus(self, text, max_length=None, add_special_tokens=True, pad_to_max_length=True):
        # Simple mock: convert text to token ids
        # Just return a list of integers padded to max_length
        tokens = [101] + [i % 100 + 1 for i in range(len(text.split()))] + [102]  # [CLS] + tokens + [SEP]
        if pad_to_max_length and max_length:
            if len(tokens) < max_length:
                tokens = tokens + [0] * (max_length - len(tokens))
            else:
                tokens = tokens[:max_length]
        return {'input_ids': tokens}

# Create tokenizer instance
tokenizer = MockTokenizer()

# Define arguments for get_dnabert_encoder
ARGS = {
    'tokenizer': tokenizer,
    'max_len': 32,
    'k': 6
}
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 function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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
prepare Ran
ran on a synthesized input
bioscan-ml/BarcodeBERT/barcodebert/utils.py
code served (permissive licence) · get_code("7648cdeb15ca24f3")
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 DataLoader. 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
from torch.utils.data import Dataset

torch.manual_seed(0)

class SimpleDataset(Dataset):
    def __init__(self, size=10):
        self.size = size
    
    def __len__(self):
        return self.size
    
    def __getitem__(self, idx):
        x = torch.randn(4)
        y = torch.randint(0, 2, (1,)).item()
        return x, y

dataset = SimpleDataset(size=10)
rank = 0
world_size = 2
batch_size = 2
pin_memory = False
num_workers = 0

ARGS = {
    "dataset": dataset,
    "rank": rank,
    "world_size": world_size,
    "batch_size": batch_size,
    "pin_memory": pin_memory,
    "num_workers": num_workers,
}
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 DataLoader — a DataLoader output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a DataLoader 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
remove_extra_pre_fix Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/utils.py
code served (permissive licence) · get_code("e30ded1705b3327c")
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 torch
import torch.nn as nn

torch.manual_seed(0)

# The function removes 'module.' prefix from state_dict keys
# It iterates over items() and checks if key startswith 'module.'
# So we need a state_dict (dict) with some keys that have 'module.' prefix and some that don't

state_dict = {
    'module.layer1.weight': torch.randn(4, 3),
    'module.layer1.bias': torch.randn(4),
    'module.layer2.weight': torch.randn(5, 4),
    'layer3.weight': torch.randn(3, 5),
    'layer3.bias': torch.randn(3),
}

ARGS = {
    'state_dict': state_dict
}
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 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
representations_from_df Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/datasets.py
code served (permissive licence) · get_code("3aa2e236070ba9bd")
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 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 np_nn
import numpy as np
import pandas as pd

torch.manual_seed(0)

# Create a minimal model that matches the function's usage
class MinimalModel(torch.nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = torch.nn.Linear(4, 8)
        self.device_attr = 'cpu'
    
    @property
    def device(self):
        return self.device_attr
    
    def forward(self, x, att_mask):
        # Return an object with hidden_states attribute
        output = self.linear(x)
        result = type('Output', (), {'hidden_states': [None, output]})()
        return result

# Create a minimal tokenizer
class MinimalTokenizer:
    def __call__(self, barcode):
        # Return (token_ids, attention_mask)
        # x shape: (seq_len, embedding_dim) = (5, 4)
        x = torch.randn(5, 4)
        att_mask = torch.ones(5)
        return x, att_mask

# Create sample dataframe
df = pd.DataFrame({
    'order_name': ['order1', 'order2'],
    'target_col': ['class_a', 'class_b'],
    'nucleotides': ['ACGTACGT', 'TGCATGCA']
})

# Build the arguments
model = MinimalModel()
tokenizer = MinimalTokenizer()

ARGS = {
    'df': df,
    'target_level': 'target_col',
    'model': model,
    'tokenizer': tokenizer,
    'dataset_name': 'CANADA-1.5M'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas, 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: none by the harness; any seed is in the setup block
split_input_barcode_for_dnabert Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/bzsl/models/model.py
code served (permissive licence) · get_code("58b9228a02f9d603")
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 str. 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 numpy as np

# Construct valid arguments for split_input_barcode_for_dnabert

# The function takes:
# 1. barcode: str - a DNA sequence string
# 2. k: int - k-mer size (default=6)

# Test with a simple DNA barcode string
barcode_input = "ACGAATCGA"
k_value = 6

ARGS = {
    "barcode": barcode_input,
    "k": k_value
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
train_one_epoch Ran
ran; our contract draft was wrong, not the code
bioscan-ml/BarcodeBERT/barcodebert/finetuning.py
code served (permissive licence) · get_code("0af2290a64233a5e")
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 tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is 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
import torch.nn as nn
import torch.optim as optim
from torch.optim.lr_scheduler import StepLR
from torch.utils.data import DataLoader, TensorDataset
from argparse import Namespace

torch.manual_seed(0)

# Build a small model that returns an object with .loss and .logits attributes
class SimpleModel(nn.Module):
    def __init__(self, vocab_size=128, hidden_dim=4, num_classes=3):
        super().__init__()
        self.embedding = nn.Embedding(vocab_size, hidden_dim)
        self.classifier = nn.Linear(hidden_dim, num_classes)
    
    def forward(self, sequences, mask=None, labels=None):
        # sequences: [batch, seq_len]
        embedded = self.embedding(sequences)  # [batch, seq_len, hidden_dim]
        pooled = embedded.mean(dim=1)  # [batch, hidden_dim]
        logits = self.classifier(pooled)  # [batch, num_classes]
        
        loss = None
        if labels is not None:
            criterion = nn.CrossEntropyLoss()
            loss = criterion(logits, labels)
        
        class Output:
            pass
        
        out = Output()
        out.logits = logits
        out.loss = loss if loss is not None else torch.tensor(0.0)
        return out

# Create config
config = Namespace(
    log_wandb=False,
    print_interval=1,
    log_interval=1,
    world_size=1,
    distributed=False,
    global_rank=0,
)

# Create model
model = SimpleModel(vocab_size=128, hidden_dim=4, num_classes=3)

# Create optimizer
optimizer = optim.SGD(model.parameters(), lr=0.01)

# Create scheduler
scheduler = StepLR(optimizer, step_size=1, gamma=0.1)

# Create criterion (not used in function but needed for signature compatibility)
criterion = nn.CrossEntropyLoss()

# Create a simple dataloader
batch_size = 2
seq_len = 5
num_classes = 3
num_samples = 6

sequences = torch.randint(0, 128, (num_samples, seq_len))
labels = torch.randint(0, num_classes, (num_samples,))
att_mask = torch.ones(num_samples, seq_len)

dataset = TensorDataset(sequences, labels, att_mask)
dataloader = DataLoader(dataset, batch_size=batch_size, shuffle=False)

ARGS = {
    'config': config,
    'model': model,
    'optimizer': optimizer,
    'scheduler': scheduler,
    'criterion': criterion,
    'dataloader': dataloader,
    'device': 'cpu',
    'epoch': 1,
    'n_epoch': 2,
    'total_step': 0,
    'n_samples_seen': 0,
    'use_cuda': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, wandb — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — 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_inference_model Not yet run
unverified (harvested, no recorded run)
bioscan-ml/BarcodeBERT/barcodebert/io.py
code served (permissive licence) · get_code("b3a9654b0d800dca")
How it ran

no invocation recorded.

load_old_pretrained_model Not yet run
unverified (harvested, no recorded run)
bioscan-ml/BarcodeBERT/barcodebert/io.py
code served (permissive licence) · get_code("a3031f37064b5b3c")
How it ran

no invocation recorded.

load_pretrained_model Not yet run
unverified (harvested, no recorded run)
bioscan-ml/BarcodeBERT/barcodebert/io.py
code served (permissive licence) · get_code("b3098f766bcf63bb")
How it ran

no invocation recorded.

train_one_epoch Not yet run
unverified (harvested, no recorded run)
bioscan-ml/barcodebert/barcodebert/pretraining.py
code served (permissive licence) · get_code("147fa47317265ee7")
How it ran

no invocation recorded.

Also present in other papers' code

Of 16 samples lifted from this paper's linked repositories, 16 carry a function identity and 0 do not. Of the 16 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 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
determine_epoch_seed 1 other paper
1 later
2406.02465 (2024-06)
An Empirical Study into Clustering of Unseen Datasets with Self-Supervised Encoders

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-21.

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 the global challenge of understanding and characterizing biodiversity, short species-specific genomic sequences known as DNA barcodes play a critical role, enabling fine-grained comparisons among organisms within the same kingdom of life. Although machine learning algorithms specifically designed for the analysis of DNA barcodes are becoming more popular, most existing methodologies rely on generic supervised training algorithms. We introduce BarcodeBERT, a family of models tailored to biodiversity analysis and trained exclusively on data from a reference library of 1.5 M invertebrate DNA barcodes. We compared the performance of BarcodeBERT on taxonomic identification tasks against a spectrum of machine learning approaches, including supervised training of classical neural architectures and fine-tuning of general DNA foundation models. Our self-supervised pretraining strategies on domain-specific data outperform fine-tuned foundation models, especially in identification tasks involving lower taxa such as genera and species. We also compared Barcode-BERT with BLAST, one of the most widely used bioinformatics tools for sequence searching, and found that our method matched BLAST's performance in species-level classification while being 55 times faster. Our analysis of masking and tokenization strategies also provides practical guidance for building customized DNA language models, emphasizing the importance of aligning model training strategies with dataset characteristics and domain knowledge. The code repository is available at https://github.com/bioscan-ml/BarcodeBERT.

For agents

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

get_harvested_code_for_paper("2311.02401")
get_code_for_paper("2311.02401")
have("2311.02401")

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

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

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

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

Connect an agent — have() is free.