> ## Documentation Index
> Fetch the complete documentation index at: https://proto.evodesign.org/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# ESM3 Perplexity

> Score protein naturalness by ESM3 masked mean NLL and report pseudo-perplexity.

![ESM3 Perplexity](https://proto-bio.github.io/proto-assets/images/constraint/esm3-perplexity/hero.png)

> [!NOTE]
>
> **License:** ESM3 is open source and free for academic and commercial use under an MIT license. Please refer to [the license](https://github.com/Biohub/esm/blob/main/LICENSE.md) for full terms.

This constraint is open source. Any third-party models, product names, or trademarks referenced are the property of their respective owners, and Proto is not affiliated with them.

***

&#x20;Tools Used Tools Used  Source Source  Cite Cite

![](https://proto-bio.github.io/proto-assets/images/tool/esm3/social.png)

&#x20;Go to Tool Page

[Open](https://proto.evodesign.org/docs/tools/masked-models/esm3.md)

![Proto](https://mintcdn.com/bio-pro/cMLt8hAqaP9M3LKy/assets/logo/logo-light.svg?fit=max\&auto=format\&n=cMLt8hAqaP9M3LKy\&q=85\&s=f5e5dfd1b8f9b9db3a0be0e2eb01f678)

evo-design/proto-language

&#x20;View source

[Open](https://github.com/evo-design/proto-language/blob/1a97e675c7e5e4ae0e92be91b1bb7b49f1331104/proto_language/constraint/sequence_scoring/esm3_perplexity_constraint.py#L70)

@articlehayes2025esm3\@softwareevolutionaryscale\_2024

```bibtex theme={null}
@article{hayes2025esm3,
  title={Simulating 500 million years of evolution with a language model},
  author={Hayes, Thomas and Rao, Roshan and Akin, Halil and Sofroniew, Nicholas J. and Oktay, Deniz and Lin, Zeming and Verkuil, Robert and Tran, Vincent Q. and Deaton, Jonathan and Wiggert, Marius and Badkundri, Rohil and Shafkat, Irhum and Gong, Jun and Derry, Alexander and Molina, Raul S. and Thomas, Neil and Khan, Yousuf A. and Mishra, Chetan and Kim, Carolyn and Bartie, Liam J. and Nemeth, Matthew and Hsu, Patrick D. and Sercu, Tom and Candido, Salvatore and Rives, Alexander},
  journal={Science},
  volume={387},
  number={6736},
  pages={850--858},
  year={2025},
  publisher={American Association for the Advancement of Science},
  doi={10.1126/science.ads0018}
}

@software{evolutionaryscale_2024,
  author={{EvolutionaryScale Team}},
  title={evolutionaryscale/esm},
  year={2024},
  publisher={Zenodo},
  doi={10.5281/zenodo.14219303},
  url={https://doi.org/10.5281/zenodo.14219303}
}
```

&#x20;Copy citation

Constraint contributors[![](https://avatars.githubusercontent.com/u/61667248?v=4\&s=64)adititm](https://github.com/adititm)[![](https://avatars.githubusercontent.com/u/21143637?v=4\&s=64)bviggiano](https://github.com/bviggiano)
Score protein sequences by ESM3 masked mean NLL.

Ambiguous residues (`X`, `B`, `Z`, ...) are excluded from the mean by `esm3-score`.

## API Reference

ConfigESM3PerplexityConfig[ Source](https://github.com/evo-design/proto-language/blob/1a97e675c7e5e4ae0e92be91b1bb7b49f1331104/proto_language/constraint/sequence_scoring/esm3_perplexity_constraint.py#L35)

Configuration for ESM3 masked pseudo-perplexity scoring.

**model\_checkpoint** `string` (default: esm3\_sm\_open\_v1)

ESM3 weights variant

**score\_mode** `enum` (default: nll)

Return raw mean NLL by default, or perplexity when set to 'ppl'.

Options: `nll`, `ppl`

**batch\_size** `integer` (default: 8)

Masked variants per ESM3 forward pass, pooled across sequences; lower if OOM.

**device** `string` (default: cuda)

Device for model execution, e.g. 'cuda' or 'cuda:0'.

ReturnsConstraintOutput

Per-proposal scores with NLL and perplexity metadata.

## Usage

```python python icon="python" theme={null}
from proto_language.core import Constraint
from proto_language.constraint import esm3_perplexity_constraint, ESM3PerplexityConfig

constraint = Constraint(
    inputs=[segment],
    function=esm3_perplexity_constraint,
    function_config=ESM3PerplexityConfig(
        # Configure parameters here
    ),
)

scores = constraint.evaluate()
```

## Metadata

| Property | Value |
| - | - |
| Key | `esm3-perplexity` |
| Function | `esm3_perplexity_constraint` |
| Category | `sequence_scoring` |
| Mode | `discrete` |
| Uses GPU | `True` |
| Supported Types | `protein` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.