ddangelov / Top2Vec

Top2Vec learns jointly embedded topic, document and word vectors.
BSD 3-Clause "New" or "Revised" License
2.92k stars 374 forks source link

ValueError: Number of topics must be less than 1. #311

Closed waguken closed 1 year ago

waguken commented 1 year ago

In order to compare training results with different numbers of data in terms of cosine similarity, we reduced the number of topics in the training results with more data to match those with less data. It succeeded several times and generally I am having trouble with this error. I would like to know what is causing this and which parameter is affecting it.

# top2vec_model2 = Top2Vec2(docs2,embedding_model='universal-sentence-encoder-multilingual') num_TP=top2vec_model2.get_num_topics() print(num_TP) vector = top2vec_model2.topic_vectors print(vector)

top2vec_model = Top2Vec2(docs,embedding_model='universal-sentence-encoder-multilingual') top2vec_model.hierarchical_topic_reduction(num_TP) num_TP2=top2vec_model.get_num_topics(reduced=True) print(num_TP2) answer = top2vec_model.topic_vectors_reduced print(answer) # ↓ Traceback (most recent call last): File "guess.py", line 73, in top2vec_model.hierarchical_topic_reduction(num_TP) File "D:\novel\TP\top2vec\Top2Vec2.py", line 1804, in hierarchical_topic_reduction self._validate_hierarchical_reduction_num_topics(num_topics) File "D:\novel\TP\top2vec\Top2Vec2.py", line 1147, in _validate_hierarchical_reduction_num_topics raise ValueError(f"Number of topics must be less than {current_num_topics}.") ValueError: Number of topics must be less than 1.