Skip to contents

Generate vector embeddings for input data using Pinecone's hosted embedding models.

Usage

embed(model, inputs, input_type = "passage", truncate = "END", tidy = TRUE)

Arguments

model

The embedding model to use. Available models include: - "multilingual-e5-large" (1024 dimensions) - "pinecone-sparse-english-v0" (sparse vectors) See Pinecone documentation for the full list of available models.

inputs

A character vector of texts to embed.

input_type

The type of input. Either "passage" for documents to be indexed, or "query" for search queries. Default is "passage".

truncate

How to handle inputs longer than the model's max token length. Options: "END" (truncate from end), "NONE" (error if too long). Default is "END".

tidy

Whether to return a tidy tibble format (default: TRUE). If FALSE, returns the raw API response structure.

Value

List with http response, content (embeddings), and status_code. When tidy = TRUE, content is a tibble with columns: - values: list column containing the embedding vectors

Examples

if (FALSE) { # \dontrun{
# Embed documents for indexing
result <- embed(
  model = "multilingual-e5-large",
  inputs = c("The quick brown fox", "jumps over the lazy dog"),
  input_type = "passage"
)

# Embed a query for searching
query_embedding <- embed(
  model = "multilingual-e5-large",
  inputs = "What does the fox do?",
  input_type = "query"
)

# Use the embedding for a vector query
vector_query("my-index", vector = query_embedding$content$values[[1]], top_k = 10)
} # }