Linné 50M

Version française plus bas

A language model trained from scratch on DNA barcodes, a fragment of the mitochondrial gene COI, without ever being given a single rule of biology.

It reads DNA one letter at a time and predicts the next one. It was never told what a gene, a codon or a protein is, nor that insects and vertebrates exist.

Code, protocol and pre-registered predictions: github.com/geekourson/linne.

What it learned on its own

Measurement Linné 50M Baseline
Loss on 17,576 never-seen species 0.349 bit/base raw entropy ≈ 1.9
Loss on new sequences of known species 0.233 bit/base
Free generations with an open reading frame (no stop codon) 94.2 % 5th-order Markov chain: 0.1 % (real DNA: 98.0 %)
AGA+AGG frequency, insect primer / vertebrate primer 49× real DNA: 2,178×
Detecting barcodes with 5 % insertions/deletions (AUROC) 0.997 8-mer nearest neighbour: 0.767
  • 78 % of its remaining uncertainty on unseen species sits on the third base of codons, and 4 % on the second.
  • In vertebrate mitochondria, AGA and AGG are stop codons. The model infers the lineage from the first bases, then changes how it writes.

Usage

import math, torch
from transformers import AutoModelForCausalLM, AutoTokenizer

tok = AutoTokenizer.from_pretrained("billygeekourson/linne-50m")
model = AutoModelForCausalLM.from_pretrained("billygeekourson/linne-50m").eval()

# Generate a barcode from a primer
ids = tok("ACTTTATATTTTATTTTTGGAGCATGAGCAGG", return_tensors="pt").input_ids
out = model.generate(ids, max_new_tokens=650, do_sample=True, temperature=1.0, top_k=0,
                     eos_token_id=2, pad_token_id=0)
print(tok.decode(out[0], skip_special_tokens=True))

# "Is this a real, intact COI barcode?" Loss in bits per base
def bits_par_base(seq):
    ids = tok(seq, return_tensors="pt").input_ids
    with torch.no_grad():
        return model(ids, labels=ids).loss.item() / math.log(2)

One base is one token. The tokenizer adds <bos>, accepts lowercase, and maps any unknown character to N, exactly as during training. The IUPAC ambiguity codes (R, Y, S, W, K, M, B, D, H, V) are tokens of their own.

Reference values for bits_par_base, measured on 3,000 barcodes of never-seen species:

median 99th percentile
real COI barcodes 0.31 0.94
the same with 5 % insertions/deletions 1.39 1.79
random DNA with the same composition 2.05 2.15

Architecture

Decoder-only Transformer, 16 layers, width 512, 8 heads, SwiGLU MLP of 1,408, pre-norm, RMSNorm, RoPE, tied embeddings, context of 1,024 bases.

51,397,120 non-embedding parameters. The architecture is exactly Llama's, so the model loads as a standard LlamaForCausalLM. The conversion was checked: the maximum logit difference with the original implementation is printed by the conversion script, and stays below 1e-4.

Vocabulary of 24 tokens: the 15 IUPAC nucleotide codes, <pad>, <bos>, <eos> and 6 reserved tokens. No BPE, no codons: splitting by three would hand the model the reading frame.

Data

GenBank, Metazoa, COI gene, 400 to 2,000 bases, published before 2018-12-01 (3,117,091 records). The NCBI taxonomy of 2018-12-01 is the only one used.

unique sequences after exact deduplication 1,922,376 (61.7 %)
species 600,587
training bases 1.149 G
held-out species (val_inedites) 17,576, with all their sequences

The split is per species, never per sequence.

Training

One RTX 3090 capped at 280 W, 4 h 14, 34,000 steps, 1.67 G tokens, about 1.45 epochs. bf16, AdamW (β = 0.9 / 0.95, weight decay 0.1), learning rate 6e-4 with a cosine schedule down to 6e-5 and 1,000 warmup steps, 49,152 tokens per step. Throughput 115 k tokens/s, MFU 74.9 %.

At equal compute, a 30 M model is 3.2 % worse on unseen species, and a 75 M model is 0.6 % worse.

Limitations

  • It does not identify species better than the simple method. A nearest neighbour on its mean embeddings finds the right genus for 59.8 % of unseen species, against 83.4 % for 8-mer nearest neighbour. For identification, see linne-b-50m.
  • A single isolated insertion barely shows in the mean loss (AUROC 0.67). It shows as a local peak in the per-base surprise.
  • Pre-2019 data only: everything published since is unknown to it.

Related model

linne-b-50m: the same trunk, fine-tuned to write order › family › genus after the sequence, and to score how suspicious a label is.


Linné 50M (français)

Un modèle de langage entraîné de zéro sur des codes-barres ADN (fragment du gène mitochondrial COI), sans jamais recevoir la moindre règle de biologie. Il lit l'ADN lettre par lettre et prédit la suivante.

  • 0,349 bit par base sur 17 576 espèces qu'il n'a jamais vues.
  • 94,2 % de ses séquences générées ont un cadre de lecture sans codon stop. Une chaîne de Markov d'ordre 5 fait 0,1 %.
  • Il écrit 49 fois moins d'AGA/AGG après une amorce de vertébré, chez qui ce sont des codons stop.
  • Il détecte les codes-barres abîmés par des insertions et des délétions avec une AUROC de 0,997, contre 0,767 pour le plus proche voisin 8-mers.
  • Limite : pour identifier le genre, la méthode simple des 8-mers fait mieux.

Le code, le protocole et les 13 prédictions pré-enregistrées sont sur github.com/geekourson/linne.

Licence MIT. Les séquences viennent de GenBank et ne sont pas redistribuées ici.

Downloads last month
-
Safetensors
Model size
51.4M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support