Skip to main content

LucaVirus: LucaVirus Model compatible with HuggingFace Transformers

Project description

LucaVirus


LucaVirus: a Unified Nucleotide-Protein Language Model for Virus

PyPI version Hugging Face Model License: MIT

LucaVirus is a Unified Nucleotide-Protein Language Model for predicting the Evolutionary and Functional Landscapes of Viruses. This repository provides the refactored implementation that is fully compatible with the Hugging Face transformers ecosystem, supporting seamless integration for various viral downstream bioinformatics tasks.

Key Features

  • Hugging Face Native: Full support for AutoModel, AutoModelForMaskedLM, AutoModelForSequenceClassification, AutoModelForTokenClassification, AutoConfig, and AutoTokenizer.
  • Unified Architecture: Single model architecture handling multiple biological modalities.
  • Task-Specific Heads:
    • LucaVirusModel: For sequences embedding.
    • LucaVirusForMaskedLM: For pre-training and sequence recovery.
    • LucaVirusForSequenceClassification: For sequence-level tasks (e.g., protein family, solubility, RdRP identity, or promoter prediction).
    • LucaVirusForTokenClassification: For residue-level tasks (e.g., secondary structure, binding sites, or post-translational modifications).
  • Extensible: Easily adaptable to custom downstream tasks using the standard transformers API.

Installation

pip install lucavirus==1.0.1
pip install tokenizers==0.19.1
pip install transformers==4.41.2

You can install LucaVirus directly from source:

git clone -b huggingface https://github.com/LucaOne/LucaVirus.git
cd LucaVirus
pip install .

For development mode:

pip install -e .

🚀Quick Start

1. Feature Extraction/Embedding

Extract high-dimensional embeddings for downstream analysis or training downstream tasks using LucaVirus-Embedding:

Please refer to the code in test/test_lucavirus_embedding.py.

2. MLM Pre-training and Sequence Recovery

Continue to perform MLM pre-training or sequence recovery.

Please refer to the code in test/test_lucavirus_mlm.py.

3. Sequence Classification

Predict properties for the entire sequence (e.g., RdRP vs. Non-RdRP):

Supports multi-class classification, binary classification, multi-label classification, and regression tasks.

Please refer to the code in test/test_lucavirus_seq_classification.py.

4. Token Classification

Predict properties for each residue/nucleotide (e.g., Secondary Structure, Binding Sites, Post-Translational Modifications):

Supports multi-class classification, binary classification, multi-label classification, and regression tasks.

Please refer to the code in test/test_lucavirus_token_classification.py.

Model Configuration

Parameter Description Default Value
vocab_size Size of the dictionary 39
hidden_size Dimension of the hidden layers 2560
num_hidden_layers Number of Transformer layers 12
num_attention_heads Number of attention heads 20
position_embeddings - ROPE
alphabet Type of sequences (e.g., gene, prot, or gene_prot) DNA, RNA, and Protein

Weights Conversion

If you have legacy weights in .pth format, use the provided conversion script to migrate them to the Hugging Face format. This script maps the original state dictionary to the new lucavirus. prefixed structure.

python scripts/convert_weights.py     

Citation

If you use LucaVirus in your research, please cite:

@article{lucavirus2025,
  title={Predicting the Evolutionary and Functional Landscapes of Viruses with a Unified Nucleotide-Protein Language Model: LucaVirus.},
  author={Pan, Yuan-Fei* and He, Yong*. et al.},
  journal={bioRxiv},
  year={2025},
  url={https://www.biorxiv.org/content/early/2025/06/20/2025.06.14.659722}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.


For more information or issues, please open a GitHub issue or contact the maintainers at [sanyuan.hy@alibaba-inc.com/heyongcsat@gmail.com].

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lucavirus-1.0.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lucavirus-1.0.1-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file lucavirus-1.0.1.tar.gz.

File metadata

  • Download URL: lucavirus-1.0.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for lucavirus-1.0.1.tar.gz
Algorithm Hash digest
SHA256 39b689e49030f926e37abb4b91bc6e003b50e8b057478f781af60317bd77ef5c
MD5 bc310f4405a7aa53f7931e303e7a63c3
BLAKE2b-256 57eccc3a954df149556a29bf96163e44db7c854382462f4854ef1157b51513ae

See more details on using hashes here.

File details

Details for the file lucavirus-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: lucavirus-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for lucavirus-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8fdd594780f1c708e6345f1deb96f95cd686baab9f54ff623dcaba5719442361
MD5 16bba11d80384d692107a36163656142
BLAKE2b-256 fb15e3aec8904ee56af2b8eff8d75fe705cbe1b6f23cf6e491e80f1a3b2c2652

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page