Skip to content

EVO Models Inference

This tutorial covers inference with EVO-1 and EVO-2, large-scale genomic foundation models that support both sequence generation and likelihood scoring.

Full Notebook

View Full Notebook

Prerequisites

uv pip install -e '.[base,inference,cuda124]'

EVO-2

Load Configuration

from dnallm import load_config

configs = load_config("./inference_evo_config.yaml")

Load Model

from dnallm import load_model_and_tokenizer

model_name = "arcinstitute/evo2_1b_base"
model, tokenizer = load_model_and_tokenizer(
    model_name,
    task_config=configs['task'],
    source="huggingface"
)

Create Inference Engine

from dnallm import DNAInference

inference_engine = DNAInference(
    model=model,
    tokenizer=tokenizer,
    config=configs
)

Generate Sequences

output = inference_engine.generate(["@", "ATG"])

Display generated sequences with scores:

for seq in output:
    print(f"Input Sequence: {seq['Prompt']}")
    print(f"Generated Sequence: {seq['Output']}")
    print(f"Score: {seq['Score']}")
    print()

Score Sequences

Compute log-likelihood scores for given sequences:

scores = inference_engine.scoring(["ATCCGCATG", "ATGCGCATG"])
for res in scores:
    print(f"Input Sequence: {res['Input']}")
    print(f"Score: {res['Score']}")
    print()

EVO-1

EVO-1 uses the same inference API with a different model checkpoint:

model_name = "togethercomputer/evo-1-131k-base"
model, tokenizer = load_model_and_tokenizer(
    model_name,
    task_config=configs['task'],
    source="huggingface"
)

inference_engine = DNAInference(
    model=model,
    tokenizer=tokenizer,
    config=configs
)

Generate and score with the same methods:

output = inference_engine.generate(["@", "ACGT"])
for seq in output:
    print(f"Input Sequence: {seq['Prompt']}")
    print(f"Generated Sequence: {seq['Output']}")
    print(f"Score: {seq['Score']}")
    print()
scores = inference_engine.scoring(["ATCCGCATG", "ATGCGCATG"])
for res in scores:
    print(f"Input Sequence: {res['Input']}")
    print(f"Score: {res['Score']}")
    print()