Skip to contents

Extract term embeddings from an embedded topic model (ETM).

Usage

get_term_embeddings(x)

Arguments

x

Either an nlp_topic_fit with engine = "topicmodels.etm" or a raw ETM object.

Value

A data.table with one row per term, a term column, and one column per embedding dimension named dim_001, dim_002, and so on.

Examples

if (FALSE) { # requireNamespace("topicmodels.etm", quietly = TRUE) && requireNamespace("torch", quietly = TRUE) && torch::torch_is_installed()
path <- system.file(package = "topicmodels.etm", "example", "example_etm.ckpt")
model <- torch::torch_load(path)
get_term_embeddings(model)
}