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

# ESM-IF1 Sequence Probability

> Score sequence compatibility with a backbone under ESM-IF1 or ProteinDPO.

![ESM-IF1 Sequence Probability](https://proto-bio.github.io/proto-assets/images/constraint/esm-if1-sequence-probability/hero.png)

> [!NOTE]
>
> **License:** ESM-IF1 is open source and free for academic and commercial use under an MIT license. Please refer to [the license](https://github.com/facebookresearch/esm/blob/main/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/esm_if1/social.png)

&#x20;Go to Tool Page

[Open](https://proto.evodesign.org/docs/tools/inverse-folding/esm-if1.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/esm_if1_sequence_probability_constraint.py#L132)

@inproceedingshsu2022learning\@articlewidatalla2024aligning

```bibtex theme={null}
@inproceedings{hsu2022learning,
  title={Learning inverse folding from millions of predicted structures},
  author={Hsu, Chloe and Verkuil, Robert and Liu, Jason and Lin, Zeming and Hie, Brian and Sercu, Tom and Lerer, Adam and Rives, Alexander},
  booktitle={International Conference on Machine Learning},
  pages={8946--8970},
  year={2022},
  organization={PMLR}
}

@article{widatalla2024aligning,
  title={Aligning protein generative models with experimental fitness via Direct Preference Optimization},
  author={Widatalla, Talal and Rafailov, Rafael and Hie, Brian},
  journal={bioRxiv},
  doi={10.1101/2024.05.20.595026},
  year={2024}
}
```

&#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 proposals by ESM-IF1 likelihood given a structure; lower is better.

## API Reference

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

Configuration for ESM-IF1 / ProteinDPO sequence-probability scoring.

**weights\_variant** `enum` (default: protein\_dpo)

'protein\_dpo' (stability-aligned, default) or 'esmif' (original ESM-IF1).

Options: `esmif`, `protein_dpo`

**structure\_source** `enum` (default: configured\_structure\_inputs)

Score against configured structure\_inputs or each proposal's attached structure.

Options: `configured_structure_inputs`, `proposal_structure`

**structure\_inputs** `array`

Structures to score against; optional when using proposal structures.

**output\_chain\_id** `string`

Structure chain whose sequence the proposal supplies; inferred when unambiguous.

**score\_mode** `enum` (default: probability\_loss)

Return 1-exp(avg\_log\_likelihood), mean NLL, or perplexity (all lower is better).

Options: `probability_loss`, `nll`, `perplexity`

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

Device for ESM-IF1 scoring.

**verbose** `boolean` (default: False)

Whether to print ESM-IF1 scoring progress.

ReturnsConstraintOutput

One output per proposal. `score` follows `score_mode`;
metadata carries the ESM-IF1 average log-likelihood, NLL, perplexity and the
number of residues scored.

## Usage

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

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

scores = constraint.evaluate()
```

## Metadata

| Property | Value |
| - | - |
| Key | `esm-if1-sequence-probability` |
| Function | `esm_if1_sequence_probability_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.