> ## 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 (Encodon)

> CodonFM (model name Encodon) is a codon-level masked language model of protein-coding sequences from NVIDIA. Unlike nucleotide- or amino-acid-level models, Encodon tokenizes a coding sequence in-frame at codon resolution (one token per 3 nt), so it directly captures synonymous-codon usage and codon-context signals that are invisible to an amino-acid model. This toolkit exposes four Encodon checkpoints (80M, 600M, 1B, and a codon-frequency-aware-masking 1B variant) for coding-sequence fitness scoring, mutation-effect prediction, embeddings, and differentiable sequence design.

<div class="page-hero"><img class="page-hero-banner" src="https://proto-bio.github.io/proto-assets/images/tool/codonfm/hero.png" alt="CodonFM (Encodon)" /><div class="tool-org-badges page-hero-badges"><a href="/docs/tools/organizations/nvidia" class="tool-org-badge" style={{background: "#76B900"}} title="NVIDIA"><img src="https://avatars.githubusercontent.com/u/1728152?s=200&v=4" alt="" class="tool-org-badge-logo" /> NVIDIA</a> <a href="/docs/tools/organizations/arc-institute" class="tool-org-badge tool-org-badge-light" style={{background: "#e0e0e0"}} title="Arc Institute"><img src="https://mintcdn.com/bio-pro/_UGa2jUMKeVPCbLk/assets/images/cached/2f286ca379a2.png?fit=max&auto=format&n=_UGa2jUMKeVPCbLk&q=85&s=8dfa2f559c96e84c86ef4d3df3cb39d7" alt="" class="tool-org-badge-logo" width="200" height="200" data-path="assets/images/cached/2f286ca379a2.png" /> Arc Institute</a> <a href="/docs/tools/organizations/university-of-california-san-francisco" class="tool-org-badge" style={{background: "#052049"}} title="University of California, San Francisco"><img src="https://mintcdn.com/bio-pro/rW-ZVHoYhZw2v7T_/assets/images/cached/5041e72f92fb.png?fit=max&auto=format&n=rW-ZVHoYhZw2v7T_&q=85&s=7ac60809f069a1cfd150f24d073683ca" alt="" class="tool-org-badge-logo" width="330" height="161" data-path="assets/images/cached/5041e72f92fb.png" /> UCSF</a></div></div>

<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.
</Note>

<p class="entity-disclaimer">Proto is not affiliated with NVIDIA, Arc Institute, and University of California, San Francisco. This toolkit is open source and builds on the implementations produced by these organizations. Product names, logos, and trademarks are the property of their respective owners.</p>

<hr class="entity-rule" />

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

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

<input type="radio" name="tab-codonfm" id="hf-codonfm" class="tab-radio-input" />

<input type="radio" name="tab-codonfm" id="preprint-codonfm" class="tab-radio-input" />

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

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

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

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

<div class="tool-tab-bar">
  <span class="tool-tab-wrap"><label for="github-codonfm" 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 <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" /></svg> 88</label><label for="none-codonfm" 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 <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" /></svg> 88</label></span> <span class="tool-tab-wrap"><label for="hf-codonfm" class="tool-tab tab-open badge-hf"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> HuggingFace</label><label for="none-codonfm" class="tool-tab tab-close badge-hf"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> HuggingFace</label></span> <span class="tool-tab-wrap"><label for="preprint-codonfm" class="tool-tab tab-open badge-preprint"><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> Preprint</label><label for="none-codonfm" class="tool-tab tab-close badge-preprint"><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> Preprint</label></span> <span class="tool-tab-wrap"><label for="cite-codonfm" 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-codonfm" 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-codonfm" 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-codonfm" 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-codonfm" 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-codonfm" 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-codonfm" 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-codonfm" 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/NVIDIA-BioNeMo/CodonFM" target="_blank" class="tab-panel github-panel" data-tab="github-codonfm">
  <div class="gh-card-wrap">
    <img src="https://opengraph.githubassets.com/1/NVIDIA-BioNeMo/CodonFM" class="gh-card-img img-fallback" alt="NVIDIA-BioNeMo/CodonFM" />

    <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> NVIDIA-BioNeMo/CodonFM</div>
      <div class="gh-fallback-desc">A family of codon-resolution language models trained on 130 million protein-coding sequences from over 20,000 species.</div>
      <div class="gh-fallback-stats"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" /></svg> 88 stars</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>

