File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -4315,11 +4315,11 @@ def _create_topic_vectors(
43154315 if embeddings is not None and documents is not None :
43164316 topic_embeddings = []
43174317 topics = documents .sort_values ("Topic" ).Topic .unique ()
4318+ topic_ids = documents ["Topic" ].values
4319+ doc_ids = documents ["ID" ].values .astype (int )
43184320 for topic in topics :
4319- indices = documents .loc [documents .Topic == topic , "ID" ].values
4320- indices = [int (index ) for index in indices ]
4321- topic_embedding = np .mean (embeddings [indices ], axis = 0 )
4322- topic_embeddings .append (topic_embedding )
4321+ mask = topic_ids == topic
4322+ topic_embeddings .append (embeddings [doc_ids [mask ]].mean (axis = 0 ))
43234323 self .topic_embeddings_ = np .array (topic_embeddings )
43244324
43254325 # Topic embeddings when merging topics
You can’t perform that action at this time.
0 commit comments