Skip to content

Commit

Permalink
Merge pull request #4 from dataiku/fix/remove-inner-products
Browse files Browse the repository at this point in the history
Remove every inner product based similarity metrics
  • Loading branch information
alexcombessie authored Nov 25, 2020
2 parents 63f8037 + 2e42eb7 commit 2a6c8b8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
8 changes: 0 additions & 8 deletions custom-recipes/similarity-search-index/recipe.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@
{
"label": "Hamming",
"value": "hamming"
},
{
"label": "Dot",
"value": "dot"
}
],
"defaultValue": "angular",
Expand All @@ -148,10 +144,6 @@
"label": "Exact Search for L2",
"value": "IndexFlatL2"
},
{
"label": "Exact Search for Inner Product",
"value": "IndexFlatIP"
},
{
"label": "Locality-Sensitive Hashing",
"value": "IndexLSH"
Expand Down
4 changes: 2 additions & 2 deletions python-lib/dku_param_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def load_indexing_recipe_params() -> Dict:
modeling_params["expert"] = bool(recipe_config.get("expert"))
if modeling_params["algorithm"] == "annoy":
modeling_params["annoy_metric"] = recipe_config.get("annoy_metric")
if modeling_params["annoy_metric"] not in {"angular", "euclidean", "manhattan", "hamming", "dot"}:
if modeling_params["annoy_metric"] not in {"angular", "euclidean", "manhattan", "hamming"}:
raise PluginParamValidationError(f"Invalid Annoy distance metric: {modeling_params['annoy_metric']}")
modeling_params["annoy_num_trees"] = recipe_config.get("annoy_num_trees")
if not isinstance(modeling_params["annoy_num_trees"], int):
Expand All @@ -99,7 +99,7 @@ def load_indexing_recipe_params() -> Dict:
raise PluginParamValidationError("Number of trees must be above 1")
elif modeling_params["algorithm"] == "faiss":
modeling_params["faiss_index_type"] = recipe_config.get("faiss_index_type")
if modeling_params["faiss_index_type"] not in {"IndexFlatL2", "IndexFlatIP", "IndexLSH"}:
if modeling_params["faiss_index_type"] not in {"IndexFlatL2", "IndexLSH"}:
raise PluginParamValidationError(f"Invalid FAISS index type: {modeling_params['faiss_index_type']}")
modeling_params["faiss_lsh_num_bits"] = recipe_config.get("faiss_lsh_num_bits")
if not isinstance(modeling_params["faiss_lsh_num_bits"], int):
Expand Down
2 changes: 0 additions & 2 deletions python-lib/nearest_neighbor/faiss.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def __init__(self, num_dimensions: int, **kwargs):
self.faiss_lsh_num_bits = int(kwargs.get("faiss_lsh_num_bits", 4))
if self.faiss_index_type == "IndexFlatL2":
self.index = faiss.IndexFlatL2(self.num_dimensions)
elif self.faiss_index_type == "IndexFlatIP":
self.index = faiss.IndexFlatIP(self.num_dimensions)
elif self.faiss_index_type == "IndexLSH":
self.index = faiss.IndexLSH(self.num_dimensions, self.faiss_lsh_num_bits)
else:
Expand Down

0 comments on commit 2a6c8b8

Please sign in to comment.