Examples

ESM model

 1"""In this example we compute embedding and run masked inference
 2 on the ESM2 language model."""
 3
 4from ginkgo_ai_client import (
 5    GinkgoAIClient,
 6    MaskedInferenceQuery,
 7    MeanEmbeddingQuery,
 8)
 9
10client = GinkgoAIClient()
11model = "esm2-650M"
12
13# SIMPLE QUERY FOR EMBEDDING COMPUTATION
14
15query = MeanEmbeddingQuery(sequence="MLYLRRL", model=model)
16prediction = client.send_request(query)
17# prediction.embedding == [1.05, -2.34, ...]
18
19
20# SIMPLE QUERY FOR MASKED INFERENCE
21
22query = MaskedInferenceQuery(sequence="MLY<mask>RRL", model=model)
23prediction = client.send_request(query)
24# prediction.sequence == "MLYRRL"
25
26# BATCH REQUEST
27
28queries = [
29    MeanEmbeddingQuery(sequence=sequence, model=model)
30    for sequence in ["MLYLRRL", "MLL", "MLYLLRRL"]
31]
32predictions = client.send_batch_request(queries)
33# predictions[0].embedding == [1.05, -2.34, ...]

AA0 model

 1"""In this example we compute embedding and run masked inference
 2 on the aa0 language model."""
 3
 4from ginkgo_ai_client import (
 5    GinkgoAIClient,
 6    MaskedInferenceQuery,
 7    MeanEmbeddingQuery,
 8)
 9
10client = GinkgoAIClient()
11model = "ginkgo-aa0-650M"
12
13# SIMPLE QUERY FOR EMBEDDING COMPUTATION
14
15query = MeanEmbeddingQuery(sequence="MLYLRRL", model=model)
16prediction = client.send_request(query)
17# prediction.embedding == [1.05, -2.34, ...]
18
19
20# SIMPLE QUERY FOR MASKED INFERENCE
21
22query = MaskedInferenceQuery(sequence="MLY<mask>RRL", model=model)
23prediction = client.send_request(query)
24# prediction.sequence == "MLYRRL"
25
26# BATCH REQUEST
27
28queries = [
29    MeanEmbeddingQuery(sequence=sequence, model=model)
30    for sequence in ["MLYLRRL", "MLL", "MLYLLRRL"]
31]
32predictions = client.send_batch_request(queries)
33# predictions[0].embedding == [1.05, -2.34, ...]

3’UTR model

 1"""In this example we compute embedding and run masked inference
 2 on Ginkgo's 3'UTR language model."""
 3
 4from ginkgo_ai_client import (
 5    GinkgoAIClient,
 6    MaskedInferenceQuery,
 7    MeanEmbeddingQuery,
 8)
 9
10client = GinkgoAIClient()
11model = "ginkgo-maskedlm-3utr-v1"
12
13# SIMPLE QUERY FOR EMBEDDING COMPUTATION
14
15query = MeanEmbeddingQuery(sequence="ATTGCG", model=model)
16prediction = client.send_request(query)
17# prediction.embedding == [1.05, -2.34, ...]
18
19
20# SIMPLE QUERY FOR MASKED INFERENCE
21
22query = MaskedInferenceQuery(sequence="ATT<mask>TAC", model=model)
23prediction = client.send_request(query)
24
25# BATCH REQUEST
26
27queries = [
28    MeanEmbeddingQuery(sequence=sequence, model=model)
29    for sequence in ["AGCGC", "ATTGCG", "TACCGCA"]
30]
31predictions = client.send_batch_request(queries)
32# predictions[0].embedding == [1.05, -2.34, ...]