Skip to content

Commit

Permalink
docs: Update Gemini docs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 676646774
  • Loading branch information
sasha-gitg authored and copybara-github committed Sep 20, 2024
1 parent 55553ba commit 2b84142
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 45 deletions.
16 changes: 4 additions & 12 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ Vertex AI SDK for Python

|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests|

.. note::

For Gemini API and Generative AI on Vertex AI, please reference `Vertex Generative AI SDK for Python`_
.. _Vertex Generative AI SDK for Python: https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest

`Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle.

Expand Down Expand Up @@ -113,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin
from google.cloud import aiplatform
Vertex AI SDK preview functionality can be used by importing the following namespace:

.. code-block:: Python
from vertexai import preview
Vertex AI SDK general availability (GA) functionality can be used by importing the following namespace:

.. code-block:: Python
import vertexai
Initialization
^^^^^^^^^^^^^^
Initialize the SDK to store common configurations that you use with the SDK.
Expand Down
38 changes: 16 additions & 22 deletions docs/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
Vertex AI SDK for Python
=================================================

|GA| |pypi| |versions|
|GA| |pypi| |versions| |unit-tests| |system-tests| |sample-tests|

.. note::

For Gemini API and Generative AI on Vertex AI, please reference `Vertex Generative AI SDK for Python`_
.. _Vertex Generative AI SDK for Python: https://cloud.google.com/vertex-ai/generative-ai/docs/reference/python/latest

`Vertex AI`_: Google Vertex AI is an integrated suite of machine learning tools and services for building and using ML models with AutoML or custom code. It offers both novices and experts the best workbench for the entire machine learning development lifecycle.

Expand All @@ -14,11 +19,16 @@ Vertex AI SDK for Python
:target: https://pypi.org/project/google-cloud-aiplatform/
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-aiplatform.svg
:target: https://pypi.org/project/google-cloud-aiplatform/
.. |unit-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-unit-tests.svg
:target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-unit-tests.html
.. |system-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-system-tests.svg
:target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-system-tests.html
.. |sample-tests| image:: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-sample-tests.svg
:target: https://storage.googleapis.com/cloud-devrel-public/python-aiplatform/badges/sdk-sample-tests.html
.. _Vertex AI: https://cloud.google.com/vertex-ai/docs
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/aiplatform/latest/summary_overview
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/aiplatform/latest
.. _Product Documentation: https://cloud.google.com/vertex-ai/docs


Quick Start
-----------

Expand Down Expand Up @@ -59,7 +69,6 @@ Mac/Linux
<your-env>/bin/pip install google-cloud-aiplatform
Windows
^^^^^^^

Expand All @@ -70,6 +79,7 @@ Windows
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install google-cloud-aiplatform
Supported Python Versions
^^^^^^^^^^^^^^^^^^^^^^^^^
Python >= 3.8
Expand Down Expand Up @@ -107,18 +117,6 @@ Vertex AI SDK resource based functionality can be used by importing the followin
from google.cloud import aiplatform
Vertex AI SDK preview functionality can be used by importing the following namespace:

.. code-block:: Python
from vertexai import preview
Vertex AI SDK general availability (GA) functionality can be used by importing the following namespace:

.. code-block:: Python
import vertexai
Initialization
^^^^^^^^^^^^^^
Initialize the SDK to store common configurations that you use with the SDK.
Expand Down Expand Up @@ -175,8 +173,8 @@ You can also create and import a dataset in separate steps:
my_dataset = aiplatform.TextDataset.create(
display_name="my-dataset")
my_dataset.import(
gcs_source=['gs://path/to/my/dataset.csv']
my_dataset.import_data(
gcs_source=['gs://path/to/my/dataset.csv'],
import_schema_uri=aiplatform.schema.dataset.ioformat.text.multi_label_classification
)
Expand Down Expand Up @@ -232,7 +230,6 @@ It must write the model artifact to the environment variable populated by the tr
container_uri="us-docker.pkg.dev/vertex-ai/training/tf-cpu.2-2:latest",
requirements=["gcsfs==0.7.1"],
model_serving_container_image_uri="us-docker.pkg.dev/vertex-ai/prediction/tf2-cpu.2-2:latest",
)
model = job.run(my_dataset,
Expand Down Expand Up @@ -312,7 +309,6 @@ Please visit `Importing models to Vertex AI`_ for a detailed overview:

.. _Importing models to Vertex AI: https://cloud.google.com/vertex-ai/docs/general/import-model


Model Evaluation
----------------

Expand Down Expand Up @@ -417,7 +413,6 @@ To get predictions from endpoints:
endpoint.predict(instances=[[6.7, 3.1, 4.7, 1.5], [4.6, 3.1, 1.5, 0.2]])
To undeploy models from an endpoint:

.. code-block:: Python
Expand Down Expand Up @@ -540,7 +535,6 @@ To use Explanation Metadata in endpoint deployment and model upload:
aiplatform.Model.upload(..., explanation_metadata=explanation_metadata)
Cloud Profiler
----------------------------

Expand Down
27 changes: 16 additions & 11 deletions gemini_docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Vertex Generative AI SDK for Python
The Vertex Generative AI SDK helps developers use Google's generative AI
[Gemini models](http://cloud.google.com/vertex-ai/docs/generative-ai/multimodal/overview)
and [PaLM language models](http://cloud.google.com/vertex-ai/docs/generative-ai/language-model-overview)
to build AI-powered features and applications.
The SDKs support use cases like the following:

Expand All @@ -25,7 +24,13 @@ For detailed instructions, see [quickstart](http://cloud.google.com/vertex-ai/do

#### Imports:
```python
from vertexai.generative_models import GenerativeModel, Image, Content, Part, Tool, FunctionDeclaration, GenerationConfig
import vertexai
```

#### Initialization:

```python
vertexai.init(project='my-project', location='us-central1')
```

#### Basic generation:
Expand Down Expand Up @@ -54,7 +59,7 @@ print(vision_model.generate_content(["What is in the video? ", video_part]))
```

