Function er_embed generates embeddings for text inputs.

er_embed(text, api = "huggingface", model = NULL, type = NULL, verbose = FALSE)

Arguments

text

a character vector of texts.

api

a character string specifying the embedding API. One of c("huggingface","openai","cohere"). Default is "huggingface".

model

a character string specifying the embedding model. Must match the model names in the corresponding APIs. See, huggingface.co/models, platform.openai.com/docs/models/embeddings, cohere.com/embeddings. Defaults to "sentence-transformers/all-mpnet-base-v2" for api = "huggingface", to "text-embedding-ada-002" for api = "openai", and to "embed-english-v3.0" for api = "cohere".

type

a character string specifying the type of Cohere embeddings. One of c("search_document","search_query","classification","clustering"). Default is "clustering". See https://docs.cohere.com/reference/embed.

verbose

a logical specifying whether to show messages.

Value

The function returns a matrix containing the text embeddings with length(text) rows and as many columns as there are embedding dimensions.

References

Wulff, D. U., Aeschbach, S., Hussain, Z., & Mata, R. (2024). embeddeR. In preparation.

Examples