Skip to contents

Create an embedding model using a model available from the Spacy Library

Usage

bt_make_embedder_spacy(model, ..., prefer_gpu = TRUE, exclude = NULL)

Arguments

model

The pipeline used to make predictions

...

additional arguments to be sent to the spacy.load function

prefer_gpu

if TRUE use gpu if available

exclude

name of pipeline components to exclude

Value

an embedding model, formed according to the model defined, that can be input to be_do_embedding to create document embeddings

Examples

# \donttest{
# specify a non-transformer model, excluding features not required
embedder <- bt_make_embedder_spacy(model = "en_core_web_md", exclude = c("tagger", "parser", "ner", "attribute_ruler", "lemmatizer"))
#> spacy is not in installed packages of current environment, run reticulate::py_install("spacy").
#> Error in py_module_import(module, convert = convert): ModuleNotFoundError: No module named 'spacy'
#> Run `reticulate::py_last_error()` for details.

# specify a transformer model and exclude features not required
embedder <- bt_make_embedder_spacy(model = "en_core_web_trf", exclude = c("tagger", "parser", "ner", "attribute_ruler", "lemmatizer"))
#> spacy is not in installed packages of current environment, run reticulate::py_install("spacy").
#> Error in py_module_import(module, convert = convert): ModuleNotFoundError: No module named 'spacy'
#> Run `reticulate::py_last_error()` for details.
# }