Skip to content

Instantly share code, notes, and snippets.

@MaartenGr
Created January 5, 2021 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaartenGr/49e70d18517585fb83ed8e4eb148c193 to your computer and use it in GitHub Desktop.
Save MaartenGr/49e70d18517585fb83ed8e4eb148c193 to your computer and use it in GitHub Desktop.
from bertopic import BERTopic
from sentence_transformers import SentenceTransformer
# Prepare embeddings
sentence_model = SentenceTransformer("distilbert-base-nli-mean-tokens")
embeddings = sentence_model.encode(docs, show_progress_bar=False)
# Create topic model
model = BERTopic()
topics, probabilities = model.fit_transform(docs, embeddings)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment