Class TextGenerationModel (1.27.0)

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

TextGenerationModel represents a general language model.

Examples::

# Getting answers:
model = TextGenerationModel.from_pretrained("text-bison@001")
model.predict("What is life?")

Methods

TextGenerationModel

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.

from_pretrained

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

Loads a _ModelGardenModel.

Exceptions
TypeDescription
ValueErrorIf model_name is unknown.
ValueErrorIf 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.