Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,11 @@ async def sample_generate_answer():
``SafetyCategory`` specified in the safety_settings. If
there is no ``SafetySetting`` for a given
``SafetyCategory`` provided in the list, the API will
use the default safety setting for that category.
use the default safety setting for that category. Harm
categories HARM_CATEGORY_HATE_SPEECH,
HARM_CATEGORY_SEXUALLY_EXPLICIT,
HARM_CATEGORY_DANGEROUS_CONTENT,
HARM_CATEGORY_HARASSMENT are supported.

This corresponds to the ``safety_settings`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,11 @@ def sample_generate_answer():
``SafetyCategory`` specified in the safety_settings. If
there is no ``SafetySetting`` for a given
``SafetyCategory`` provided in the list, the API will
use the default safety setting for that category.
use the default safety setting for that category. Harm
categories HARM_CATEGORY_HATE_SPEECH,
HARM_CATEGORY_SEXUALLY_EXPLICIT,
HARM_CATEGORY_DANGEROUS_CONTENT,
HARM_CATEGORY_HARASSMENT are supported.

This corresponds to the ``safety_settings`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,6 +798,11 @@ def __call__(
"uri": "/v1beta/{model=models/*}:generateContent",
"body": "*",
},
{
"method": "post",
"uri": "/v1beta/{model=tunedModels/*}:generateContent",
"body": "*",
},
]
request, metadata = self._interceptor.pre_generate_content(
request, metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,19 @@ class GenerationConfig(proto.Message):
Optional. The maximum number of tokens to include in a
candidate.

If unset, this will default to output_token_limit specified
in the ``Model`` specification.
Note: The default value varies by model, see the
``Model.output_token_limit`` attribute of the ``Model``
returned from the ``getModel`` function.

This field is a member of `oneof`_ ``_max_output_tokens``.
temperature (float):
Optional. Controls the randomness of the output. Note: The
default value varies by model, see the ``Model.temperature``
attribute of the ``Model`` returned the ``getModel``
function.
Optional. Controls the randomness of the output.

Values can range from [0.0,1.0], inclusive. A value closer
to 1.0 will produce responses that are more varied and
creative, while a value closer to 0.0 will typically result
in more straightforward responses from the model.
Note: The default value varies by model, see the
``Model.temperature`` attribute of the ``Model`` returned
from the ``getModel`` function.

Values can range from [0.0, infinity).

This field is a member of `oneof`_ ``_temperature``.
top_p (float):
Expand All @@ -210,7 +209,7 @@ class GenerationConfig(proto.Message):
based on the cumulative probability.

Note: The default value varies by model, see the
``Model.top_p`` attribute of the ``Model`` returned the
``Model.top_p`` attribute of the ``Model`` returned from the
``getModel`` function.

This field is a member of `oneof`_ ``_top_p``.
Expand All @@ -221,10 +220,10 @@ class GenerationConfig(proto.Message):
The model uses combined Top-k and nucleus sampling.

Top-k sampling considers the set of ``top_k`` most probable
tokens. Defaults to 40.
tokens.

Note: The default value varies by model, see the
``Model.top_k`` attribute of the ``Model`` returned the
``Model.top_k`` attribute of the ``Model`` returned from the
``getModel`` function.

This field is a member of `oneof`_ ``_top_k``.
Expand Down Expand Up @@ -655,7 +654,11 @@ class GenerateAnswerRequest(proto.Message):
the default settings for each ``SafetyCategory`` specified
in the safety_settings. If there is no ``SafetySetting`` for
a given ``SafetyCategory`` provided in the list, the API
will use the default safety setting for that category.
will use the default safety setting for that category. Harm
categories HARM_CATEGORY_HATE_SPEECH,
HARM_CATEGORY_SEXUALLY_EXPLICIT,
HARM_CATEGORY_DANGEROUS_CONTENT, HARM_CATEGORY_HARASSMENT
are supported.
temperature (float):
Optional. Controls the randomness of the output.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Document(proto.Message):
Attributes:
name (str):
Immutable. Identifier. The ``Document`` resource name. The
ID (name excluding the "corpora/*/documents/" prefix) can
ID (name excluding the `corpora/*/documents/` prefix) can
contain up to 40 characters that are lowercase alphanumeric
or dashes (-). The ID cannot start or end with a dash. If
the name is empty on create, a unique name will be derived
Expand Down Expand Up @@ -315,7 +315,7 @@ class Chunk(proto.Message):
Attributes:
name (str):
Immutable. Identifier. The ``Chunk`` resource name. The ID
(name excluding the "corpora/*/documents/*/chunks/" prefix)
(name excluding the `corpora/*/documents/*/chunks/` prefix)
can contain up to 40 characters that are lowercase
alphanumeric or dashes (-). The ID cannot start or end with
a dash. If the name is empty on create, a random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ class HarmCategory(proto.Enum):
Negative or harmful comments targeting
identity and/or protected attribute.
HARM_CATEGORY_TOXICITY (2):
Content that is rude, disrepspectful, or
Content that is rude, disrespectful, or
profane.
HARM_CATEGORY_VIOLENCE (3):
Describes scenarios depictng violence against
an individual or group, or general descriptions
of gore.
Describes scenarios depicting violence
against an individual or group, or general
descriptions of gore.
HARM_CATEGORY_SEXUAL (4):
Contains references to sexual acts or other
lewd content.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,33 +268,57 @@ class TuningTask(proto.Message):


class Hyperparameters(proto.Message):
r"""Hyperparameters controlling the tuning process.
r"""Hyperparameters controlling the tuning process. Read more at
https://ai.google.dev/docs/model_tuning_guidance

This message has `oneof`_ fields (mutually exclusive fields).
For each oneof, at most one member field can be set at the same time.
Setting any member of the oneof automatically clears all other
members.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
learning_rate (float):
Optional. Immutable. The learning rate
hyperparameter for tuning. If not set, a default
of 0.001 or 0.0002 will be calculated based on
the number of training examples.

This field is a member of `oneof`_ ``learning_rate_option``.
learning_rate_multiplier (float):
Optional. Immutable. The learning rate multiplier is used to
calculate a final learning_rate based on the default
(recommended) value. Actual learning rate :=
learning_rate_multiplier \* default learning rate Default
learning rate is dependent on base model and dataset size.
If not set, a default of 1.0 will be used.

This field is a member of `oneof`_ ``learning_rate_option``.
epoch_count (int):
Immutable. The number of training epochs. An
epoch is one pass through the training data. If
not set, a default of 10 will be used.
not set, a default of 5 will be used.

This field is a member of `oneof`_ ``_epoch_count``.
batch_size (int):
Immutable. The batch size hyperparameter for
tuning. If not set, a default of 16 or 64 will
be used based on the number of training
examples.
tuning. If not set, a default of 4 or 16 will be
used based on the number of training examples.

This field is a member of `oneof`_ ``_batch_size``.
learning_rate (float):
Immutable. The learning rate hyperparameter
for tuning. If not set, a default of 0.0002 or
0.002 will be calculated based on the number of
training examples.

This field is a member of `oneof`_ ``_learning_rate``.
"""

learning_rate: float = proto.Field(
proto.FLOAT,
number=16,
oneof="learning_rate_option",
)
learning_rate_multiplier: float = proto.Field(
proto.FLOAT,
number=17,
oneof="learning_rate_option",
)
epoch_count: int = proto.Field(
proto.INT32,
number=14,
Expand All @@ -305,11 +329,6 @@ class Hyperparameters(proto.Message):
number=15,
optional=True,
)
learning_rate: float = proto.Field(
proto.FLOAT,
number=16,
optional=True,
)


class Dataset(proto.Message):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,11 @@ async def sample_create_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -473,11 +473,11 @@ async def sample_get_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -729,11 +729,11 @@ async def sample_update_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,11 +764,11 @@ def sample_create_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -894,11 +894,11 @@ def sample_get_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -1150,11 +1150,11 @@ def sample_update_permission():
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,11 @@ def __call__(
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -588,11 +588,11 @@ def __call__(
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down Expand Up @@ -882,11 +882,11 @@ def __call__(
role is a superset of the previous
role's permitted operations:

- reader can use the resource (e.g.
- reader can use the resource (e.g.
tuned model) for inference
- writer has reader's permissions and
- writer has reader's permissions and
additionally can edit and share
- owner has writer's permissions and
- owner has writer's permissions and
additionally can delete

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class Permission(proto.Message):
There are three concentric roles. Each role is a superset of the
previous role's permitted operations:

- reader can use the resource (e.g. tuned model) for inference
- writer has reader's permissions and additionally can edit and
- reader can use the resource (e.g. tuned model) for inference
- writer has reader's permissions and additionally can edit and
share
- owner has writer's permissions and additionally can delete
- owner has writer's permissions and additionally can delete


.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4221,9 +4221,10 @@ def test_create_tuned_model_rest(request_type):
}
},
"hyperparameters": {
"learning_rate": 0.1371,
"learning_rate_multiplier": 0.2561,
"epoch_count": 1175,
"batch_size": 1052,
"learning_rate": 0.1371,
},
},
}
Expand Down Expand Up @@ -4588,9 +4589,10 @@ def test_update_tuned_model_rest(request_type):
}
},
"hyperparameters": {
"learning_rate": 0.1371,
"learning_rate_multiplier": 0.2561,
"epoch_count": 1175,
"batch_size": 1052,
"learning_rate": 0.1371,
},
},
}
Expand Down