Class TextGenerationModel (1.28.1)

TextGenerationModel(model_id: str, endpoint_name: typing.Optional[str] = None)

Creates a LanguageModel.

This constructor should not be called directly. Use LanguageModel.from_pretrained(model_name=...) instead.

Methods

batch_predict

batch_predict(
    *,
    dataset: typing.Union[str, typing.List[str]],
    destination_uri_prefix: str,
    model_parameters: typing.Optional[typing.Dict] = None
) -> google.cloud.aiplatform.jobs.BatchPredictionJob

Starts a batch prediction job with the model.

Exceptions
Type Description
ValueError When source or destination URI is not supported.

from_pretrained

from_pretrained(model_name: str) -> vertexai._model_garden._model_garden_models.T

Loads a _ModelGardenModel.

Exceptions
Type Description
ValueError If model_name is unknown.
ValueError If model does not support this class.

predict

predict(
    prompt: str,
    *,
    max_output_tokens: int = 128,
    temperature: float = 0.0,
    top_k: int = 40,
    top_p: float = 0.95
) -> vertexai.language_models._language_models.TextGenerationResponse

Gets model response for a single prompt.