Skip to content

Embed using Google Vertex API platform

Usage

embed_google_vertex(
  x,
  model,
  location,
  project_id,
  task_type = "RETRIEVAL_QUERY"
)

Arguments

x

x can be:

  • A character vector, in which case a matrix of embeddings is returned.

  • A data frame with a column named text, in which case the dataframe is returned with an additional column named embedding.

  • Missing or NULL, in which case a function is returned that can be called to get embeddings. This is a convenient way to partial in additional arguments like model, and is the most convenient way to produce a function that can be passed to the embed argument of ragnar_store_create().

model

Character specifying the embedding model. See supported models in Text embeddings API

location

Location, e.g. us-east1, me-central1, africa-south1.

project_id

Project ID.

task_type

Used to convey intended downstream application to help the model produce better embeddings. If left blank, the default used is "RETRIEVAL_QUERY".

  • "RETRIEVAL_QUERY"

  • "RETRIEVAL_DOCUMENT"

  • "SEMANTIC_SIMILARITY"

  • "CLASSIFICATION"

  • "CLUSTERING"

  • "QUESTION_ANSWERING"

  • "FACT_VERIFICATION"

  • "CODE_RETRIEVAL_QUERY" For more information about task types, see Choose an embeddings task type.

Examples

# \dontrun{
embed_google_vertex(
 "hello world",
 model="gemini-embedding-001",
 project = "<your-project-id>",
 location = "us-central1"
)
#> Error in embed_google_vertex("hello world", model = "gemini-embedding-001",     project = "<your-project-id>", location = "us-central1"): No Google credentials are available.
#>  Try suppling an API key or configuring Google's application default
#>   credentials.
# }