> ## 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.

# ProGen Perplexity

> Score protein naturalness by ProGen2/ProGen3 mean NLL and report perplexity.

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

> [!NOTE]
>
> **License:** This constraint can use multiple tools, each under its own license. See the **Tools Used** tab and each tool's page for license details.

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

[![](https://proto-bio.github.io/proto-assets/images/tool/progen2/social.png)](https://proto.evodesign.org/docs/tools/causal-models/progen2.md)

[![](https://proto-bio.github.io/proto-assets/images/tool/progen3/social.png)](https://proto.evodesign.org/docs/tools/causal-models/progen3.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/progen_perplexity_constraint.py#L85)

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 ProGen autoregressive mean NLL.

## API Reference

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

Configuration for ProGen protein perplexity scoring.

**model\_checkpoint** `string | string` (default: progen2-large)

ProGen2 ('progen2-...') or ProGen3 ('progen3-...', bidirectional) checkpoint

**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)

Sequences per model forward pass; 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 progen_perplexity_constraint, ProGenPerplexityConfig

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

scores = constraint.evaluate()
```

## Metadata

| Property | Value |
| - | - |
| Key | `progen-perplexity` |
| Function | `progen_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.