Notebooks
G
Google Gemini
[TxGemma]Quickstart With Model Garden

[TxGemma]Quickstart With Model Garden

recurrentgemmagemmapaligemmagemma-cookbookTxGemmacodegemma
[ ]

Quick start with Model Garden - TxGemma

Overview

This notebook demonstrates how to use TxGemma in Vertex AI to generate predictions from therapeutic related text prompts using two methods for getting predictions:

  • Online predictions are synchronous requests that are made to the endpoint deployed from Model Garden and are served with low latency. Online predictions are useful if the responses are being used in production. The cost for online prediction is based on the time a virtual machine spends waiting in an active state (an endpoint with a deployed model) to handle prediction requests.

  • Batch predictions are asynchronous requests that are run on a set number of prompts specified in a single job. They are made directly to an uploaded model and do not use an endpoint deployed from Model Garden. Batch predictions are useful if you want to generate responses for a large number of prompts for use in training and don't require low latency. The cost for batch prediction is based on the time a virtual machine spends running your prediction job.

Vertex AI makes it easy to serve your model and make it accessible to the world. Learn more about Vertex AI.

Objectives

  • Deploy TxGemma to a Vertex AI Endpoint and get online predictions.
  • Upload TxGemma to Vertex AI Model Registry and get batch predictions.

Costs

This tutorial uses billable components of Google Cloud:

  • Vertex AI
  • Cloud Storage

Learn about Vertex AI pricing, Cloud Storage pricing, and use the Pricing Calculator to generate a cost estimate based on your projected usage.

Before you begin

[ ]
[ ]

Format prompts for therapeutic tasks

The following sections in this notebook demonstrate prompting TxGemma for therapeutic development tasks from Therapeutics Data Commons (TDC).

For these predictive tasks, prompts should be formatted according to the TDC structure, including:

  • Instruction: Briefly describes the task.

  • Context: Provides 2-3 sentences of relevant biochemical background, derived from TDC descriptions and literature.

  • Question: Queries a specific therapeutic property, incorporating textual representations of therapeutics and/or targets as inputs.

    • Inputs can include SMILES strings, amino acid sequences, nucleotide sequences, and natural language text.

    • Optional few-shot examples can be provided.

[ ]
[ ]

Get online predictions

[ ]
ENDPOINT_ID
ENDPOINT_REGION

Explore predictive capabilities

TxGemma models are designed to process and understand information related to various therapeutic modalities and targets, including small molecules, proteins, nucleic acids, diseases, and cell lines, and can generate predictions on a broad set of therapeutic development tasks.

You can send online prediction requests to the endpoint with formatted text prompts.

[ ]

Explore conversational capabilities with TxGemma-Chat

TxGemma features conversational models that add reasoning and explainability to predictions and can be used in multi-turn interactions. Their conversational ability comes at the expense of some predictive power.

You can send online prediction requests to the endpoint using the OpenAI SDK.

For this section, make sure that you are using a TxGemma-Chat model variant.

[ ]

Get batch predictions

[ ]
HF_TOKEN
[ ]
MODEL_VARIANT
[ ]
BUCKET_URI

Predict

You can send batch prediction requests to the model using a JSON Lines file to specify a list of input instances with text prompts to generate predictions. For more details on configuring batch prediction jobs, see how to format your input data and choose compute settings.

[ ]
[ ]

Next steps

Explore the other notebooks to learn what else you can do with the model.

Clean up resources

[ ]
delete_bucket
False