Skip to content

Commit

Permalink
Add from_dict tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrl committed Aug 2, 2024
1 parent bacde0f commit 923b112
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ def test_from_dict(self):
"meta_fields_to_embed": ["meta_field"],
"trust_remote_code": True,
"truncate_dim": 256,
"model_kwargs": {"torch_dtype": "torch.float32"},
"tokenizer_kwargs": {"model_max_length": 512},
}
component = SentenceTransformersDocumentEmbedder.from_dict(
{
Expand All @@ -151,6 +153,8 @@ def test_from_dict(self):
assert component.trust_remote_code
assert component.meta_fields_to_embed == ["meta_field"]
assert component.truncate_dim == 256
assert component.model_kwargs == {"torch_dtype": torch.float32}
assert component.tokenizer_kwargs == {"model_max_length": 512}

def test_from_dict_no_default_parameters(self):
component = SentenceTransformersDocumentEmbedder.from_dict(
Expand Down
2 changes: 2 additions & 0 deletions test/components/rankers/test_transformers_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ def test_from_dict(self):
"calibration_factor": None,
"score_threshold": 0.01,
"model_kwargs": {"torch_dtype": "torch.float16"},
"tokenizer_kwargs": {"model_max_length": 512},
},
}

Expand All @@ -176,6 +177,7 @@ def test_from_dict(self):
"torch_dtype": torch.float16,
"device_map": ComponentDevice.resolve_device(None).to_hf(),
}
assert component.tokenizer_kwargs == {"model_max_length": 512}

def test_from_dict_no_default_parameters(self):
data = {
Expand Down

0 comments on commit 923b112

Please sign in to comment.