#### Chat
```
```python
from vertexai.generative_models import GenerativeModel, Image
vision_model = GenerativeModel("gemini-ultra-vision")
vision_chat = vision_model.start_chat()
Expand All @@ -64,7 +69,7 @@ print(vision_chat.send_message("What things do I like?."))
```

#### System instructions
```
```python
from vertexai.generative_models import GenerativeModel
model = GenerativeModel(
"gemini-1.0-pro",
Expand All @@ -78,7 +83,7 @@ print(model.generate_content("Why is sky blue?"))

#### Function calling

```
```python
# First, create tools that the model is can use to answer your questions.
# Describe a function by specifying it's schema (JsonSchema format)
get_current_weather_func = generative_models.FunctionDeclaration(
Expand Down Expand Up @@ -132,7 +137,7 @@ print(chat.send_message(

#### Automatic Function calling

```
```python
from vertexai.preview.generative_models import GenerativeModel, Tool, FunctionDeclaration, AutomaticFunctionCallingResponder

# First, create functions that the model can use to answer your questions.
Expand Down Expand Up @@ -179,7 +184,7 @@ print(chat.send_message("What is the weather like in Boston?"))

- To perform bring-your-own-response(BYOR) evaluation, provide the model responses in the `response` column in the dataset. If a pairwise metric is used for BYOR evaluation, provide the baseline model responses in the `baseline_model_response` column.

```
```python
import pandas as pd
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples

Expand All @@ -203,7 +208,7 @@ eval_result = eval_task.evaluate(experiment_run_name="eval-experiment-run")
```
- To perform evaluation with Gemini model inference, specify the `model` parameter with a `GenerativeModel` instance. The input column name to the model is `prompt` and must be present in the dataset.

```
```python
from vertexai.evaluation import EvalTask
from vertexai.generative_models import GenerativeModel

Expand All @@ -223,7 +228,7 @@ result = EvalTask(

- If a `prompt_template` is specified, the `prompt` column is not required. Prompts can be assembled from the evaluation dataset, and all prompt template variable names must be present in the dataset columns.

```
```python
import pandas as pd
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples
from vertexai.generative_models import GenerativeModel
Expand All @@ -245,7 +250,7 @@ result = EvalTask(
parameter with a custom inference function. The input column name to the
custom inference function is `prompt` and must be present in the dataset.

```
```python
from openai import OpenAI
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples

Expand Down Expand Up @@ -279,7 +284,7 @@ the `baseline_model` input to a `PairwiseMetric` instance and the candidate
`model` input to the `EvalTask.evaluate()` function. The input column name
to both models is `prompt` and must be present in the dataset.

```
```python
import pandas as pd
from vertexai.evaluation import EvalTask, MetricPromptTemplateExamples, PairwiseMetric
from vertexai.generative_models import GenerativeModel
Expand Down

0 comments on commit 2b84142

Please sign in to comment.