lightopic.lightbertopic

A simple child class of bertopic.BERTopic to enable using Lightopic.

The only addition to the base class is a method to save_lightopic: this will serialise a model in a format suitable for instantiating a Lightopic model with Lightopic.load. As part of this process it will train a reduced UMAP model, suitable for projecting down to two dimensions for plotting.

Typical usage example: ```python from lightopic import LightBERTopic from sklearn.datasets import fetch_20newsgroups

docs = fetch_20newsgroups(subset=”all”)[“data”] topic_model = LightBERTopic() topics, probabilities = topic_model.fit_transform(docs) topic_model.save_lightopic(“lightopic_model”) ```

Classes

LightBERTopic

Child class of bertopic.BERTopic to enable serialising models in

Module Contents

class lightopic.lightbertopic.LightBERTopic

Bases: bertopic.BERTopic

Child class of bertopic.BERTopic to enable serialising models in the Lightopic format.

All methods from bertopic.BERTopic are left unchanged; we add only the save_lightopic method.

save_lightopic(output_path: str) None

Serialise a trained model for use as a Lightopic model.

Parameters:

output_path (str) – Directory path to serialise the model, will be created if it does not exist.