Skip to content

Commit

Permalink
transformers changed model save format
Browse files Browse the repository at this point in the history
  • Loading branch information
iulusoy committed May 15, 2024
1 parent 8f167a3 commit aa6c761
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions moralization/tests/test_transformers_model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,14 +264,11 @@ def test_train_evaluate(gen_instance, gen_instance_dm):
learning_rate,
)
assert gen_instance.results["overall_precision"] == pytest.approx(0.0, 1e-3)
assert (model_path / "pytorch_model.bin").is_file()
assert (model_path / "model.safetensors").is_file()
assert (model_path / "special_tokens_map.json").is_file()
assert (model_path / "config.json").is_file()
evaluate_result = gen_instance.evaluate("Python ist toll.")
assert evaluate_result[0]["score"]
del gen_instance._model_path
with pytest.raises(ValueError):
gen_instance.evaluate("Python ist toll.")
# check that column names throw error if not given correctly
label_column_name = "something"
with pytest.raises(ValueError):
Expand All @@ -291,6 +288,9 @@ def test_train_evaluate(gen_instance, gen_instance_dm):
num_train_epochs,
learning_rate,
)
del gen_instance._model_path
with pytest.raises(ValueError):
gen_instance.evaluate("Python ist toll.")


def test_publish(gen_instance):
Expand Down
2 changes: 1 addition & 1 deletion moralization/transformers_model_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ def _evaluate_model(self):
def save(self):
"""Save the model to the set model path.
If a model already exists in that path, it will be overwritten."""
model_file = self.model_path / "pytorch_model.bin"
model_file = self.model_path / "model.safetensors"
if model_file.exists():
print(
"Model file already existing at specified model path {} - will be overwritten.".format(
Expand Down

0 comments on commit aa6c761

Please sign in to comment.