<div class="tab-panel hf-panel hf-multi-panel" data-tab="hf-codonfm">
  <div class="hf-model-list">
    <a href="https://huggingface.co/nvidia/NV-CodonFM-Encodon-80M-v1" target="_blank" class="hf-model-card">
      <img src="https://cdn-thumbnails.huggingface.co/social-thumbnails/models/nvidia/NV-CodonFM-Encodon-80M-v1.png" class="hf-model-card-bg img-fallback" alt="NV-CodonFM-Encodon-80M-v1" />

      <span class="hf-model-card-label"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> NV-CodonFM-Encodon-80M-v1</span>
    </a>

    <a href="https://huggingface.co/nvidia/NV-CodonFM-Encodon-600M-v1" target="_blank" class="hf-model-card">
      <img src="https://cdn-thumbnails.huggingface.co/social-thumbnails/models/nvidia/NV-CodonFM-Encodon-600M-v1.png" class="hf-model-card-bg img-fallback" alt="NV-CodonFM-Encodon-600M-v1" />

      <span class="hf-model-card-label"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> NV-CodonFM-Encodon-600M-v1</span>
    </a>

    <a href="https://huggingface.co/nvidia/NV-CodonFM-Encodon-1B-v1" target="_blank" class="hf-model-card">
      <img src="https://cdn-thumbnails.huggingface.co/social-thumbnails/models/nvidia/NV-CodonFM-Encodon-1B-v1.png" class="hf-model-card-bg img-fallback" alt="NV-CodonFM-Encodon-1B-v1" />

      <span class="hf-model-card-label"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> NV-CodonFM-Encodon-1B-v1</span>
    </a>

    <a href="https://huggingface.co/nvidia/NV-CodonFM-Encodon-Cdwt-1B-v1" target="_blank" class="hf-model-card">
      <img src="https://cdn-thumbnails.huggingface.co/social-thumbnails/models/nvidia/NV-CodonFM-Encodon-Cdwt-1B-v1.png" class="hf-model-card-bg img-fallback" alt="NV-CodonFM-Encodon-Cdwt-1B-v1" />

      <span class="hf-model-card-label"><img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="16" height="16" class="hf-logo" /> NV-CodonFM-Encodon-Cdwt-1B-v1</span>
    </a>
  </div>
</div>

<a href="https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf" target="_blank" class="tab-panel preprint-panel" data-tab="preprint-codonfm">
  <span class="panel-goto-btn preprint-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 preprint</span></span>
</a>

<div class="tab-panel cite-panel" data-tab="cite-codonfm">
  <div class="cite-code-wrap">
    ```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}
    }
    ```
  </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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm" target="_blank" class="tab-panel source-panel" data-tab="source-codonfm">
  <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/masked\_models/codonfm</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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/examples/example.ipynb" target="_blank" class="tab-panel notebook-panel" data-tab="notebook-codonfm">
  <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-codonfm">
  <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/codonfm-embedding" target="_blank" class="proto-action-btn"><span>CodonFM Embeddings</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/codonfm-fitness" target="_blank" class="proto-action-btn"><span>CodonFM Fitness</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/codonfm-gradient" target="_blank" class="proto-action-btn"><span>CodonFM 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/codonfm-sample" target="_blank" class="proto-action-btn"><span>CodonFM Sampling</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/codonfm-score" target="_blank" class="proto-action-btn"><span>CodonFM Mutation Score</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/roknabadi" target="_blank" rel="noopener" title="roknabadi: 1 commit"><img noZoom class="entity-contributor-avatar" src="https://avatars.githubusercontent.com/u/74315203?v=4&s=64" alt="" loading="lazy" /><span class="entity-contributor-login">roknabadi</span></a></span></div>

| Function                   | Description                                                                                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| -------------------------- | ---------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `run_codonfm_embeddings()` | Extract final-layer CLS embeddings for coding sequences with the CodonFM/Encodon model (GPU)         | <a href="#api-run-codonfm-embeddings" 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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_embeddings.py#L107" 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_codonfm_fitness()`    | Score coding-sequence fitness with the upstream CodonFM/Encodon visible-token objective (GPU)        | <a href="#api-run-codonfm-fitness" 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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_fitness.py#L118" 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_codonfm_gradient()`   | Compute the CodonFM/Encodon masked pseudo-log-likelihood gradient for relaxed coding sequences (GPU) | <a href="#api-run-codonfm-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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_gradient.py#L160" 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_codonfm_sample()`     | Resample a subset of codons in coding sequences with the CodonFM/Encodon model (GPU)                 | <a href="#api-run-codonfm-sample" 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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_sample.py#L157" 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_codonfm_score()`      | Score codon substitutions by ref-vs-alt log-likelihood ratio with the CodonFM/Encodon model (GPU)    | <a href="#api-run-codonfm-score" 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/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_score.py#L206" 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

