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

# CodonFM Perplexity

> Score coding-sequence naturalness by CodonFM mean codon NLL and report perplexity.

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

> [!NOTE]
>
> **License:** CodonFM (Encodon) uses Apache-2.0 for code and Custom (NVIDIA Open Model License) for model weights. Please refer to the [code license](https://github.com/NVIDIA-BioNeMo/CodonFM/blob/main/LICENSE) and [model weights license](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/) 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/codonfm/social.png)

&#x20;Go to Tool Page

[Open](https://proto.evodesign.org/docs/tools/masked-models/codonfm.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/codonfm_perplexity_constraint.py#L162)

@articlecodonfm2025

```bibtex theme={null}
@article{codonfm2025,
  title={Learning the language of codon translation with CodonFM},
  author={Darabi, Sajad and Cao, Fan and Naghipourfar, Mohsen and Rabi, Sara and Sethia, Ankit and Gion, Kyle and Grewal, Jasleen and Cohen, Jonathan and Greenleaf, William and Goodarzi, Hani and Sundaram, Laksshman},
  year={2025},
  publisher={NVIDIA},
  url={https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf}
}
```

&#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)
Forward CodonFM coding-sequence scoring via masked pseudo-log-likelihood.

## API Reference

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

Configuration for CodonFM perplexity scoring (forward + gradient).

**model\_checkpoint** `enum` (default: encodon\_80m)

Encodon checkpoint to use

Options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`

**temperature** `number` *required*

Softmax temperature for CodonFM (fixed for this constraint).

**use\_ste** `boolean` (default: True)

Hard one-hot forward pass with soft-probability gradients.

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

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

**batch\_size** `integer`

Codon positions per CodonFM forward pass. Lower if OOM, higher for throughput.

## Usage

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

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

scores = constraint.evaluate()
```

## Metadata

| Property | Value |
| - | - |
| Key | `codonfm-perplexity` |
| Function | `codonfm_perplexity_constraint` |
| Category | `sequence_scoring` |
| Mode | `dual` |
| Uses GPU | `True` |
| Supported Types | `dna` |


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