Fill-Mask
Transformers
PyTorch
caduceus
biology
genomics
DNA
bryophytes
masked-language-modeling
mamba2
custom_code
Instructions to use bryocad/BryoCAD-Small with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use bryocad/BryoCAD-Small with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="bryocad/BryoCAD-Small", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForMaskedLM model = AutoModelForMaskedLM.from_pretrained("bryocad/BryoCAD-Small", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
|
Download README.md from bryocad/BryoCAD-Small: direct link, hf CLI and curl.
- Browser
- Download file 4.16 kB
-
https://huggingface.co/bryocad/BryoCAD-Small/resolve/main/README.md
- Command line
-
hf download hf://bryocad/BryoCAD-Small/README.md
-
curl -L -o README.md https://huggingface.co/bryocad/BryoCAD-Small/resolve/main/README.md
4.16 kB
| 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. | |