Repository navigation
Standardized approaches to automating hyperparameter-tuning? #1031
Replies: 1 comment 2 replies
Thank you for your kind words! Glad to hear that the "lego block" approach is appreciated.
As highlighted, there are two parts in your question that I think are important here, namely parameter tuning combined with an evaluation metric, namely coherence. First, parameter tuning will remain important regardless of the evaluation metric as out-of-the-box solutions seldom work perfectly with every single use case. In the case of BERTopic, and from my personal view, I believe parameter tuning in BERTopic should be done first with human evaluation. I believe it is more important to answer questions like "Does the number of topics resonate with domain experts?" and "Is my model in line with its intended use case?" than it does maximizing coherence. This brings me to the second component, namely coherence scores and evaluation metrics in general. The difficulty with evaluation metrics in topic modeling is that they often are not fully subjective. If I decide on a topic to be cohesive, many others might disagree with it. I have seen it time and time again where even domain experts disagree on things like topic cohesiveness, diversity, number of topics, topic distributions, etc. As a result, I would typically advise refraining from tuning the hyperparameters to optimize coherence as there is a good chance of overfitting to an imperfect metric. Having said that, it does not mean that you should forego any evaluation metric. The reason for me often advising OCTIS is that it implements a wide variety of evaluation metrics, which together, give a much better overview of a model's quality than a single metric.
BERTopic does not meet the requirements out of the box. The reason is mostly explained above but it all boils down to each use case being different and therefore needing a different set of evaluation metrics, custom or not. Having said that, you can find some code for using OCTIS with BERTopic here although it was not meant to be a framework for doing so at is was merely part of the paper. Instead of making sure BERTopic follows the suggested class, it creates an output used by their scoring functions as mentioned here. |
Uh oh!
There was an error while loading. Please reload this page.
First: Loving the latest (very modular) version of Bertopic (v0.14) - I'm learning so much playing around with each "lego block" :)
Second: I'm now trying to figure out the best (or at least most repeatable and formalized) method for tuning all the hyperparameters that make up the bertopic 'stack' to get the highest coherence score possible ... but public threads on the subject seem to be pretty scarce.
@MaartenGr I've seen you recommend using OCTIS for this, and I'm currently trying to figure out how to go about doing so. Would you say that Bertopic v0.14 is written in a way that's compatible with OCTIS? For example, the OCTIS documentation has a specific section on "Implementing Your Own Model" that specifically says:
"[OCTIS] Models inherit from the class AbstractModel defined in octis/models/model.py . To build your own model, your class must override the train_model(self, dataset, hyperparameters) method which always requires at least a Dataset object and a Dictionary of hyperparameters as input and should return a dictionary with the output of the model as output."
Would you say the BERTopic() class meets the above requirements "out of the box"? Is there anything specific that needs to be done/changed for bertopic models to be able to be plugged into an OCTIS-based parameter-tuning pipeline?
As always, thank you in advance!
Momoko
P.S. I will keep trying to answer this question on my own, but any clues or specifics on "how to use OCTIS to evaluate/optimize bertopic models" would be hugely appreciated!
All reactions