Views
No views yet
transformers library, allowing for easy loading and inference.transformers library as follows:1import torch
2from transformers import Evo2ForCausalLM, Evo2Tokenizer
3
4# Replace with your local path or the Hub repo ID after uploading
5model_path = "path/to/this/repo"
6
7print(f"Loading model from {model_path}...")
8model = Evo2ForCausalLM.from_pretrained(model_path)
9tokenizer = Evo2Tokenizer.from_pretrained(model_path)
10
11# Move to GPU if available
12device = "cuda" if torch.cuda.is_available() else "cpu"
13model = model.to(device)
14
15# Input sequence (DNA)
16sequence = "ACGTACGT"
17print(f"Input: {sequence}")
18
19# Tokenize
20input_ids = tokenizer.encode(sequence, return_tensors="pt").to(device)
21
22# Generate
23print("Generating...")
24with torch.no_grad():
25 output = model.generate(input_ids, max_new_tokens=20)
26
27# Decode
28generated_sequence = tokenizer.decode(output[0])
29print(f"Output: {generated_sequence}")1@article{brixi2024genome,
2 title={Genome modeling and design across all domains of life with Evo 2},
3 author={Brixi, Garyk and Durrant, Matthew G and Ku, Jerome and Poli, Michael and others},
4 journal={bioRxiv},
5 year={2024},
6 publisher={Cold Spring Harbor Laboratory}
7}