Apllying code in my own dataset
Hi, Thank you for this great job, i'm beginner in BERT, and i want to use your code to extract topics from arabic text (stored on MongDB), do you have an idea how can i do this? thank you so much.
BR
XLM-R from sentence-transformers is trained on 50+ languages including Arabic. To use BERTopic for Arabic text use the following code:
from bertopic import BERTopic
model = BERTopic("xlm-r-bert-base-nli-stsb-mean-tokens", verbose=True)
topics, probabilities = model.fit_transform(docs)
Of course, you will have to define docs yourself.
@nassera2014 you may also find some luck in using the arabic-bert-base model which was pre-trained on ~8.2 Billion words.
Once you load the pre-trained model, extracting embeddings is pretty similar to Maarten's example since they both are a HuggingFace model. And after that, fit_transforming the model should be easy.