Skip to content

Commit

Permalink
fix: LLM - Fixed get_tuned_model for the future models that are not…
Browse files Browse the repository at this point in the history
… `text-bison`

Also fixed the `_endpoint_name` attribute of tuned models although it's not used.

PiperOrigin-RevId: 551363402
  • Loading branch information
Ark-kun authored and copybara-github committed Jul 27, 2023
1 parent 3bfd996 commit 1adf72b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions vertexai/language_models/_language_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,17 @@ def _get_model_id_from_tuning_model_id(tuning_model_id: str) -> str:
"""Gets the base model ID for the model ID labels used the tuned models.
Args:
tuning_model_id: The model ID used in tuning
tuning_model_id: The model ID used in tuning. E.g. `text-bison-001`
Returns:
The publisher model ID
Raises:
ValueError: If tuning model ID is unsupported
"""
if tuning_model_id.startswith("text-bison-"):
return tuning_model_id.replace(
"text-bison-", "publishers/google/models/text-bison@"
)
if "/" not in tuning_model_id:
return "publishers/google/models/" + tuning_model_id
return tuning_model_id
model_name, _, version = tuning_model_id.rpartition("-")
# "publishers/google/models/text-bison@001"
return f"publishers/google/models/{model_name}@{version}"


class _LanguageModel(_model_garden_models._ModelGardenModel):
Expand Down Expand Up @@ -203,6 +199,7 @@ def tune_model(
tuned_model = job.result()
# The UXR study attendees preferred to tune model in place
self._endpoint = tuned_model._endpoint
self._endpoint_name = tuned_model._endpoint_name


@dataclasses.dataclass
Expand Down

0 comments on commit 1adf72b

Please sign in to comment.