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

# ESMFold

> First released in 2022, ESMFold is Meta AI's protein language model based structure predictor. It folds a protein from its sequence using the embeddings of ESM-2 in place of a multiple-sequence alignment, making it roughly an order of magnitude faster than alignment-based methods like AlphaFold2 at competitive but generally somewhat lower accuracy. This toolkit provides two tools: structure prediction for proteins and complexes from sequence, and a differentiable confidence pass that returns the gradient of an ESMFold confidence loss for sequence design.

<div class="page-hero"><img class="page-hero-banner" src="https://proto-bio.github.io/proto-assets/images/tool/esmfold/hero.png" alt="ESMFold" /><div class="tool-org-badges page-hero-badges"><a href="/docs/tools/organizations/meta-ai" class="tool-org-badge" style={{background: "#0866FF"}} title="Meta AI"><img src="https://mintcdn.com/bio-pro/_UGa2jUMKeVPCbLk/assets/images/cached/122d88bc7259.png?fit=max&auto=format&n=_UGa2jUMKeVPCbLk&q=85&s=ca6fedad598bccf781a70ad3b02bf561" alt="" class="tool-org-badge-logo" width="200" height="200" data-path="assets/images/cached/122d88bc7259.png" /> Meta AI</a></div></div>

<Note>
  **License:** ESMFold 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.
</Note>

<p class="entity-disclaimer">Proto is not affiliated with Meta AI. This toolkit is open source and builds on the implementation produced by this organization. Product names, logos, and trademarks are the property of their respective owners.</p>

<hr class="entity-rule" />

<input type="radio" name="tab-esmfold" id="none-esmfold" class="tab-radio-input" />

<input type="radio" name="tab-esmfold" id="github-esmfold" class="tab-radio-input" defaultChecked />

<input type="radio" name="tab-esmfold" id="paper-esmfold" class="tab-radio-input" />

<input type="radio" name="tab-esmfold" id="cite-esmfold" class="tab-radio-input" />

<input type="radio" name="tab-esmfold" id="source-esmfold" class="tab-radio-input" />

<input type="radio" name="tab-esmfold" id="notebook-esmfold" class="tab-radio-input" />

<input type="radio" name="tab-esmfold" id="proto-esmfold" class="tab-radio-input" />

<div class="tool-tab-bar">
  <span class="tool-tab-wrap"><label for="github-esmfold" class="tool-tab tab-open badge-github"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> GitHub</label><label for="none-esmfold" class="tool-tab tab-close badge-github"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> GitHub</label></span> <span class="tool-tab-wrap"><label for="paper-esmfold" class="tool-tab tab-open badge-paper"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Publication</label><label for="none-esmfold" class="tool-tab tab-close badge-paper"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Publication</label></span> <span class="tool-tab-wrap"><label for="cite-esmfold" class="tool-tab tab-open badge-cite"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Cite</label><label for="none-esmfold" class="tool-tab tab-close badge-cite"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Cite</label></span> <span class="tool-tab-wrap"><label for="source-esmfold" class="tool-tab tab-open badge-source"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Tool Source</label><label for="none-esmfold" class="tool-tab tab-close badge-source"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Tool Source</label></span> <span class="tool-tab-wrap"><label for="notebook-esmfold" class="tool-tab tab-open badge-notebook"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open as Notebook</label><label for="none-esmfold" class="tool-tab tab-close badge-notebook"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open as Notebook</label></span> <span class="tool-tab-wrap"><label for="proto-esmfold" class="tool-tab tab-open badge-proto"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg> Open on Proto</label><label for="none-esmfold" class="tool-tab tab-close badge-proto"><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M13 2L3 14h9l-1 8 10-12h-9l1-8z" /></svg> Open on Proto</label></span>
</div>

<a href="https://github.com/facebookresearch/esm" target="_blank" class="tab-panel github-panel" data-tab="github-esmfold">
  <div class="gh-card-wrap">
    <img src="https://opengraph.githubassets.com/1/facebookresearch/esm" class="gh-card-img img-fallback" alt="facebookresearch/esm" />

    <div class="gh-card-fallback">
      <div class="gh-fallback-org"><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> facebookresearch/esm</div>
    </div>
  </div>

  <span class="panel-goto-btn gh-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> View repo</span></span>
