Skip to main content

ESM2quinox

An implementation of ESM2 in Equinox+JAX

Installation

pip install esm2quinox

Public API

See their docstrings for details:

esm2quinox
    .ESM2
        .__init__(self, num_layers: int, embed_size: int, num_heads: int, token_dropout: bool, key: PRNGKeyArray)
        .__call__(self, tokens: Int[np.ndarray | jax.Array, " length"]) -> esm2quinox.ESM2Result

    .ESM2Result
        .hidden: Float[Array, "length embed_size"]
        .logits: Float[Array, "length alphabet_size"]

    .tokenise(proteins: list[str], length: None | int = None, key: None | PRNGKeyArray = None)

    .from_torch(torch_esm2: esm.ESM2) -> esm2quinox.ESM2

Quick examples

Load an equivalent pretrained model from PyTorch:

import esm  # pip install fair-esm==2.0.0
import esm2quinox

torch_model, _ = esm.pretrained.esm2_t6_8M_UR50D()
model = esm2quinox.from_torch(torch_model)

Create a randomly-initialised model:

import esm2quinox
import jax.random as jr

key = jr.key(1337)
model = esm2quinox.ESM2(num_layers=3, embed_size=32, num_heads=2, token_dropout=False, key=key)

Forward pass (note the model operates on unbatched data):

proteins = esm2quinox.tokenise(["SPIDERMAN", "FOO"])
out = jax.vmap(model)(proteins)
out.hidden  # hidden representation from last layer
out.logits  # logits for masked positions

Metadata

Release files for esm2quinox 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for esm2quinox 0.2.0
File Size Uploaded
esm2quinox-0.2.0.tar.gz 12.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for esm2quinox 0.2.0
File Interpreter ABI Platform
esm2quinox-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.5 kB

Release files / esm2quinox-0.2.0.tar.gz

Download URL esm2quinox-0.2.0.tar.gz
Size 12.4 kB
Tags Source
SHA-256 checksum
How to use checksums
12c11632f0b3efd3e3a4f94b031efb3f50f010f8fcbddd9a95b38da716bbb983
BLAKE2b-256 checksum
How to use checksums
e487d48d18a1faa94ee4560f14cfc559413fcfc610854c29af897bcf9fb91cf9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release files / esm2quinox-0.2.0-py3-none-any.whl

Download URL esm2quinox-0.2.0-py3-none-any.whl
Size 17.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac89d44ba1e141a60de1a76e10b345fab70d629d7c438031a76f53bd405fc244
BLAKE2b-256 checksum
How to use checksums
bc34b72aeafa3521e42e300117c1d1cb749a6db534ae88d9c5b28c1dd054001a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.12

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page