You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Distill a staticmodel from a sentence transformer.
@@ -46,25 +47,20 @@ def distill_from_model(
46
47
:param pca_dims: The number of components to use for PCA.
47
48
If this is None, we don't apply PCA.
48
49
If this is 'auto', we don't reduce dimensionality, but still apply PCA.
49
-
:param apply_zipf: DEPRECATED: This parameter used to control whether Zipf is applied.
50
-
Zipf weighting is now controlled by the sif_coefficient parameter. If this is set to None, no weighting is applied.
51
50
:param sif_coefficient: The SIF coefficient to use. If this is None, no weighting is applied.
52
51
Should be a value > 0 and < 1.0. A value of 1e-4 is a good default.
53
52
:param token_remove_pattern: If this is set to a string, we compile this into a regex. Any tokens that conform to this regex pattern will be removed from the vocabulary.
54
53
If the pattern is so general that it removes all tokens, we throw an error. If the pattern can't be compiled into a valid regex, we also throw an error.
55
54
:param quantize_to: The data type to quantize to. Can be any of the DType enum members or their string equivalents.
56
-
:param use_subword: DEPRECATED: If this is not set to None, we show a warning. It doesn't do anything.
55
+
:param lower_case: If this is set, all tokens in the model vocabulary will be converted to lowercase, and
56
+
a lowercase normalizer will be inserted. This almost always improves performance.
57
57
:return: A StaticModel
58
58
:raises: ValueError if the vocabulary is empty after preprocessing.
59
59
60
60
"""
61
-
ifuse_subwordisnotNone:
62
-
logger.warning(
63
-
"The `use_subword` parameter is deprecated and will be removed in the next release. It doesn't do anything."
"seq_length": 1000000, # Set this to a high value since we don't have a sequence length limit.
@@ -157,35 +144,19 @@ def distill_from_model(
157
144
158
145
159
146
def_validate_parameters(
160
-
apply_zipf: bool|None,
161
147
sif_coefficient: float|None,
162
148
token_remove_pattern: str|None,
163
149
) ->tuple[float|None, re.Pattern|None]:
164
150
"""
165
151
Validate the parameters passed to the distillation function.
166
152
167
-
:param apply_zipf: DEPRECATED: This parameter used to control whether Zipf is applied.
168
-
Zipf weighting is now controlled by the sif_coefficient parameter. If this is set to None, no weighting is applied.
169
153
:param sif_coefficient: The SIF coefficient to use. If this is None, no weighting is applied.
170
154
Should be a value >= 0 and < 1.0. A value of 1e-4 is a good default.
171
155
:param token_remove_pattern: If this is set to a string, we compile this into a regex. Any tokens that conform to this regex pattern will be removed from the vocabulary.
172
156
:return: The SIF coefficient to use.
173
157
:raises: ValueError if the regex can't be compiled.
174
158
175
159
"""
176
-
ifapply_zipfisnotNone:
177
-
logger.warning(
178
-
"The `apply_zipf` parameter is deprecated and will be removed in the next release. "
179
-
"Zipf weighting is applied based on the sif_coefficient parameter. If this is set to None, "
180
-
"no weighting is applied."
181
-
)
182
-
ifapply_zipfandsif_coefficientisNone:
183
-
logger.warning("You set apply_zipf to True, but sif_coefficient is None. Setting sif_coefficient to 1e-4.")
184
-
sif_coefficient=1e-4
185
-
elifnotapply_zipf:
186
-
logger.warning("Because you set apply_zipf to False, we ignore the sif_coefficient parameter.")
187
-
sif_coefficient=None
188
-
189
160
ifsif_coefficientisnotNone:
190
161
ifnot0<sif_coefficient<1.0:
191
162
raiseValueError("SIF coefficient must be a value > 0 and < 1.0.")
@@ -205,12 +176,11 @@ def distill(
205
176
vocabulary: list[str] |None=None,
206
177
device: str|None=None,
207
178
pca_dims: PCADimType=256,
208
-
apply_zipf: bool|None=None,
209
179
sif_coefficient: float|None=1e-4,
210
180
token_remove_pattern: str|None=r"\[unused\d+\]",
211
181
trust_remote_code: bool=False,
212
182
quantize_to: DType|str=DType.Float16,
213
-
use_subword: bool|None=None,
183
+
lower_case: bool=True,
214
184
) ->StaticModel:
215
185
"""
216
186
Distill a staticmodel from a sentence transformer.
@@ -227,14 +197,13 @@ def distill(
227
197
:param pca_dims: The number of components to use for PCA.
228
198
If this is None, we don't apply PCA.
229
199
If this is 'auto', we don't reduce dimenionality, but still apply PCA.
230
-
:param apply_zipf: DEPRECATED: This parameter used to control whether Zipf is applied.
231
-
Zipf weighting is now controlled by the sif_coefficient parameter. If this is set to None, no weighting is applied.
232
200
:param sif_coefficient: The SIF coefficient to use. If this is None, no weighting is applied.
233
201
Should be a value >= 0 and < 1.0. A value of 1e-4 is a good default.
234
202
:param token_remove_pattern: If this is set to a string, we compile this into a regex. Any tokens that conform to this regex pattern will be removed from the vocabulary.
235
203
:param trust_remote_code: Whether to trust the remote code. If this is False, we will only load components coming from `transformers`. If this is True, we will load all components.
236
204
:param quantize_to: The data type to quantize to. Can be any of the DType enum members or their string equivalents.
237
-
:param use_subword: DEPRECATED: If this is not set to None, we show a warning. It doesn't do anything.
205
+
:param lower_case: If this is set, all tokens in the model vocabulary will be converted to lowercase, and
206
+
a lowercase normalizer will be inserted. This almost always improves performance.
0 commit comments