MaartenGr / MaartenGr/BERTopic
Suggestion & Feedback: Add support for Apple Silicons' GPU support
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 7.8k
- Forks
- 920
- Avg merge
- 22h 24m
- Merged PRs (30d)
- 5
Description
First of all thanks a lot for this amazing package! I am currently using a MacBook Pro 2021 version with M1 Pro chip. As many Apple users may know, PyTorch now supports GPU acceleration by using mps as computing device. However, currently in the BERTopic model, there is no support for this parameter.
After digging into the details for some time I found a easy work around: SentenceTransformer do supports the device parameter, so we can simply do the following:
`embedding = SentenceTransformer('paraphrase-multilingual-MiniLM-L12-v2', device = 'mps')`
`model = BERTopic(language="chinese (simplified)", embedding_model=embedding, nr_topics='auto',verbose=True, vectorizer_model=vectorizer,) `
which will perform exactly as the default model if an user chooses to. On my Mac, this drastically reduce the training time from 4h30m to 58m.
I assume this should be also easy to incorporate into the package, which will be very helpful. Thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating BERTopic's embedding model handling and how it interacts with SentenceTransformer. Check how a device such as `mps` could be supported while preserving the default behavior, then verify topic-model training with Apple Silicon GPU acceleration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100