Views
No views yet
1from transformers import AutoModel, AutoModelForMaskedLM, AutoTokenizer
2import torch
3model_path = 'kuleshov-group/PlantCaduceus_l24'
4device = "cuda:0" if torch.cuda.is_available() else "cpu"
5model = AutoModelForMaskedLM.from_pretrained(model_path, trust_remote_code=True, device_map=device)
6model.eval()
7tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
8
9sequence = "ATGCGTACGATCGTAG"
10encoding = tokenizer.encode_plus(
11 sequence,
12 return_tensors="pt",
13 return_attention_mask=False,
14 return_token_type_ids=False
15 )
16input_ids = encoding["input_ids"].to(device)
17with torch.inference_mode():
18 outputs = model(input_ids=input_ids, output_hidden_states=True)1@article{Zhai2025CrossSpecies,
2 author = {Zhai, Jingjing and Gokaslan, Aaron and Schiff, Yoni and Berthel, Alexander and Liu, Z. Y. and Lai, W. L. and Miller, Z. R. and Scheben, Armin and Stitzer, Michelle C. and Romay, Maria C. and Buckler, Edward S. and Kuleshov, Volodymyr},
3 title = {Cross-species modeling of plant genomes at single nucleotide resolution using a pretrained DNA language model},
4 journal = {Proceedings of the National Academy of Sciences},
5 year = {2025},
6 volume = {122},
7 number = {24},
8 pages = {e2421738122},
9 doi = {10.1073/pnas.2421738122},
10 url = {https://doi.org/10.1073/pnas.2421738122}
11}