Use Vertex AI to send text embedding requests to Google's PaLM 2 Large Language Model (LLM) and to receive a response. Test and customize prompts to meet the needs of your application.
Before you begin
Before you can try the chat prompts, you must do the following:
- Set up a project and a development environment. The project ID is needed to run the sample code.
- Familiarize yourself with the text embedding parameters that you must replace before running the sample code.
- Review the text embedding use cases to help you identify which type of sample to create.
Try text embedding requests
The Vertex AI PaLM Embedding API performs online (real-time) predictions, which use text embedding requests as input to the model. The API accepts 3,072 input tokens and outputs 768-dimensional vector embeddings.
Select a tab, and follow the instructions to run the sample.
Vertex AI SDK for Python
To learn how to install or update the Vertex AI SDK for Python, see Install the Vertex AI SDK for Python. For more information, see the Vertex AI SDK for Python API reference documentation.
C#
Before trying this sample, follow the C# setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI C# API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Node.js API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Vertex AI quickstart using client libraries. For more information, see the Vertex AI Java API reference documentation.
To authenticate to Vertex AI, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Console
To try a text embedding request by using the Google Cloud console, do the following:
-
Open the Cloud Shell terminal in the Google Cloud console.
-
Edit the placeholders in the sample code, and copy to the console.
MODEL_ID="textembedding-gecko" PROJECT_ID=PROJECT_ID curl \ -X POST \ -H "Authorization: Bearer $(gcloud auth print-access-token)" \ -H "Content-Type: application/json" \ https://us-central1-aiplatform.googleapis.com/v1/projects/${PROJECT_ID}/locations/us-central1/publishers/google/models/${MODEL_ID}:predict -d \ $'{ "instances": [ { "content": "What is life?"} ], }'
What's next
- Learn about designing text prompts. and text chat prompts.
- Learn how to test prompts in Generative AI Studio.
- Learn about text embeddings.
- Try to tune a language foundation model.
- Learn about responsible AI best practices and Vertex AI's safety filters.