get_embeddings: Get Vector Embeddings (uses Python)

View source: R/python.R

get_embeddingsR Documentation

Get Vector Embeddings (uses Python)

Description

This function wraps the 'transformers' library in 'Python', to obtain vector embeddings (a numerical representation of meaning) for a character vector based on a pretrained model.

Usage

get_embeddings(x, model_path = NULL)

Arguments

x

Character vector of text to be embedded.

model_path

Atomic character vector referring to a folder with a pretrained model. Default: NULL

Value

Matrix

Examples

## Not run: 
if(requireNamespace("reticulate", quietly = TRUE)){
 tmp <- get_embeddings(c("cat", "my cat", "dog"),
 model_path = "scibert_scivocab_uncased")
 }

## End(Not run)

theorytools documentation built on Feb. 7, 2026, 5:06 p.m.