AmelieSchreiber / LucaOne

huggingface.co
Total runs: 10
24-hour runs: -1
7-day runs: 1
30-day runs: 4
Model's Last Updated: June 24 2025

Introduction of LucaOne

Model Details of LucaOne

LucaOne

LucaOne: Generalized Biological Foundation Model with Unified Nucleic Acid and Protein Language.

Github Page: https://github.com/LucaOne/LucaOne

This repo contains weights (checkpoint=17600000) and core codes (modified to suit HF API, might be unstable in the current stage) for LucaOne general-purpose language model (LucaOneGPLM).

To calculate the embedding of a nucleotide/protein sequence:

import torch
from transformers import AutoModel, AutoTokenizer

def gene_seq_replace(seq):
    '''
    Nucleic acid (gene replace: A->1, U/T->2, C->3, G->4, N->5
    :param seq:
    :return:
    '''
    new_seq = ""
    for ch in seq:
        if ch in ["A", "a"]:
            new_seq += "1"
        elif ch in ["T", "U", "t", "u"]:
            new_seq += "2"
        elif ch in ["C", "c"]:
            new_seq += "3"
        elif ch in ["G", "g"]:
            new_seq += "4"
        else: # unknown
            new_seq += "5"
    return new_seq


model = AutoModel.from_pretrained("Yuanfei/LucaOne", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("Yuanfei/LucaOne", trust_remote_code=True)

# Test input
seq = "ATCGCGAGTAGCGAGNNNAGCGAT"
seq_type = "gene" # or "prot"

if seq_type == "gene":
    seq = gene_seq_replace(seq)

print("seq len: %d:" % len(seq))

# Test run
seq_encoded = tokenizer.encode(seq)
input_ids = torch.tensor(seq_encoded, dtype=torch.int64).unsqueeze(0)

print("input_ids:")
print(input_ids)

if seq_type == "gene":
    token_type_ids = torch.zeros_like(input_ids)
else:
    token_type_ids = torch.ones_like(input_ids)

encoding = {
    "input_ids": input_ids, 
    "token_type_ids": token_type_ids, 
}

if seq_type == "prot":
    new_encoding = {}
    for item in encoding.items():
        new_encoding[item[0] + "_b"] = item[1]
    encoding = new_encoding

batch = encoding
batch["return_dict"] = True

res = model(**batch)

if seq_type == "prot":
    embedding = res.hidden_states_b
else:
    embedding = res.hidden_states

print("embedding matrix(include [CLS] and [SEP]):")
print(embedding)
print(embedding.shape)

print("[CLS] embedding vector:")
cls_vec = embedding[0, 0, :]
print(cls_vec)
print(cls_vec.shape)

If there is an error when loading tokenizer: "ValueError: Tokenizer class AlphabetTokenizer does not exist or is not currently imported." then try to run the alphabet.py first.


Runs of AmelieSchreiber LucaOne on huggingface.co

10
Total runs
-1
24-hour runs
1
3-day runs
1
7-day runs
4
30-day runs

More Information About LucaOne huggingface.co Model

More LucaOne license Visit here:

https://choosealicense.com/licenses/apache-2.0

LucaOne huggingface.co

LucaOne huggingface.co is an AI model on huggingface.co that provides LucaOne's model effect (), which can be used instantly with this AmelieSchreiber LucaOne model. huggingface.co supports a free trial of the LucaOne model, and also provides paid use of the LucaOne. Support call LucaOne model through api, including Node.js, Python, http.

AmelieSchreiber LucaOne online free

LucaOne huggingface.co is an online trial and call api platform, which integrates LucaOne's modeling effects, including api services, and provides a free online trial of LucaOne, you can try LucaOne online for free by clicking the link below.

AmelieSchreiber LucaOne online free url in huggingface.co:

https://huggingface.co/AmelieSchreiber/LucaOne

LucaOne install

LucaOne is an open source model from GitHub that offers a free installation service, and any user can find LucaOne on GitHub to install. At the same time, huggingface.co provides the effect of LucaOne install, users can directly use LucaOne installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

LucaOne install url in huggingface.co:

https://huggingface.co/AmelieSchreiber/LucaOne

Url of LucaOne

Provider of LucaOne huggingface.co

AmelieSchreiber
ORGANIZATIONS

Other API from AmelieSchreiber

huggingface.co

Total runs: 0
Run Growth: 0
Growth Rate: 0.00%
Updated:August 21 2024