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    esm_mean_embedding_params,
 7    esm_masked_inference_params,
 8)
 9
10client = GinkgoAIClient()
11
12# Simple query for embedding computation
13prediction = client.query(esm_mean_embedding_params("MLYLRRL"))
14# prediction["embedding"] == [1.05, -2.34, ...]
15
16
17# Simple query for masked inference
18prediction = client.query(esm_masked_inference_params("MLY<mask>RRL"))
19
20queries = [
21    esm_mean_embedding_params("MLYLRRL"),
22    esm_mean_embedding_params("MLYRRL"),
23    esm_mean_embedding_params("MLYLLRRL"),
24]
25predictions = client.batch_query(queries)
26
27# predictions[0]["result"]["embedding"] == [1.05, -2.34, ...]

AA0 model

 1"""In this example we compute embedding and run masked inference
 2 on the aa02 language model."""
 3
 4from ginkgo_ai_client import (
 5    GinkgoAIClient,
 6    aa0_mean_embedding_params,
 7    aa0_masked_inference_params,
 8)
 9
10client = GinkgoAIClient()
11
12# Simple query for embedding computation
13prediction = client.query(aa0_mean_embedding_params("MLYLRRL"))
14# prediction["embedding"] == [1.05, -2.34, ...]
15
16
17# Simple query for masked inference
18prediction = client.query(aa0_masked_inference_params("MLY<mask>RRL"))
19
20queries = [
21    aa0_mean_embedding_params("MLYLRRL"),
22    aa0_mean_embedding_params("MLYRRL"),
23    aa0_mean_embedding_params("MLYLLRRL"),
24]
25predictions = client.batch_query(queries)
26
27# predictions[0]["result"]["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    three_utr_mean_embedding_params,
 7    three_utr_masked_inference_params,
 8)
 9
10client = GinkgoAIClient()
11
12# Simple query for embedding computation
13prediction = client.query(three_utr_mean_embedding_params("ATTGCG"))
14# prediction["embedding"] == [1.05, -2.34, ...]
15
16
17# Simple query for masked inference
18prediction = client.query(three_utr_masked_inference_params("ATT<mask>TAC"))
19
20queries = [
21    three_utr_mean_embedding_params("AGCGC"),
22    three_utr_mean_embedding_params("ATTGCG"),
23    three_utr_mean_embedding_params("TACCGCA"),
24]
25predictions = client.batch_query(queries)
26
27# predictions[0]["result"]["embedding"] == [1.05, -2.34, ...]