Skip to content

Commit

Permalink
Revert change
Browse files Browse the repository at this point in the history
  • Loading branch information
picaultj authored and dsia-dev committed Feb 24, 2025
1 parent 187860c commit 1a5d6fa
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions bertrend/BERTrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# See AUTHORS.txt
# SPDX-License-Identifier: MPL-2.0
# This file is part of BERTrend.
import copy
import os
import pickle

Expand Down Expand Up @@ -628,14 +629,15 @@ def save_models(self, models_path: Path = MODELS_DIR):
topic_model.doc_info_df.to_pickle(model_dir / DOC_INFO_DF_FILE)
topic_model.topic_info_df.to_pickle(model_dir / TOPIC_INFO_DF_FILE)


# Serialize BERTrend (excluding topic models for separate reuse if needed)
# topic_models_bak = copy.deepcopy(self.topic_models)
# FIXME: the commented code introduced a too-heavy memory overhead, to be improved; the idea is to serialize
topic_models_bak = copy.deepcopy(self.topic_models)
# FIXME: the code above introduced a too-heavy memory overhead, to be improved; the idea is to serialize
# the topics models separetely from the rest of the BERTrend object
# self.topic_models = None
self.topic_models = None
with open(models_path / BERTREND_FILE, "wb") as f:
dill.dump(self, f)
# self.topic_models = topic_models_bak
self.topic_models = topic_models_bak

logger.info(f"Models saved to: {models_path}")

Expand Down

0 comments on commit 1a5d6fa

Please sign in to comment.