Encodon is a BERT-style Transformer encoder trained with a masked-language-modeling objective over codon tokens ([Darabi et al., 2025](https://research.nvidia.com/labs/dbr/assets/data/manuscripts/nv-codonfm-preprint.pdf)). Each coding sequence is split into in-frame codons, a fraction of codon tokens are masked, and the model predicts the original codon from its full bidirectional context. Because the vocabulary is codons rather than amino acids, the model learns the *language of codon translation* — which synonymous codon is expected in a given context — and not only the encoded protein. The released family spans four checkpoints (80M, 600M, 1B parameters, plus a codon-frequency-aware-masking 1B variant), all reading sequences up to 2048 tokens, i.e. coding sequences up to `(2048 - 2) × 3 = 6138 nt` after the CLS/SEP tokens.

## Tools

<a name="api-run-codonfm-fitness" />

<div class="tool-section-card">
  ### CodonFM Fitness (`codonfm-fitness`)

  Runs the upstream Encodon fitness routine: one unmasked forward pass, followed by the mean log-probability assigned to each visible non-padding input token. The mean includes the CLS and SEP special tokens as well as the codons. Higher is more model-typical, but this score is not masked pseudo-log-likelihood.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/shared_data_models.py#L130" 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: CodonSequenceInput">
      <ParamField path="sequences" type="List[string]" required>
        Coding sequence(s) at codon resolution. A single string is normalized to a one-item list; `U` maps to `T` and each length must be a multiple of 3 (codon-aligned) and at most 6138 nt.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_fitness.py#L25" 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: CodonFMFitnessConfig">
      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device used for inference.
      </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="model_checkpoint" type="enum" default="encodon_80m">
        Encodon checkpoint to run.

        Available options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`
      </ParamField>

      <ParamField path="batch_size" type="integer" default="1">
        Sequences processed per GPU forward pass.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_fitness.py#L49" 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: CodonFMFitnessOutput">
      <ResponseField name="results" type="List[CodonFMFitnessResult]">
        Per-sequence fitness predictions.

        <Expandable title="CodonFMFitnessResult">
          <ResponseField name="sequence" type="string" required>
            Coding sequence that was scored (DNA alphabet).
          </ResponseField>

          <ResponseField name="sequence_length" type="integer" required>
            Length of the scored sequence in nucleotides.
          </ResponseField>

          <ResponseField name="fitness" type="number" required>
            Mean per-token log-likelihood under Encodon; higher is more model-typical (a proxy for a well-formed, natural coding sequence).
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  Sequence fitness is a zero-shot naturalness score for ranking or filtering coding sequences: comparing codon-optimized designs against wild type, screening synthetic constructs, or scoring candidate CDS variants without any task-specific training.

  #### Usage Tips

  * **Fitness is a relative score against Encodon's training distribution, not an absolute quantity.** It is most meaningful when comparing related sequences of similar length; the per-token mean already normalizes for length, but very short sequences are noisy.
  * **`batch_size` trades memory for throughput.** Lower it if you OOM on long CDS, raise it for short sequences.

  <a name="api-run-codonfm-score" />
</div>

<div class="tool-section-card tool-section-card--score">
  ### CodonFM Score (`codonfm-score`)

  Scores individual **codon substitutions** by the reference-vs-alternate log-likelihood ratio at the mutated position. The reference codon is masked and the model's log-probability of the reference and alternate codons is compared; a positive `llr` (`ref − alt`) means the model favors the reference and the substitution is model-disfavored.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_score.py#L74" 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: CodonFMScoreInput">
      <ParamField path="mutations" type="List[CodonFMMutation]" required>
        One or more codon substitutions, each against its own reference coding sequence.

        <Expandable title="CodonFMMutation">
          <ParamField path="sequence" type="string" required>
            The reference coding sequence (codon-aligned DNA/RNA).
          </ParamField>

          <ParamField path="codon_position" type="integer" required>
            1-based codon position of the substitution within `sequence`.
          </ParamField>

          <ParamField path="ref_codon" type="string" required>
            Reference codon at `codon_position` (must match `sequence`).
          </ParamField>

          <ParamField path="alt_codon" type="string" required>
            Alternate codon substituted at `codon_position`.
          </ParamField>
        </Expandable>
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_score.py#L21" 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: CodonFMScoreConfig">
      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device used for inference.
      </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="model_checkpoint" type="enum" default="encodon_80m">
        Encodon checkpoint to run.

        Available options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`
      </ParamField>

      <ParamField path="batch_size" type="integer" default="1">
        Mutations processed per GPU forward pass.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_score.py#L118" 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: CodonFMScoreOutput">
      <ResponseField name="results" type="List[CodonFMMutationResult]">
        Per-mutation log-likelihood-ratio scores.

        <Expandable title="CodonFMMutationResult">
          <ResponseField name="sequence" type="string" required>
            Reference coding sequence used as model context.
          </ResponseField>

          <ResponseField name="sequence_length" type="integer" required>
            Length of the reference sequence in nucleotides.
          </ResponseField>

          <ResponseField name="codon_position" type="integer" required>
            1-based codon position of the substitution.
          </ResponseField>

          <ResponseField name="ref_codon" type="string" required>
            Reference codon.
          </ResponseField>

          <ResponseField name="alt_codon" type="string" required>
            Alternate codon.
          </ResponseField>

          <ResponseField name="ref_log_likelihood" type="number" required>
            Model log-likelihood of the reference codon at the site.
          </ResponseField>

          <ResponseField name="alt_log_likelihood" type="number" required>
            Model log-likelihood of the alternate codon at the site.
          </ResponseField>

          <ResponseField name="llr" type="number" required>
            Log-likelihood ratio `ref - alt`; positive means the model favors the reference and the substitution is model-disfavored.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  The masked log-likelihood ratio is a canonical zero-shot variant-effect estimator. Because Encodon is codon-level, it discriminates *synonymous* substitutions (same amino acid, different codon) that an amino-acid model cannot see — useful for studying codon-usage effects on expression and mRNA stability.

  #### Usage Tips

  * **Each mutation carries its own reference sequence, codon position (1-based), and ref/alt codons.** The reference codon is validated against the sequence at that position, so an off-by-one frame error is caught before dispatch rather than silently mis-scored.
  * **Scores are position-conditional.** The same substitution scored in different sequence contexts will differ; that context-dependence is the point.

  <a name="api-run-codonfm-embeddings" />
</div>

<div class="tool-section-card tool-section-card--embedding">
  ### CodonFM Embeddings (`codonfm-embedding`)

  Returns the final-layer **CLS-token embedding** for each coding sequence — a fixed-length learned representation whose dimensionality follows the checkpoint.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/shared_data_models.py#L130" 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: CodonSequenceInput">
      <ParamField path="sequences" type="List[string]" required>
        Coding sequence(s) at codon resolution. A single string is normalized to a one-item list; `U` maps to `T` and each length must be a multiple of 3 (codon-aligned) and at most 6138 nt.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_embeddings.py#L22" 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: CodonFMEmbeddingsConfig">
      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device used for inference.
      </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="model_checkpoint" type="enum" default="encodon_80m">
        Encodon checkpoint to run.

        Available options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`
      </ParamField>

      <ParamField path="batch_size" type="integer" default="1">
        Sequences processed per GPU forward pass.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_embeddings.py#L46" 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: CodonFMEmbeddingsOutput">
      <ResponseField name="results" type="List[CodonFMEmbeddingResult]">
        Per-sequence CLS embeddings.

        <Expandable title="CodonFMEmbeddingResult">
          <ResponseField name="sequence" type="string" required>
            Coding sequence that was embedded (DNA alphabet).
          </ResponseField>

          <ResponseField name="sequence_length" type="integer" required>
            Length of the sequence in nucleotides.
          </ResponseField>

          <ResponseField name="embedding" type="List[number]" required>
            The final-layer CLS-token embedding vector (hidden size depends on the checkpoint: 1024 for 80M, 2048 for 600M/1B).
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  The CLS embedding is a codon-aware sequence descriptor for downstream supervised tasks (classification, regression, clustering) and similarity search over coding sequences.

  #### Usage Tips

  * **Different checkpoints produce different embedding sizes.** Representations from one checkpoint do not transfer to another without re-fitting downstream models; pick one and keep it fixed for an analysis.

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

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

  Computes the gradient of the mean masked negative log-likelihood with respect to a relaxed `(L, 64)` distribution over all 64 DNA codons, including the three standard stop codons (lexicographic order `AAA, AAC, AAG, AAT, …`). Each row's current argmax codon is the masked-language-model target. The Encodon weights are frozen; the relaxed distribution passes through Encodon's embedding layer and normalization, each codon position is masked in turn, and a per-chunk backward pass accumulates the gradient. An optional Straight-Through Estimator runs the forward on hard one-hot codons while routing gradients through the soft probabilities.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_gradient.py#L24" 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: CodonFMGradientInput">
      <ParamField path="logits" type="List[array]" required>
        Relaxed coding-sequence state with shape `(L, 64)` in lexicographic DNA codon order (`AAA, AAC, AAG, AAT, ...`; see :data:`CODONFM_CODON_VOCAB`). `L` must be ≤ 2046 (Encodon's positional cap minus the CLS/SEP tokens); over-length inputs raise `ValueError`. Each row's argmax codon is used as that position's masked-language-model target.
      </ParamField>

      <ParamField path="temperature" type="number" default="1.0">
        Optional softmax temperature. When set, applies `softmax(input / temperature)` before computing the gradient. When `None`, every input row must already be a probability distribution.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_gradient.py#L97" 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: CodonFMGradientConfig">
      <ParamField path="model_checkpoint" type="enum" default="encodon_80m">
        Encodon weights variant.

        Available options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`
      </ParamField>

      <ParamField path="use_ste" type="boolean" default="False">
        Straight-Through Estimator: hard one-hot codons in the forward pass with gradients flowing through soft probabilities. When `False`, uses soft blended codon embeddings directly.
      </ParamField>

      <ParamField path="compute_gradient" type="boolean" default="True">
        Run backward pass and return gradient. Set `False` for forward-only masked-log-likelihood scoring.
      </ParamField>

      <ParamField path="batch_size" type="integer" default="32">
        Codon positions per forward pass for batched masked-PLL.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device to run the model on.
      </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>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_gradient.py#L79" 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: CodonFMGradientOutput">
      <ResponseField name="gradient" type="array">
        Gradient w\.r.t. the input codon logits, or `None` when `compute_gradient=False`.
      </ResponseField>

      <ResponseField name="loss" type="number" required>
        Mean masked negative log-likelihood over codon positions.
      </ResponseField>

      <ResponseField name="metrics" type="Dict[string, any]">
        Log-likelihood, perplexity, sequence length, and objective details.
      </ResponseField>

      <ResponseField name="vocab" type="List[string]" required>
        Codon column ordering for the input logits and returned gradient.
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  This exposes Encodon as a differentiable, codon-level naturalness prior for continuous sequence design — usable inside gradient descent, MCMC, or any optimization loop over relaxed coding sequences (e.g. codon optimization with a learned constraint).

  #### Usage Tips

  * **`temperature` converts the raw input into a per-position distribution.** The default `1.0` applies `softmax(logits / T)`; set it to `None` only when every row is already a non-negative probability distribution summing to 1.
  * **`use_ste` enables the Straight-Through Estimator** for stronger guidance toward discrete codons while keeping a usable gradient.
  * **`compute_gradient=False` runs forward-only.** The `gradient` field is `None` but `loss` and `metrics` are still populated. This is a masked pseudo-log-likelihood objective; it is distinct from the visible-token objective returned by `codonfm-fitness`.

  <a name="api-run-codonfm-sample" />
</div>

<div class="tool-section-card tool-section-card--sample">
  ### CodonFM Sampling (`codonfm-sample`)

  Resamples a subset of codons in a coding sequence. A number of codon positions (`num_mutations`, or `mask_fraction` of the codons) are chosen at random, masked, and refilled from Encodon's distribution over the 61 sense codons in a single forward pass. The sequence length is preserved and sampling cannot introduce a new stop codon. It can replace an existing stop if that position is selected, so keep a required terminal stop outside the editable region or restore it afterward.

  #### API Reference

  <div class="api-model-section api-input-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/shared_data_models.py#L169" 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: MaskableCodonSequenceInput">
      <ParamField path="sequences" type="List[string]" required>
        Coding sequence(s) at codon resolution, optionally with whole codons masked as `___` to choose which positions are resampled.
      </ParamField>
    </Accordion>
  </div>

  <div class="api-model-section api-config-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_sample.py#L23" 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: CodonFMSampleConfig">
      <ParamField path="model_checkpoint" type="enum" default="encodon_80m">
        Encodon checkpoint to sample from.

        Available options: `encodon_80m`, `encodon_600m`, `encodon_1b`, `encodon_1b_cdwt`
      </ParamField>

      <ParamField path="masking_strategy" type="RandomMaskingStrategy">
        Which codons to resample, counted in codons rather than nucleotides. Ignored when the input already carries `___` masks, which name the positions outright. `fixed_positions` pins codons that must survive, which is how a start or stop codon is kept intact.

        <Expandable title="RandomMaskingStrategy">
          <ParamField path="method" type="string" default="random">
            Position-selection method. Always `"random"` for this tier (uniform selection, no model).
          </ParamField>

          <ParamField path="num_mutations" type="integer">
            Exact number of positions to mask per sequence.
          </ParamField>

          <ParamField path="mask_fraction" type="number">
            Fraction of designable positions to mask (e.g. 0.15 for \~15%).
          </ParamField>

          <ParamField path="fixed_positions" type="array">
            1-indexed positions that must NOT be masked. Applied uniformly to all sequences.
          </ParamField>
        </Expandable>
      </ParamField>

      <ParamField path="temperature" type="number" default="1.0">
        Softmax temperature for codon sampling; higher is more diverse.
      </ParamField>

      <ParamField path="batch_size" type="integer" default="1">
        Number of (same-length) sequences per GPU forward pass.
      </ParamField>

      <ParamField path="verbose" type="integer" default="0">
        Verbosity level (0=quiet, 1=info, 2=debug, 3=raw subprocess stderr). `True` is coerced to `1` and `False` to `0`.
      </ParamField>

      <ParamField path="device" type="string" default="cuda">
        Device used for CodonFM inference.
      </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>
    </Accordion>
  </div>

  <div class="api-model-section api-output-section">
    <a href="https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/codonfm_sample.py#L88" 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: CodonFMSampleOutput">
      <ResponseField name="results" type="List[CodonFMSampleResult]">
        One resampled coding sequence per input.

        <Expandable title="CodonFMSampleResult">
          <ResponseField name="sequence" type="string" required>
            Resampled coding sequence in the DNA alphabet.
          </ResponseField>
        </Expandable>
      </ResponseField>
    </Accordion>
  </div>

  #### Applications

  Masked-codon resampling is the local-edit primitive behind coding-sequence design: it proposes model-plausible synonymous or missense codon changes for directed-evolution / MCMC / genetic-algorithm loops (e.g. as the mutation generator in a Proto Language optimizer, paired with the `codonfm-fitness` constraint).

  #### Usage Tips

  * **`num_mutations` overrides `mask_fraction`.** It sets an exact number of positions to resample, not a guaranteed Hamming distance: the model can draw the original codon again.
  * **`temperature` controls diversity.** Below 1.0 sharpens toward the model's favorite codon; above 1.0 broadens exploration. Because sampling is stochastic, pass a `seed` for reproducible proposals.
</div>

## Toolkit Notes

These apply to every CodonFM tool in this toolkit (`codonfm-fitness`, `codonfm-score`, `codonfm-embedding`, `codonfm-gradient`, `codonfm-sample`).

* **Checkpoints download on demand.** The `nvidia/NV-CodonFM-Encodon-*-v1` repos are public; the standalone worker fetches the `.safetensors` weights and their `config.json` on first use and caches them. No HuggingFace token is required (one is used automatically if present).
* **A CUDA GPU is required.** The pinned upstream Encodon attention implementation uses xFormers kernels that do not provide a CPU execution path.
* **Inputs are codon-aligned nucleotide sequences.** Each length must be a multiple of 3; RNA `U` is mapped to `T`, while ambiguous bases such as `N` are rejected because upstream tokenization would shift codon positions. Inputs are not checked for a start codon, terminal stop, internal stops, or coding-strand orientation.
* **Max sequence length is 6138 nt (2046 codons).** Encodon's positional cap is 2048 tokens; longer inputs raise `ValueError` rather than truncating.
* **The default checkpoint is `encodon_80m`.** It is the fastest; the 600M/1B checkpoints trade throughput for fidelity. Pick a larger one for final scoring.

<Tip>
  **Example notebook:** See the [full working example](https://github.com/evo-design/proto-tools/blob/ede09259d665f23bd5fb57c68b020dfbc539a080/proto_tools/tools/masked_models/codonfm/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>