</a>

<a href="https://doi.org/10.1126/science.ade2574" target="_blank" class="tab-panel paper-panel" data-tab="paper-esmfold">
  <div class="paper-info">
    <div class="paper-title">Evolutionary-scale prediction of atomic-level protein structure with a language model</div>
    <div class="paper-meta">Zeming Lin, Halil Akin, ... Yaniv Shmueli</div>
    <div class="paper-meta paper-venue">Science (2023)</div>
  </div>

  <span class="panel-goto-btn pub-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" /><polyline points="14 2 14 8 20 8" /><line x1="16" y1="13" x2="8" y2="13" /><line x1="16" y1="17" x2="8" y2="17" /><polyline points="10 9 9 9 8 9" /></svg> Read paper</span></span>
</a>

<div class="tab-panel cite-panel" data-tab="cite-esmfold">
  <div class="cite-code-wrap">
    ```bibtex theme={null}
    @article{lin2023esm2,
      title={Evolutionary-scale prediction of atomic-level protein structure with a language model},
      author={Lin, Zeming and Akin, Halil and Rao, Roshan and Hie, Brian and Zhu, Zhongkai and Lu, Wenting and Smetanin, Nikita and Verkuil, Robert and Kabeli, Ori and Shmueli, Yaniv and others},
      journal={Science},
      volume={379},
      number={6637},
      pages={1123--1130},
      year={2023},
      publisher={American Association for the Advancement of Science},
      doi={10.1126/science.ade2574}
    }
    ```
  </div>

  <span class="panel-goto-btn cite-copy-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 21c3 0 7-1 7-8V5c0-1.25-.756-2.017-2-2H4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2 1 0 1 0 1 1v1c0 1-1 2-2 2s-1 .008-1 1.031V20c0 1 0 1 1 1z" /><path d="M15 21c3 0 7-1 7-8V5c0-1.25-.757-2.017-2-2h-4c-1.25 0-2 .75-2 1.972V11c0 1.25.75 2 2 2h.75c0 2.25.25 4-2.75 4v3c0 1 0 1 1 1z" /></svg> Copy citation</span></span>
</div>

<a href="https://github.com/evo-design/proto-tools/tree/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold" target="_blank" class="tab-panel source-panel" data-tab="source-esmfold">
  <div class="source-info">
    <img src="https://github.com/evo-design.png?size=40" class="source-avatar" width="36" height="36" />

    <span class="source-path">evo-design/proto-tools<span class="source-subpath">/proto\_tools/tools/structure\_prediction/esmfold</span></span>
  </div>

  <span class="panel-goto-btn source-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="currentColor"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" /></svg> View source</span></span>
</a>

<a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/examples/example.ipynb" target="_blank" class="tab-panel notebook-panel" data-tab="notebook-esmfold">
  <div class="notebook-info">
    <span class="notebook-icon">
      <svg width="40" height="40" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
        <path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" />

        <path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" />
      </svg>
    </span>

    <span class="notebook-label">Open Notebook</span>
  </div>

  <span class="panel-goto-btn notebook-goto-btn"><span><svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" /><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" /></svg> Open notebook</span></span>
</a>

