Open In Colab

Google PaLM Embeddings#

If you’re opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.

%pip install llama-index-embeddings-google
!pip install llama-index
# imports
from import GooglePaLMEmbedding
# get API key and create embeddings

model_name = "models/embedding-gecko-001"
api_key = "YOUR API KEY"

embed_model = GooglePaLMEmbedding(model_name=model_name, api_key=api_key)

embeddings = embed_model.get_text_embedding("Google PaLM Embeddings.")
/opt/homebrew/lib/python3.11/site-packages/tqdm/ TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See
  from .autonotebook import tqdm as notebook_tqdm
print(f"Dimension of embeddings: {len(embeddings)}")
Dimension of embeddings: 768
[0.028517298, -0.0028859433, -0.035110522, 0.021982985, -0.0039763353]