Skip to content

Commit

Permalink
RemoteTgisTextGen: Raise if trying to run remote-only model with loca…
Browse files Browse the repository at this point in the history
…l TGIS

Signed-off-by: Gabe Goodhart <[email protected]>
  • Loading branch information
gabe-l-hart committed Jul 28, 2023
1 parent 3416de2 commit 0f54593
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions caikit_nlp/modules/text_generation/text_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


# Standard
from typing import Iterable
from typing import Iterable, Optional
import os

# Third Party
Expand Down Expand Up @@ -62,12 +62,12 @@ class TextGeneration(ModuleBase):
def __init__(
self,
base_model_name: str,
base_model: PretrainedModelBase = None,
bos_token: str = None,
sep_token: str = None,
eos_token: str = None,
pad_token: str = None,
tgis_backend: TGISBackend = None,
base_model: Optional[PretrainedModelBase] = None,
bos_token: Optional[str] = None,
sep_token: Optional[str] = None,
eos_token: Optional[str] = None,
pad_token: Optional[str] = None,
tgis_backend: Optional[TGISBackend] = None,
):
super().__init__()

Expand All @@ -89,6 +89,14 @@ def __init__(
self._client = tgis_backend.get_client(base_model_name)
# mark that the model is loaded so that we can unload it later
self._model_loaded = True
# Make sure that we either have a base model or TGIS is running as a
# remote-proxy
error.value_check(
"<NLP51672289E>",
self.base_model or not tgis_backend.local_tgis,
"Cannot run model {} with TGIS locally since it has no base artifacts",
base_model_name,
)

self._bos_token = bos_token
self._sep_token = sep_token
Expand Down Expand Up @@ -122,7 +130,6 @@ def bootstrap(cls, base_model_path: str, load_backend: BackendBase = None):
"""
# pylint: disable=duplicate-code
model_config = AutoConfig.from_pretrained(base_model_path)

resource_type = None
for resource in cls.supported_resources:
if model_config.model_type in resource.SUPPORTED_MODEL_TYPES:
Expand Down

0 comments on commit 0f54593

Please sign in to comment.