Papers › BarcodeBERT: Transformers for Biodiversity Analysis

BarcodeBERT: Transformers for Biodiversity Analysis

4 Nov 2023arXiv:2311.02401archive 2025-07-28

Pablo Millan Arias, Niousha Sadjadi, Monireh Safari, ZeMing Gong, Austin T. Wang, Joakim Bruslund Haurum, Iuliia Zarubiieva, Dirk Steinke, Lila Kari, Angel X. Chang, Scott C. Lowe, Graham W. Taylor

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.5M 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 BarcodeBERT 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.

PaperPDFCodeCode Syntology ranMethod as code

In Syntology View this paper on Syntology, its page in Syntology's graph. That page adds which of its functions are also present in other papers' code Syntology holds, with dates, and its dated run record as JSON and a README badge. It also lists the repositories linked to the paper, the abstract and the calls for agents.

Open this paper in Syntology's Atlas, the map of the papers in Syntology's graph and their citations.

For agents, on Syntology's MCP service (how to connect):

Code

Syntology 16 code samples harvested from 2 repositories linked to this paper: 12 ran (of which 1 constructed an object rather than computing a result; 11 with no instrument failure: 0 honoured, 0 violated, 11 with no contract checked; 1 where Syntology's instrument failed) · 4 unverified. Where Syntology's instrument failed: 1 where our contract draft was wrong; failures of Syntology's instrument, not of the code.

By repository: official repository: 16 samples from 2 repositories, 12 ran (11 with no instrument failure; 1 where Syntology's instrument failed). The run record, sample by sample. “Ran” means executed on a synthesized input, not that the code is correct or reproduces the paper.

No sample is linked to this paper from 1 of its repositories that Syntology harvested for other papers:

Levels written between 2026-09-22 and 2026-09-24 (UTC): the dates Syntology's graph wrote each sample's verification level, not when the code executed. 1 of the 12 samples that ran has no recorded date.

bioscan-ml/barcodebert officialmentioned in papermentioned on GitHubpytorchMITSyntology: 15 samples, 11 ran (1 instrument-failed) · 4 unverified report
kari-genomics-lab/barcodebert officialmentioned in papermentioned on GitHubpytorchSyntology: 1 sample, 1 ran (0 instrument-failed) · 0 unverified report
bioscan-ml/bioscan-5m mentioned on GitHubSyntology: no sample linked to this paper (harvested for another paper). Syntology's graph links these samples to BIOSCAN-5M: A Multimodal Dataset for Insect Biodiversity (arXiv:2406.12723; that paper's own run record: 5 ran (of which 0 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 4 where Syntology's instrument failed) · 3 unverified); nothing checks that they implement this paper's method. report
zahrag/BIOSCAN-5M mentioned on GitHubNOASSERTIONSyntology: not harvested report

Repository list and official/mentioned flags are the archive's, frozen 2025-07-28. Reachability, where shown, is from one Syntology probe window (2026-09-16 to 2026-09-18); repositories not probed show nothing. GitHub stars are not tracked.

A paper named beside a repository with no sample linked to this paper is shown with that paper's own run record, not this paper's: “ran” means executed on a synthesized input, not that the code is correct, and “where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Papers are listed in arXiv-id order, at most three per repository.

Code Syntology ran Syntology

16 samples harvested: 12 ran (of which 1 constructed an object rather than computing a result; 11 with no instrument failure: 0 honoured, 0 violated, 11 with no contract checked; 1 where Syntology's instrument failed) · 4 unverified. “Where Syntology's instrument failed” counts failures of Syntology's instrument, not of the code. Syntology's record for this page has not changed since , the first build that kept a record date for it; when this build read Syntology's graph is in the build record. That date is not when the samples ran.

1ran · our draft was wrong
11ran
4unverified

Licence: 0 of the 16 samples are pointer only, meaning Syntology does not serve that copy's text. This page shows no code text for any sample; each one links to its file in the repository.

Harvested from 2 repositories linked to this paper, official or community; the list below is grouped by repository, each group headed by its name and what it is to the paper. “Ran” means the sample executed on a synthesized input. It does not mean the output is correct, and nothing here reproduces the paper's results. A line beginning “fixture:” under a sample that ran gives the arguments Syntology's fixture called the sample with, each as name:type/rank/element kind (? where none was recorded), and the type of what the fixture's run returned, exactly as the harness recorded them; the arguments and the returned type were recorded by two separate runs of the same fixture. No output value is shown, and a returned type says nothing about whether the output was right. “Level recorded” gives the UTC date when Syntology's graph wrote the sample's verification level, not when the code executed; where the level was written before Syntology's graph kept that date, the row says “level recorded, date not recorded”. For 1 sample that ran, the graph records a signature this page does not show: for a class the fixture built without calling, the harness called the object with inputs it made up itself, so the recorded signature is the harness's probe, not the fixture's arguments. “Honoured” and “violated” refer to a contract Syntology drafted from the code itself. “Our draft was wrong” and “the contract check could not run” are failures of Syntology's instrument, not of the code: the sample ran on Syntology's synthesized input, and then the drafted contract did not describe it, or the check itself raised an error (RAISES), lacked a dependency (DEP_MISSING) or ran out of time (TIMEOUT); hover the label for which. A metamorphic tier, where shown, is evidence of the output's shape, not that the sample implements the method.

Each sample ends with its code_sha256. A sample's code_sha256 is Syntology's identity for that exact code. It is printed in full (16 hexadecimal characters for every sample in this build), and get_code(code_sha256="…") takes it exactly as printed. An agent calls it on Syntology's MCP service (how to connect); click an identity to copy that call.

Repository labels, per sample. official repository: The archive marks this repository official for the paper. named in the paper: The archive records that the paper mentions this repository; it is not marked official. community (archive-listed): In the archive's code links for this paper, not marked official and not recorded as mentioned in the paper. found in paper text by Syntology: Syntology found this repository in the paper's own text; whether it is the authors' implementation is not asserted. community: Not in the archive's code links for this paper; a community repository Syntology harvested. Samples are grouped by repository: a repository marked official first, then by how directly the repository is tied to the paper, then in the archive's order; never by how many ran. Licence labels name the repository's licence as recorded at harvest. “Pointer only” means Syntology does not serve that copy's text, for one of six reasons: no licence file was found; the licence was not identified; the licence is recorded as permissive but that copy's record is not marked cleared; the licence is outside the permissive list Syntology serves text under (MIT, Apache-2.0, BSD and similar); this paper's copy was not located, so its licence is not recorded; or this paper's copy is cleared, but the stored copy of the same code that Syntology serves is not. Some licences outside that list permit redistribution, such as WTFPL, and GPL-3.0 under its conditions; they are simply not on the list. Hover a licence label for the reason. File links open the file on GitHub at the default branch, which may have changed since the harvest.

A function or class name links to its page when the name occurs in the harvested code of at least 5 papers; the name is a string, not an identity.

bioscan-ml/barcodebert official repository 15 samples, 11 ran (1 instrument-failed) · 4 unverified
categorical_cross_entropy barcodebert/bzsl/finetuning/supervised_learning.py ran MIT (permissive) · 095f7547ac0cb25e · report fixture: signature outputs:Tensor/2/float, target:Tensor/1/int, num_classes:int/0/int · returned Tensor · level recorded 2026-09-24
construct_dataloader barcodebert/bzsl/finetuning/supervised_learning.py ran MIT (permissive) · db3d69966ddebb8f · report fixture: signature X_train:ndarray/1/<U8, X_val:ndarray/1/<U8, y_train:ndarray/1/int, y_val:ndarray/1/int, batch_size:int/0/int, tokenizer:callable/0/?, pre_tokenize:bool/0/bool · returned tuple · level recorded 2026-09-24
determine_epoch_seed barcodebert/utils.py ran fingerprinted MIT (permissive) · da25bbcd7de8221b · report fixture: signature seed:int/0/int, epoch:int/0/int · returned int · level recorded 2026-09-24
evaluate in 514 papers barcodebert/pretraining.py ran · our draft was wrong MIT (permissive) · 38d6d30dfe22d0ed · report fixture: signature config:Namespace/0/?, model:callable/0/?, criterion:callable/0/?, dataloader:list/1/tuple, mask_ratio:float/0/float, device:str/0/str, distance_table:NoneType/0/?, n_special_tokens:int/0/int · returned dict · level recorded, date not recorded
evaluate in 514 papers barcodebert/evaluation.py ran MIT (permissive) · eba6034b65efb5e6 · report fixture: signature dataloader:DataLoader/0/?, model:callable/0/?, device:device/0/?, partition_name:str/0/str, verbosity:int/0/int, is_distributed:bool/0/bool · returned dict · level recorded 2026-09-24
get_dnabert_encoder barcodebert/bzsl/models/model.py ran MIT (permissive) · 5f7f1f924be9f5a9 · report fixture: signature tokenizer:MockTokenizer/0/?, max_len:int/0/int, k:int/0/int · returned function · level recorded 2026-09-24
prepare in 17 papers barcodebert/utils.py ran MIT (permissive) · 7648cdeb15ca24f3 · report fixture: signature dataset:SimpleDataset/0/?, rank:int/0/int, world_size:int/0/int, batch_size:int/0/int, pin_memory:bool/0/bool, num_workers:int/0/int · returned DataLoader · level recorded 2026-09-24
remove_extra_pre_fix barcodebert/utils.py ran MIT (permissive) · e30ded1705b3327c · report fixture: signature state_dict:dict/0/? · returned dict · level recorded 2026-09-24
representations_from_df barcodebert/datasets.py ran MIT (permissive) · 3aa2e236070ba9bd · report fixture: signature df:DataFrame/0/?, target_level:str/0/str, model:callable/0/?, tokenizer:callable/0/?, dataset_name:str/0/str · returned tuple · level recorded 2026-09-24
split_input_barcode_for_dnabert barcodebert/bzsl/models/model.py ran MIT (permissive) · 58b9228a02f9d603 · report fixture: signature barcode:str/0/str, k:int/0/int · returned str · level recorded 2026-09-24
train_one_epoch in 50 papers barcodebert/finetuning.py ran MIT (permissive) · 0af2290a64233a5e · report fixture: signature config:Namespace/0/?, model:callable/0/?, optimizer:SGD/0/?, scheduler:StepLR/0/?, criterion:callable/0/?, dataloader:DataLoader/0/?, device:str/0/str, epoch:int/0/int, n_epoch:int/0/int, total_step:int/0/int, n_samples_seen:int/0/int, use_cuda:bool/0/bool · returned tuple · level recorded 2026-09-24
load_inference_model barcodebert/io.py unverified MIT (permissive) · b3a9654b0d800dca · report
load_old_pretrained_model barcodebert/io.py unverified MIT (permissive) · a3031f37064b5b3c · report
load_pretrained_model in 40 papers barcodebert/io.py unverified MIT (permissive) · b3098f766bcf63bb · report
train_one_epoch in 50 papers barcodebert/pretraining.py unverified MIT (permissive) · 147fa47317265ee7 · report
kari-genomics-lab/barcodebert official repository 1 sample, 1 ran (0 instrument-failed) · 0 unverified
KmerTokenizer barcodebert/bzsl/models/model.py ran fingerprinted MIT (permissive) · 5131da2c2a95f44d · report fixture: returned KmerTokenizer · level recorded 2026-09-22

Method as code Syntology

What Syntology's graph records as this paper's claimed method, lifted into code: each assembly names its bricks (functions and classes), each with its own role and its own verification level. An assembly is not a check that the code implements the method correctly or reproduces the paper's results. Levels are each brick's own verification level in Syntology's graph (level 0: no recorded run), listed brick by brick and never combined into one level; “ran” means the brick executed on a synthesized input, not that its output is correct, and the instrument figure counts failures of Syntology's instrument, not of the code. Where a model read the code against the paper's claim, each assembly's label verdict is one model's judgement, kept in this page's JSON twin; it is not calibrated, so no card prints it.

1 assembly on this paper: 1 harvested, 0 generated.

harvested Assembly for BarcodeBERT (graph method: BarcodeBERT). 1 brick; individually on a fixture: 1 ran (of which 1 constructed an object rather than computing a result; 1 with no instrument failure: 0 honoured, 0 violated, 1 with no contract checked; 0 where Syntology's instrument failed) · 0 unverified; the one sample that ran constructed an object rather than computing a result. The assembly has not been run end-to-end.

  1. KmerTokenizer entry · level 1 · ran · 5131da2c2a95f44d

Each brick ends with its code_sha256, Syntology's identity for that exact code; click one to copy the get_code call that returns it. For agents, on Syntology's MCP service: assembly(arxiv_id="2311.02401") returns these assemblies with each brick's role and wiring (how to connect).

Tasks

Model Selection

Results from the paper archive 2025-07-28

No leaderboard rows for this paper in the archive.

Report a problem or propose a change · a person checks every report against the paper or source before anything changes; decisions are listed on /corrections