forked from evolutionaryscale/esm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesmc_examples.py
34 lines (29 loc) · 1.12 KB
/
esmc_examples.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from esm.models.esmc import ESMC
from examples.local_generate import get_sample_protein
from esm.sdk.api import (
ESMCInferenceClient,
LogitsConfig,
LogitsOutput,
)
def main(client: ESMCInferenceClient):
# ================================================================
# Example usage: one single protein
# ================================================================
protein = get_sample_protein()
protein.coordinates = None
protein.function_annotations = None
protein.sasa = None
# Use logits endpoint. Using bf16 for inference optimization
protein_tensor = client.encode(protein)
logits_output = client.logits(
protein_tensor, LogitsConfig(sequence=True, return_embeddings=True)
)
assert isinstance(
logits_output, LogitsOutput
), f"LogitsOutput was expected but got {logits_output}"
assert (
logits_output.logits is not None and logits_output.logits.sequence is not None
)
assert logits_output.embeddings is not None and logits_output.embeddings is not None
if __name__ == "__main__":
main(ESMC.from_pretrained("esmc_300m"))