Clustering Lists of Words (Python)

Viewed 51

I have 54 lists consisting of words of varying lengths. For example:
1 = ["fly", "robot", "ketchup"].
2 = ["rain", "fly", "top", "jacket"].
....

I would like to cluster similar lists into groups based on the words in each list. The order of the words in the list does matter slightly but isn't the only criteria for a match. Any ideas? I was thinking of using BERT and then K-means clustering.

I want the lists to remain intact, just grouped/clustered.

1 Answers

I think BERT + K-Means is a good approach. Since the order of the words matter I would just treat each list as a sentence and instead of using just BERT I would use SentenceBERT which is usually better for clustering tasks.

Here you have a good tutorial from the original SentenceBERT documentation.

Related