Skip to main content

LucaOne: LucaGPLM Model compatible with HuggingFace Transformers

Project description

LucaOne(LucaGPLM)


LucaOne: a Foundation Model for Genomic and Protein Sequences

PyPI version Hugging Face Model License: MIT

LucaOne is a foundation model based on the LucaGPLM architecture, specifically engineered for biological sequences including DNA, Proteins, and RNA. This repository provides the refactored implementation that is fully compatible with the Hugging Face transformers ecosystem, supporting seamless integration for various 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:
    • LucaGPLMModel: For sequences embedding.
    • LucaGPLMForMaskedLM: For pre-training and sequence recovery.
    • LucaGPLMForSequenceClassification: For sequence-level tasks (e.g., protein family, solubility, or promoter prediction).
    • LucaGPLMForTokenClassification: 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 lucaone==1.1.0
pip install tokenizers==0.19.1
pip install transformers==4.41.2

You can install LucaOne directly from source:

git clone -b huggingface https://github.com/LucaOne/LucaOne.git
cd lucaone
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 LucaOne-Embedding:

Please refer to the code in test/test_lucaone_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_lucaone_mlm.py.

3. Sequence Classification

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

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

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

4. Token Classification

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

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

Please refer to the code in test/test_lucaone_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 20
num_attention_heads Number of attention heads 40
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 lucaone. prefixed structure.

python scripts/convert_weights.py --input path/to/original.pth --output ./hf_model_dir

Citation

If you use LucaOne in your research, please cite:

@article{lucaone2024,
  title={Generalized biological foundation model with unified nucleic acid and protein language.},
  author={He, Yong, Fang, P., Shan, Y. et al.},
  journal={Nat Mach Intell},
  year={2025},
  url={https://doi.org/10.1038/s42256-025-01044-4}
}

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

lucaone-1.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

lucaone-1.1.0-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

Details for the file lucaone-1.1.0.tar.gz.

File metadata

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

File hashes

Hashes for lucaone-1.1.0.tar.gz
Algorithm Hash digest
SHA256 1c61c219e0db17745b6385db288f1ea0e584031e131714e6ae605b0839971f29
MD5 d13afa6dda75ec4f27571a8931f77804
BLAKE2b-256 b791913e47b5a6725d21ee34de303c7b30d69ac01226be1681a17d7fb02f23e9

See more details on using hashes here.

File details

Details for the file lucaone-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: lucaone-1.1.0-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 lucaone-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45b3e25df12960cf8a07105d97f18ad3418f609aa8f4a9de505f5455af32c4aa
MD5 ac9c0cbf21f899c4f443058d28425f9d
BLAKE2b-256 c50133bb12a2253d19424b3c6901d12f0a7baa754cdbfd750d50f12bfffd2515

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