Skip to content

Commit

Permalink
Add search_model to settings_validation
Browse files Browse the repository at this point in the history
Add search model to settings fields
  • Loading branch information
vicilliar authored Nov 2, 2023
2 parents abe12f6 + 510be8d commit 9945851
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/marqo_commons/settings_validation/settings_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def validate_index_settings(settings_to_validate: dict, MAX_NUMBER_OF_REPLICAS:
NsFields.model_properties: {
"type": "object",
},
NsFields.search_model: {
"type": "string",
"examples": [
"hf/all_datasets_v4_MiniLM-L6"
]
},
NsFields.search_model_properties: {
"type": "object",
},
NsFields.normalize_embeddings: {
"type": "boolean",
"examples": [
Expand Down
2 changes: 2 additions & 0 deletions src/marqo_commons/shared_utils/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class IndexSettingsField:
treat_urls_and_pointers_as_images = "treat_urls_and_pointers_as_images"
model = "model"
model_properties = "model_properties"
search_model = "search_model"
search_model_properties = "search_model_properties"
normalize_embeddings = "normalize_embeddings"

text_preprocessing = "text_preprocessing"
Expand Down
18 changes: 18 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ def test_validate_index_settings_model_properties(self):
MAX_NUMBER_OF_REPLICAS=
self.MARQO_MAX_NUMBER_OF_REPLICAS,
)

def test_validate_index_settings_search_model(self):
good_settings = self.get_good_index_settings()
good_settings['index_defaults']['model_properties'] = {
"dimensions": 123,
"url": "https://random_site.com"
}
good_settings['index_defaults']['search_model'] = "ViT-B/32"
good_settings['index_defaults']['search_model_properties'] = {
"dimensions": 456,
"url": "https://random_site.com"
}
assert good_settings == validate_index_settings(good_settings,
MAX_EF_CONSTRUCTION_VALUE=
self.MARQO_EF_CONSTRUCTION_MAX_VALUE,
MAX_NUMBER_OF_REPLICAS=
self.MARQO_MAX_NUMBER_OF_REPLICAS,
)

def test_validate_index_settings_bad(self):
bad_settings = [{
Expand Down

0 comments on commit 9945851

Please sign in to comment.