<div class="tab-panel proto-panel" data-tab="proto-esmfold">
  <div class="proto-info">
    <div class="proto-cloud">
      <svg class="proto-cloud-bg" viewBox="0 0 640 512" xmlns="http://www.w3.org/2000/svg">
        <path d="M0 336c0 79.5 64.5 144 144 144H512c70.7 0 128-57.3 128-128c0-61.9-44-113.6-102.4-125.4c4.1-10.7 6.4-22.4 6.4-34.6c0-53-43-96-96-96c-19.7 0-38.1 6-53.3 16.2C367 64.2 315.3 32 256 32C167.6 32 96 103.6 96 192c0 2.7 .1 5.4 .2 8.1C40.2 219.8 0 273.2 0 336z" />
      </svg>

      <img noZoom src="https://mintcdn.com/bio-pro/KVh0EKV-IKblvXR8/assets/logo/evo-logo-light.svg?fit=max&auto=format&n=KVh0EKV-IKblvXR8&q=85&s=0cb66034ba45618505501aee6ea5f5c1" class="proto-panel-logo block dark:hidden" alt="Proto" width="198" height="151" data-path="assets/logo/evo-logo-light.svg" />

      <img noZoom src="https://mintcdn.com/bio-pro/KVh0EKV-IKblvXR8/assets/logo/evo-logo-dark.svg?fit=max&auto=format&n=KVh0EKV-IKblvXR8&q=85&s=2c9e23a14635e60384a434e220788f54" class="proto-panel-logo hidden dark:block" alt="Proto" width="198" height="151" data-path="assets/logo/evo-logo-dark.svg" />
    </div>
  </div>

  <div class="proto-actions">
    <a href="https://proto.evodesign.org/tools/esmfold-gradient" target="_blank" class="proto-action-btn"><span>ESMFold Gradient</span><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7" /><polyline points="7 7 17 7 17 17" /></svg></a>
    <a href="https://proto.evodesign.org/tools/esmfold-prediction" target="_blank" class="proto-action-btn"><span>ESMFold Structure Prediction</span><svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="7" y1="17" x2="17" y2="7" /><polyline points="7 7 17 7 17 17" /></svg></a>
  </div>
</div>

<div class="entity-contributors"><span class="entity-contributors-label">Toolkit contributors</span><span class="entity-contributors-people"><a class="entity-contributor" href="https://github.com/dguo8412" target="_blank" rel="noopener" title="dguo8412: 31 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/46211285?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">dguo8412</span></a><a class="entity-contributor" href="https://github.com/bviggiano" target="_blank" rel="noopener" title="bviggiano: 29 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/21143637?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">bviggiano</span></a><a class="entity-contributor" href="https://github.com/leba01" target="_blank" rel="noopener" title="leba01: 4 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/124846286?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">leba01</span></a><a class="entity-contributor" href="https://github.com/brianhie" target="_blank" rel="noopener" title="brianhie: 2 commits"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/6365340?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">brianhie</span></a></span></div>

| Function                 | Description                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| ------------------------ | ------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `run_esmfold_gradient()` | Differentiable ESMFold confidence loss and gradient w\.r.t. target-chain logits (GPU) | <a href="#api-run-esmfold-gradient" class="func-table-btn func-api-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" /></svg> Docs</a> <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L645" target="_blank" class="func-table-btn func-source-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a> |
| `run_esmfold()`          | Protein structure prediction using ESMFold (GPU)                                      | <a href="#api-run-esmfold" class="func-table-btn func-api-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20" /></svg> Docs</a> <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L462" target="_blank" class="func-table-btn func-source-btn"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>          |

## Background

