22
33from collections import defaultdict
44from math import ceil
5- from typing import Generic , Literal , Sequence
5+ from typing import Any , Generic , Literal , Sequence
66
77import numpy as np
88from frozendict import frozendict
@@ -102,7 +102,8 @@ def from_records(
102102 columns : Sequence [str ] | None = None ,
103103 use_ann : bool = True ,
104104 model : Encoder | None = None ,
105- ann_backend : Backend = Backend .USEARCH ,
105+ ann_backend : Backend | str = Backend .USEARCH ,
106+ ** kwargs : Any ,
106107 ) -> SemHash :
107108 """
108109 Initialize a SemHash instance from records.
@@ -114,6 +115,7 @@ def from_records(
114115 :param use_ann: Whether to use approximate nearest neighbors (True) or basic search (False). Default is True.
115116 :param model: (Optional) An Encoder model. If None, the default model is used (minishlab/potion-base-8M).
116117 :param ann_backend: (Optional) The ANN backend to use if use_ann is True. Defaults to Backend.USEARCH.
118+ :param **kwargs: Any additional keyword arguments to pass to the Vicinity index.
117119 :return: A SemHash instance with a fitted vicinity index.
118120 :raises ValueError: If columns are not provided for dictionary records.
119121 """
@@ -158,6 +160,7 @@ def from_records(
158160 vectors = embeddings ,
159161 items = items ,
160162 backend_type = backend ,
163+ ** kwargs ,
161164 )
162165
163166 return cls (index = index , columns = columns , model = model , was_string = was_string )
0 commit comments