Create an embedding model using a model available from the Flair Library
Source:R/embed.R
bt_make_embedder_flair.Rd
Create an embedding model using a model available from the Flair Library
Usage
bt_make_embedder_flair(
model,
...,
flair_class = c("FlairEmbeddings", "TransformerWordEmbeddings",
"TransformerDocumentEmbeddings", "WordEmbeddings")
)
Arguments
- model
name of model used to create embeddings
- ...
Additional arguments to be passed to the selected Flair class
- flair_class
BertopicR is currently compatible with 4 Flair embedding classes: FlairEmbeddings, WordEmbeddings, TransformerWordEmbeddings and TransformerDocumentEmbeddings. If you chose to perform word embeddings rather than document embeddings, bt_do_embedding will pool the word embeddings for each document to calculate a mean value.
Value
an embedding model, formed according to the model defined, that can be input to be_do_embedding to create document embeddings
Examples
# \donttest{
# Flair Embedding, reducing chars_per_chunk to help with memory issues
embedder <- bt_make_embedder_flair(model = "news-forward", flair_class = "FlairEmbeddings", chars_per_chunk = 400L)
#> Error in bt_make_embedder_flair(model = "news-forward", flair_class = "FlairEmbeddings", chars_per_chunk = 400L): flair is not in installed packages of current environment, run reticulate::py_install("flair").
#>
#> Note that if you receive a module not found error, you may need to instead run reticulate::py_install("flair", pip = TRUE) to force installation with pip instead of conda.
# Transformer Document Embedding
embedder <- bt_make_embedder_flair(model = "roberta-base", flair_class = "TransformerDocumentEmbeddings")
#> Error in bt_make_embedder_flair(model = "roberta-base", flair_class = "TransformerDocumentEmbeddings"): flair is not in installed packages of current environment, run reticulate::py_install("flair").
#>
#> Note that if you receive a module not found error, you may need to instead run reticulate::py_install("flair", pip = TRUE) to force installation with pip instead of conda.
# }