chanp
chanp

Reputation: 675

Fail to initialize model using GemmaVertexAIModelGarden

I try initializing an llm, following an official tutorial in Colab: Get started with Gemma and LangChain. The tutorial instruct that I deploy a model from Model Garden and, when the endpoint is ready, copy its project ID, endpoint ID, and location, and enter them in Colab Cell like this:

enter image description here

I follow the instruction and collect three strings from the following places (as highlighted in yellow):

enter image description here

So, at this point the Colab cell that accept parameters look like this:

enter image description here

The problem arises when I run the model. Here is code from the cell in which the problem occurs and its traceback:

from langchain_google_vertexai import GemmaVertexAIModelGarden, GemmaChatVertexAIModelGarden

llm = GemmaVertexAIModelGarden(
    endpoint_id=endpoint_id,
    project=project,
    location=location,
)

output = llm.invoke("What is the meaning of life?")
print(output)
_InactiveRpcError                         Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     75         try:
---> 76             return callable_(*args, **kwargs)
     77         except grpc.RpcError as exc:

11 frames
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
    status = StatusCode.INVALID_ARGUMENT
    details = "Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy."
    debug_error_string = "UNKNOWN:Error received from peer ipv4:173.194.215.95:443 {created_time:"2024-08-02T15:38:59.269976555+00:00", grpc_status:3, grpc_message:"Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy."}"
>

The above exception was the direct cause of the following exception:

InvalidArgument                           Traceback (most recent call last)
/usr/local/lib/python3.10/dist-packages/google/api_core/grpc_helpers.py in error_remapped_callable(*args, **kwargs)
     76             return callable_(*args, **kwargs)
     77         except grpc.RpcError as exc:
---> 78             raise exceptions.from_grpc_error(exc) from exc
     79 
     80     return error_remapped_callable

InvalidArgument: 400 Invalid Endpoint name: projects/use-gemma/locations/us-east1/endpoints/google_gemma-1_1-2b-it-mg-one-click-deploy.

Can anyone spot what is the cause of the problem, and/or what have I done wrong? Thank you in advance for any help.

Upvotes: 0

Views: 72

Answers (1)

chanp
chanp

Reputation: 675

I've found a solution by trial and error. The correct endpoint-related string to use in Colab must be an ID not a name. It can be copied from the area which I circle in this image.

enter image description here

Upvotes: 0

Related Questions