-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaa0_model.py
More file actions
33 lines (24 loc) · 857 Bytes
/
aa0_model.py
File metadata and controls
33 lines (24 loc) · 857 Bytes
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
"""In this example we compute embedding and run masked inference
on the aa0 language model."""
from ginkgo_ai_client import (
GinkgoAIClient,
MaskedInferenceQuery,
MeanEmbeddingQuery,
)
client = GinkgoAIClient()
model = "ginkgo-aa0-650M"
# SIMPLE QUERY FOR EMBEDDING COMPUTATION
query = MeanEmbeddingQuery(sequence="MLYLRRL", model=model)
prediction = client.send_request(query)
# prediction.embedding == [1.05, -2.34, ...]
# SIMPLE QUERY FOR MASKED INFERENCE
query = MaskedInferenceQuery(sequence="MLY<mask>RRL", model=model)
prediction = client.send_request(query)
# prediction.sequence == "MLYRRL"
# BATCH REQUEST
queries = [
MeanEmbeddingQuery(sequence=sequence, model=model)
for sequence in ["MLYLRRL", "MLL", "MLYLLRRL"]
]
predictions = client.send_batch_request(queries)
# predictions[0].embedding == [1.05, -2.34, ...]