event-data-extraction-playground
/
src
/nlp
/experimental
/textclassification
/zero_shot_classification_bertopic.py
from bertopic.representation import ZeroShotClassification | |
from bertopic import BERTopic | |
# Create your representation model | |
candidate_topics = ["space and nasa", "bicycles", "sports"] | |
representation_model = ZeroShotClassification(candidate_topics, model="facebook/bart-large-mnli") | |
# Use the representation model in BERTopic on top of the default pipeline | |
topic_model = BERTopic(representation_model=representation_model) | |