Learn R Programming

bertopicr (version 0.3.6)

save_bertopic_model: Save a BERTopic Model Bundle

Description

Persist a trained BERTopic model to disk and store R-side extras in a companion RDS file. This is the recommended way to reuse a model across sessions when working through reticulate.

Usage

save_bertopic_model(topic_model, path)

Value

Invisibly returns TRUE after successful write.

Arguments

topic_model

A list returned by train_bertopic_model(). Must contain a Python BERTopic model at topic_model$model. Optional extras such as probabilities, reduced embeddings, topics over time, or topics per class are saved when present and set to NULL otherwise.

path

Directory path to write the Python model to. The RDS companion file is saved as paste0(path, "_extras.rds").

Examples

Run this code
# \donttest{
if (exists("topic_model")) {
  save_bertopic_model(topic_model, "topic_model")
} else {
  message("No topic_model found. Please train or load a model first.")
}
# }

Run the code above in your browser using DataLab