File size: 4,157 Bytes
c661a67
4c764b3
 
 
 
 
 
 
 
 
c661a67
4c764b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
---
library_name: transformers
base_model: kuleshov-group/PlantCAD2-Small-l24-d0768
tags:
  - biology
  - genomics
  - DNA
  - bryophytes
  - masked-language-modeling
  - mamba2
---

# BryoCAD-Small

BryoCAD-Small is a DNA foundation model adapted to bryophyte genomes through continued pre-training of [PlantCAD2-Small](https://huggingface.co/kuleshov-group/PlantCAD2-Small-l24-d0768).

The model was further pre-trained on 17 phylogenetically diverse bryophyte genomes representing 17 orders across the three major bryophyte lineages: mosses, liverworts, and hornworts.

## Model overview

BryoCAD-Small retains the bidirectional, reverse-complement-equivariant Mamba2 architecture of PlantCAD2. It processes DNA sequences at single-nucleotide resolution with a context length of 8,192 bp and uses a masked language modeling objective.

| Property | Description |
|---|---|
| Base model | PlantCAD2-Small |
| Architecture | Bidirectional, reverse-complement-equivariant Mamba2 |
| Context length | 8,192 bp |
| Tokenization | Single nucleotide |
| Pre-training objective | Masked language modeling |
| Continued pre-training data | 17 bryophyte genomes |

During continued pre-training, training loss decreased from approximately 1.158 to 1.040, a reduction of 10.2%.

The larger model is available at [bryocad/BryoCAD-Large](https://huggingface.co/bryocad/BryoCAD-Large).

## Intended uses

BryoCAD-Small is intended for research on bryophyte genomic sequences, including:

- Zero-shot motif recovery.
- Genomic sequence representation learning.
- Genomic feature prediction.
- Gene structure annotation workflows.

The released checkpoint is a masked language model. Task-specific prediction or annotation may require additional scoring procedures, fine-tuning, or downstream models.

## Loading the model

BryoCAD uses custom model code and requires a compatible PyTorch, Transformers, Mamba2, and CUDA environment.

```python
import torch
from transformers import AutoModelForMaskedLM, AutoTokenizer

model_id = "bryocad/BryoCAD-Small"

tokenizer = AutoTokenizer.from_pretrained(
    model_id,
    trust_remote_code=True,
)

model = AutoModelForMaskedLM.from_pretrained(
    model_id,
    trust_remote_code=True,
    torch_dtype=torch.bfloat16,
).to("cuda").eval()
```

This example assumes a CUDA GPU with BF16 support. Review the repository's custom code before enabling `trust_remote_code=True`.

## Masked nucleotide prediction

The following example masks one nucleotide and obtains the model's logits at that position.

```python
sequence = "ACGT" * 2048  # Example input: 8,192 bp
mask_position = 4096     # Zero-based nucleotide position

inputs = tokenizer(
    sequence,
    return_tensors="pt",
    add_special_tokens=False,
    return_attention_mask=False,
    return_token_type_ids=False,
)

input_ids = inputs["input_ids"]
assert input_ids.shape[1] == len(sequence)

input_ids[0, mask_position] = tokenizer.mask_token_id
input_ids = input_ids.to("cuda")

with torch.inference_mode():
    logits = model(input_ids=input_ids).logits

masked_position_logits = logits[0, mask_position]
```

The example illustrates model inference; the synthetic sequence is not a biological benchmark. For nucleotide prediction, restrict candidate tokens to A, C, G, and T rather than selecting from the full vocabulary.

## Limitations

- Continued pre-training used 17 bryophyte genomes and does not represent all bryophyte diversity.
- Performance may vary across species, genomic regions, and downstream tasks.
- Reduced pre-training loss does not by itself establish improved downstream performance.
- Predictions should be evaluated against independent biological evidence before use in annotation or interpretation.

## Availability and reproducibility

This repository contains the model weights, configuration, tokenizer files, and custom model code required for loading the checkpoint.

For reproducible analyses, record the repository revision and software environment used.

## Acknowledgments

BryoCAD builds on PlantCAD2 and its associated model implementation. Please also acknowledge and cite the original PlantCAD2 work when using BryoCAD.