Skip to content

Commit

Permalink
finalizing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Valentin Zulkower committed Nov 1, 2024
1 parent 779ebfc commit 8469544
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 19 deletions.
23 changes: 23 additions & 0 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Examples
========

ESM model
~~~~~~~~~

.. literalinclude:: ../../examples/esm_model.py
:language: python
:linenos:

AA0 model
~~~~~~~~~

.. literalinclude:: ../../examples/aa0_model.py
:language: python
:linenos:

3'UTR model
~~~~~~~~~~~

.. literalinclude:: ../../examples/3utr_model.py
:language: python
:linenos:
8 changes: 5 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Query Parameters
.. automodule:: ginkgo_ai_client.query_parameters
:members:

.. .. toctree::
.. :maxdepth: 2
.. :caption: Contents:
.. toctree::
:maxdepth: 2
:caption: Contents:

examples
3 changes: 2 additions & 1 deletion examples/3utr_model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This runs embedding and masked inference queries on Ginkgo's 3'UTR language model."""
"""In this example we compute embedding and run masked inference
on Ginkgo's 3'UTR language model."""

from ginkgo_ai_client import (
GinkgoAIClient,
Expand Down
17 changes: 10 additions & 7 deletions examples/aa0_model.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
"""In this example we compute embedding and run masked inference
on Ginkgo's AA0 protein language model."""

from ginkgo_ai_client import (
GinkgoAIClient,
three_utr_mean_embedding_params,
three_utr_masked_inference_params,
aa0_mean_embedding_params,
aa0_masked_inference_params,
)

client = GinkgoAIClient()

# Simple query for embedding computation
prediction = client.query(three_utr_mean_embedding_params("ATTGCG"))
prediction = client.query(aa0_mean_embedding_params("ATTGCG"))
# prediction["embedding"] == [1.05, -2.34, ...]


# Simple query for masked inference
prediction = client.query(three_utr_masked_inference_params("ATT<mask>TAC"))
prediction = client.query(aa0_masked_inference_params("ATT<mask>TAC"))

queries = [
three_utr_mean_embedding_params("AGCGC"),
three_utr_mean_embedding_params("ATTGCG"),
three_utr_mean_embedding_params("TACCGCA"),
aa0_mean_embedding_params("AGCGC"),
aa0_mean_embedding_params("ATTGCG"),
aa0_mean_embedding_params("TACCGCA"),
]
predictions = client.batch_query(queries)

Expand Down
17 changes: 9 additions & 8 deletions examples/esm_model.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
"""This runs embedding and masked inference queries on Ginkgo's 3'UTR language model."""
"""In this example we compute embedding and run masked inference
on the ESM2 language model."""

from ginkgo_ai_client import (
GinkgoAIClient,
aa0_mean_embedding_params,
aa0_masked_inference_params,
esm_mean_embedding_params,
esm_masked_inference_params,
)

client = GinkgoAIClient()

# Simple query for embedding computation
prediction = client.query(aa0_mean_embedding_params("MLYLRRL"))
prediction = client.query(esm_mean_embedding_params("MLYLRRL"))
# prediction["embedding"] == [1.05, -2.34, ...]


# Simple query for masked inference
prediction = client.query(aa0_masked_inference_params("MLY<mask>RRL"))
prediction = client.query(esm_masked_inference_params("MLY<mask>RRL"))

queries = [
aa0_mean_embedding_params("MLYLRRL"),
aa0_mean_embedding_params("MLYRRL"),
aa0_mean_embedding_params("MLYLLRRL"),
esm_mean_embedding_params("MLYLRRL"),
esm_mean_embedding_params("MLYRRL"),
esm_mean_embedding_params("MLYLLRRL"),
]
predictions = client.batch_query(queries)

Expand Down

0 comments on commit 8469544

Please sign in to comment.