# Evo 2

> Genome foundation model for long-context DNA modeling and design

- Category: Science & Biomedical AI / Genomics & Single-Cell
- Language: Python
- Repository: https://github.com/ArcInstitute/evo2
- Canonical page: https://ai-tldr.dev/tools/evo2/

## In short

Evo 2 is a genome foundation model from the Arc Institute for modeling and designing DNA sequences at single-nucleotide resolution. It works with contexts of up to 1 million base pairs, which lets it read long stretches of a genome at once rather than short fragments. It sits in the Genomics & Single-Cell category of the Science & Biomedical AI tools and is open-source, written in Python.

## Overview

Evo 2 is a genome foundation model from the Arc Institute for modeling and designing DNA sequences at single-nucleotide resolution. It works with contexts of up to 1 million base pairs, which lets it read long stretches of a genome at once rather than short fragments.

The model was trained autoregressively on OpenGenome2, a dataset of 8.8 trillion tokens drawn from all domains of life, using the StripedHyena 2 architecture. It ships in several sizes, including 1B, 7B, 20B, and 40B parameter checkpoints, with variants that support 8K, 262K, or 1M base-pair context windows.

Evo 2 supports three main tasks: scoring sequences by computing their likelihoods, extracting intermediate-layer embeddings for downstream analysis, and generating new DNA sequences from a prompt. It is distributed as a Python package that runs on NVIDIA GPUs.

## What it does

- DNA language model that works at single-nucleotide resolution with up to 1 million base-pair context
- Multiple checkpoints from 1B to 40B parameters, with 8K, 262K, and 1M context variants
- Trained on OpenGenome2, a dataset of 8.8 trillion tokens spanning all domains of life
- Zero-shot variant effect prediction, demonstrated on BRCA1 scoring
- Sequence scoring, embedding extraction, and autoregressive DNA generation from a single API
- Example notebooks for BRCA1 scoring, generation, exon classification, and sparse-autoencoder analysis

## Getting started

Install Evo 2 on a Linux machine with an NVIDIA GPU, then load a model to score, embed, or generate DNA sequences from Python.

1. Install for the 7B models

   The 7B models run in bfloat16 and need Flash Attention. Install it first, then the evo2 package. Requires Linux (or WSL2), CUDA 12.1+, and Python 3.11 or 3.12.

```bash
pip install flash-attn==2.8.0.post2 --no-build-isolation
pip install evo2
```

2. Verify the installation

   Run the bundled generation test to confirm the model loads and runs on your GPU.

```bash
python -m evo2.test.test_evo2_generation --model_name evo2_7b
```

3. Generate a DNA sequence

   Load a checkpoint and generate new DNA from a prompt sequence.

```python
from evo2 import Evo2

evo2_model = Evo2('evo2_7b')
output = evo2_model.generate(prompt_seqs=["ACGT"], n_tokens=400,
                             temperature=1.0, top_k=4)
print(output.sequences[0])
```

4. Extract embeddings

   Run a forward pass with return_embeddings to pull intermediate-layer representations for downstream tasks.

```python
import torch
from evo2 import Evo2

evo2_model = Evo2('evo2_7b')
sequence = 'ACGT'
input_ids = torch.tensor(
    evo2_model.tokenizer.tokenize(sequence),
    dtype=torch.int,
).unsqueeze(0).to('cuda:0')
layer_name = 'blocks.28.mlp.l3'
outputs, embeddings = evo2_model(input_ids, return_embeddings=True,
                                 layer_names=[layer_name])
```

## When to use it

- Predict the effect of genetic variants without task-specific training, as shown with BRCA1 scoring
- Extract sequence embeddings to feed downstream classifiers, such as exon classification
- Generate candidate DNA sequences from a prompt for sequence design work
- Score long genomic regions by likelihood using the model's long-context window