ESMFold ([Lin et al., 2023](https://doi.org/10.1126/science.ade2574)) predicts a protein's 3D structure directly from its amino-acid sequence, without the multiple-sequence alignment (MSA) that AlphaFold2 depends on. AlphaFold2 infers which residues are in contact by reading coevolution across an alignment of homologous sequences. ESMFold instead relies on the ESM-2 protein language model, which has already internalized those evolutionary patterns by pre-training on hundreds of millions of natural sequences, so it works from the lone sequence with no alignment built at inference time. Skipping the alignment search makes ESMFold roughly an order of magnitude faster than AlphaFold2, at some cost in accuracy on targets where a deep, diverse MSA would otherwise help.

The sequence first runs through a frozen ESM-2 transformer (the released model uses the 3-billion-parameter ESM-2), which produces a per-residue representation. A folding trunk, a simplified stand-in for AlphaFold2's Evoformer, refines that representation, and a structure module reused essentially unchanged from AlphaFold2 then places each residue as a rigid backbone frame to produce all-atom coordinates. The whole prediction is recycled through these stages several times. Alongside the coordinates, ESMFold reports calibrated confidence: a per-residue predicted local distance difference test (pLDDT) for local reliability, a predicted aligned error (PAE) for the expected error in one residue's position when the structure is aligned on another, and a predicted template-modeling score (pTM) for overall fold confidence.

Meta AI open-sources the reference implementation at [facebookresearch/esm](https://github.com/facebookresearch/esm) under the MIT license; the released model is the `esmfold_v1` checkpoint, whose structure module is taken from the OpenFold reimplementation of AlphaFold2. Because the language model carries the structural signal, ESM-2's perplexity on a sequence correlates with how accurate the predicted structure will be, and accuracy continues to improve as the ESM-2 backbone is scaled up. ESMFold's speed made its headline application possible: Meta AI folded over 600 million metagenomic protein sequences and released them as the [ESM Metagenomic Atlas](https://esmatlas.com).

### Learning Resources

* [ESM Metagenomic Atlas Blog Post](https://ai.meta.com/blog/protein-folding-esmfold-metagenomics/) (Meta AI) - an overview blog post of the ESM Metagenomic Atlas, which contains structure predictions for nearly the entire [MGnify](https://www.ebi.ac.uk/metagenomics/) database of metagenomic sequences.

## Tools

<a name="api-run-esmfold" />

<div class="tool-section-card tool-section-card--predict">
  ### ESMFold Structure Prediction (`esmfold-prediction`)

  Predicts the 3D structure of one or more protein chains from their sequences. Each input complex (a single chain, or several chains folded together) is run through ESMFold and returned as a predicted `Structure` per complex with confidence metrics: per-residue pLDDT, a predicted TM-score (pTM), and predicted aligned error.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L63" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Input: ESMFoldInput">
      <ParamField path="complexes" type="List[Complex]" required>
        List of complexes to predict structures for. Inherited from `StructurePredictionInput`. Each complex can contain one or more protein chains. The linked length actually folded (summed chain residues plus the inter-chain `chain_linker`, i.e. `len(chain_linker) * (num_chains - 1)`) must not exceed 2,400.

        <Expandable title="Complex">
          <ParamField path="chains" type="List[Chain | Fragment]" required>
            Chains in the complex, in input order.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="msas" type="array">
        Pre-computed MSAs, one entry per complex. Each entry is a `ComplexMSAs` (per-chain MSAs keyed by chain index); `paired=True` marks rows taxonomy-aligned across chains. Populated by preprocess() or supplied directly.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L202" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Config: ESMFoldConfig">
      <ParamField path="residue_idx_offset" type="integer" default="512">
        Residue numbering gap between chains in multi-chain structures. Used to ensure proper chain separation in the output PDB/CIF files. Higher values create larger gaps in residue numbering between chains. Must be at least 0. Default: 512.
      </ParamField>

      <ParamField path="chain_linker" type="string" default="GGGGGGGGGGGGGGGGGGGGGGGGG">
        Amino acid sequence used to link chains internally for multi-chain prediction. ESMFold predicts multi-chain complexes by linking chains with a flexible linker sequence (typically glycines). The linker is removed in the final output. Default: 25 glycines (`"G" * 25`).
      </ParamField>

      <ParamField path="max_batch_residues" type="integer" default="1200">
        Starting cap on total residues per inference batch; auto-halved on CUDA OOM (floor = longest single complex). Must be at least 100. Default: 1200.
      </ParamField>

      <ParamField path="num_recycles" type="integer" default="4">
        Recycling iterations through the structure module.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Whether to print status messages during execution. Inherited from `StructurePredictionConfig`. Default: `False`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device to run the model on (`"cuda"`, `"cpu"`). Inherited from `StructurePredictionConfig`. Default: `"cuda"`.
      </ParamField>

      <ParamField path="timeout" type="integer" default="3600">
        Maximum execution time in seconds. `None` waits indefinitely.
      </ParamField>

      <ParamField path="seed" type="integer">
        Random seed. When set, tools run reproducibly up to small GPU float noise (see `BaseToolOutput.approx_equal`), and the seed participates in cache keys. When None, cacheable seed-sensitive tools skip cache until seeded.
      </ParamField>

      <ParamField path="include_pae_matrix" type="boolean" default="False">
        Inherited. Default: `False`.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L192" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Output: ESMFoldOutput">
      <ResponseField name="structures" type="List[Structure]" required>
        Predicted structures, each carrying an :class:`ESMFoldMetrics` instance on `.metrics`.

        <Expandable title="Structure">
          <ResponseField name="structure" type="string" required>
            Raw structure content in PDB or CIF format.
          </ResponseField>

          <ResponseField name="structure_format" type="string">
            Format of the content string (auto-detected if omitted).
          </ResponseField>

          <ResponseField name="b_factor_type" type="BFactorType">
            What the B-factor column represents.
          </ResponseField>

          <ResponseField name="source" type="string">
            Optional source identifier (filepath or tool name).
          </ResponseField>

          <ResponseField name="metrics" type="Metrics">
            Associated metrics (e.g., pLDDT, pTM scores, per-chain lists, pairwise matrices). None values are stripped at construction.
          </ResponseField>
        </Expandable>
      </ResponseField>

      **Metrics** (one set per `structures` item)

      | Metric      | Type                | Range      | Availability                   |
      | ----------- | ------------------- | ---------- | ------------------------------ |
      | `avg_plddt` | float               | 0.0 to 1.0 | always                         |
      | `ptm`       | float               | 0.0 to 1.0 | depends on model output        |
      | `avg_pae`   | float               | ≥ 0.0      | depends on model output        |
      | `pae`       | list\[list\[float]] | ≥ 0.0      | when include\_pae\_matrix=True |
    </Accordion>
  </div>

  #### Applications

  This tool folds a protein sequence into a 3D model for structural analysis or as input to downstream structure based tools. Because ESMFold does not use an MSA, it is well suited to de novo or heavily engineered sequences that have no natural homologs for an alignment to capture.

  #### Usage Tips

  * **No MSA or template search is used.** ESMFold does not incorporate MSAs into the prediction. There is no `use_msa` option (unlike Boltz-2 or Protenix), and passing one raises an error; the inherited `msas` input, by contrast, is ignored if supplied, emitting a single logged warning.
  * **Multi-chain complexes are approximated with an internal glycine linker.** `chain_linker` (default 25 glycines) joins chains before folding and is stripped from the output; this works best for homomeric assemblies and is unreliable for true hetero-complexes. Use AlphaFold3, Boltz2, Chai-1, or Protenix for those.
  * **Protein sequences only, with a hard cap of 2,400 residues per complex.** DNA, RNA, and ligands are not supported; `X` is allowed for unknown residues. The cap is enforced against the linked length actually folded: the sum of all chain residues plus the inter-chain `chain_linker` inserted between them (`len(chain_linker) * (chains - 1)`, 25 residues per junction by default). A multi-chain complex whose bare residues sum to just under 2,400 can still exceed the cap.
  * **Confidence is reported as pLDDT, pTM, and PAE.** Average pLDDT (0 to 1) is the primary per-structure quality metric; set `include_pae_matrix` to attach the full per-residue PAE matrix.

  <a name="api-run-esmfold-gradient" />
</div>

<div class="tool-section-card tool-section-card--gradient">
  ### ESMFold Gradient (`esmfold-gradient`)

  Runs a single differentiable ESMFold confidence pass: one forward-and-backward gradient evaluation, not an iterative design loop. For one or more designated chains, a relaxed `(L, 20)` amino-acid distribution replaces the discrete sequence, and ESMFold folds the complex under that soft input. The resulting pLDDT, pTM, and PAE terms are combined into one weighted scalar loss, and a single backward pass returns its gradient with respect to the input logits, along with the loss value, the per-term metrics, and the predicted `Structure`.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L280" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Input: ESMFoldGradientInput">
      <ParamField path="chains" type="List[string]" required>
        Complete complex chain sequences. Entries listed in `target_chain_indices` are replaced by the hard decode of `logits` before folding, but their lengths must match `len(logits)`.
      </ParamField>

      <ParamField path="target_chain_indices" type="List[integer]" default="[0]">
        Chain positions that should receive the relaxed target logits. Repeated target segments in proto-language should pass each occurrence once; gradients are summed through the shared logits tensor.
      </ParamField>

      <ParamField path="logits" type="List[array]" required>
        Target-chain logits in proto amino-acid order.
      </ParamField>

      <ParamField path="temperature" type="number" default="1.0">
        Softmax temperature for the target-chain relaxed sequence.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L344" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Config: ESMFoldGradientConfig">
      <ParamField path="loss_weights" type="Dict[string, number]">
        Weights for pLDDT, pTM, and pAE losses.
      </ParamField>

      <ParamField path="soft" type="number" default="1.0">
        Soft probability blend for relaxed target sequence.
      </ParamField>

      <ParamField path="hard" type="number" default="0.0">
        Straight-through hard-forward blend for relaxed target sequence.
      </ParamField>

      <ParamField path="compute_gradient" type="boolean" default="True">
        Whether to return the gradient with respect to logits.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Whether to print status messages during execution. Inherited from `StructurePredictionConfig`. Default: `False`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device to run the model on (`"cuda"`, `"cpu"`). Inherited from `StructurePredictionConfig`. Default: `"cuda"`.
      </ParamField>

      <ParamField path="timeout" type="integer" default="3600">
        Maximum execution time in seconds. `None` waits indefinitely.
      </ParamField>

      <ParamField path="seed" type="integer">
        Random seed. When set, tools run reproducibly up to small GPU float noise (see `BaseToolOutput.approx_equal`), and the seed participates in cache keys. When None, cacheable seed-sensitive tools skip cache until seeded.
      </ParamField>

      <ParamField path="include_pae_matrix" type="boolean" default="False">
        Attach the full per-residue PAE matrix.
      </ParamField>

      <ParamField path="residue_idx_offset" type="integer" default="512">
        Residue numbering gap between linked chains.
      </ParamField>

      <ParamField path="chain_linker" type="string" default="GGGGGGGGGGGGGGGGGGGGGGGGG">
        Sequence inserted between chains before folding.
      </ParamField>

      <ParamField path="max_batch_residues" type="integer" default="1200">
        Maximum residues per ESMFold inference batch.
      </ParamField>

      <ParamField path="num_recycles" type="integer" default="4">
        Structure module recycling iterations.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/esmfold.py#L398" target="_blank" class="func-table-btn func-source-btn api-model-source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="16 18 22 12 16 6" /><polyline points="8 6 2 12 8 18" /></svg> Source</a>

    <Accordion title="Output: ESMFoldGradientOutput">
      <ResponseField name="structure" type="Structure" required>
        Predicted ESMFold complex structure.

        <Expandable title="Structure">
          <ResponseField name="structure" type="string" required>
            Raw structure content in PDB or CIF format.
          </ResponseField>

          <ResponseField name="structure_format" type="string">
            Format of the content string (auto-detected if omitted).
          </ResponseField>

          <ResponseField name="b_factor_type" type="BFactorType">
            What the B-factor column represents.
          </ResponseField>

          <ResponseField name="source" type="string">
            Optional source identifier (filepath or tool name).
          </ResponseField>

          <ResponseField name="metrics" type="Metrics">
            Associated metrics (e.g., pLDDT, pTM scores, per-chain lists, pairwise matrices). None values are stripped at construction.
          </ResponseField>
        </Expandable>
      </ResponseField>

      <ResponseField name="gradient" type="array">
        Gradient matrix matching the input logits shape.
      </ResponseField>

      <ResponseField name="loss" type="number" required>
        Scalar weighted confidence objective value.
      </ResponseField>

      <ResponseField name="metrics" type="Dict[string, any]">
        Confidence metrics and per-term unweighted losses.
      </ResponseField>

      <ResponseField name="vocab" type="List[string]" required>
        Amino-acid column ordering for logits and gradient.
      </ResponseField>

      **Metrics**

      | Metric      | Type                | Range      | Availability                   |
      | ----------- | ------------------- | ---------- | ------------------------------ |
      | `avg_plddt` | float               | 0.0 to 1.0 | always                         |
      | `ptm`       | float               | 0.0 to 1.0 | depends on model output        |
      | `avg_pae`   | float               | ≥ 0.0      | depends on model output        |
      | `pae`       | list\[list\[float]] | ≥ 0.0      | when include\_pae\_matrix=True |
    </Accordion>
  </div>

  #### Applications

  This tool supplies the loss and gradient signal that gradient-based or MCMC sequence-design loops optimize for foldability: minimizing the confidence loss pushes a relaxed sequence toward one ESMFold predicts will fold well. With `compute_gradient=False` it instead provides forward-only confidence scoring (loss, metrics, and predicted structure) of a candidate sequence for ranking or filtering.

  #### Usage Tips

  * **One pass per call; this tool is not an optimization loop.** It evaluates a single relaxed sequence. Drive it from a sequence-design optimizer, or call it repeatedly, to actually design a sequence.
  * **`compute_gradient` defaults to `True`.** It runs a forward and backward pass and returns the gradient with respect to the input logits; set it `False` for forward-only scoring (`gradient=None`). The loss, metrics, and predicted structure are identical in both modes.
  * **`loss_weights` selects and weights the confidence terms.** Non-negative weights over `plddt`, `ptm`, and `pae` (default `{"plddt": 1.0}`); terms with weight `0.0` are skipped, and all-zero weights short-circuit to a zero gradient with `loss=0.0`.
  * **`logits` and the returned `gradient` share canonical amino-acid order `ACDEFGHIKLMNPQRSTVWY`.** Every chain listed in `target_chain_indices` must have length `len(logits)`; non-target chains fold normally with their fixed sequences.
  * **`soft` and `hard` trade smoothness for discreteness.** The default (`soft=1.0`, `hard=0.0`) uses pure soft probabilities for smooth optimization; set `hard=1.0` for a straight-through estimator (the forward pass sees argmax tokens while gradients still flow through the soft probabilities).
</div>

## Toolkit Notes

These apply to every ESMFold tool in this toolkit (`esmfold-prediction`, `esmfold-gradient`).

* **Requires a GPU.** Both tools run ESMFold through a PyTorch backend and need an NVIDIA GPU (roughly 16 GB of VRAM or more for longer sequences); CPU execution is not practical.
* **`max_batch_residues` is a starting cap, not a hard ceiling.** On CUDA OOM the wrapper halves the cap (floor = longest single complex) and re-splits the offending sub-batch, so the default `1200` is usually fine to leave in place.
* **MSA-free and single-sequence.** ESMFold folds from one sequence with no alignment or template search. Accuracy is generally lower than MSA-based methods on targets where a deep, diverse MSA would help.
* **`num_recycles` (default `4`) applies to both tools.** Each recycling iteration refines the structure; raising it improves accuracy at higher runtime.

<Tip>
  **Example notebook:** See the [full working example](https://github.com/evo-design/proto-tools/blob/47e34afa5ea240a3b406e323dc38aa5dc85f223e/proto_tools/tools/structure_prediction/esmfold/examples/example.ipynb) for a copy-paste-ready walkthrough.
</Tip>

## Infrastructure Guides

The following guides cover how to run tools efficiently and at scale.

<CardGroup cols={2}>
  <Card title="Tool Persistence" icon="repeat" href="/docs/tools/guides/tool-persistence">Keep a tool's model warm across calls instead of reloading it every invocation.</Card>
  <Card title="Device Management" icon="cpu" href="/docs/tools/guides/device-management">How GPUs are allocated to tools and how to target specific devices.</Card>
  <Card title="Parallel Execution" icon="layers" href="/docs/tools/guides/parallel-execution">Fan a batch of inputs out across multiple GPUs.</Card>
</CardGroup>
