Skip to content

Commit 8b0d263

Browse files
committed
no model.get_max_length() function so set tokenizer max when it's None
Signed-off-by: HenryL27 <[email protected]>
1 parent 538f803 commit 8b0d263

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

opensearch_py_ml/ml_models/crossencodermodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def zip_model(self, framework: str = "pt", zip_fname: str = "model.zip") -> Path
120120
# save tokenizer file
121121
tk_path = Path(f"/tmp/{mname}-tokenizer")
122122
tk.save_pretrained(tk_path)
123-
if tk.model_max_length > model.get_max_length():
123+
if tk.model_max_length is None:
124124
model_config = AutoConfig.from_pretrained(self._hf_model_id)
125125
if hasattr(model_config, "max_position_embeddings"):
126126
tk.model_max_length = model_config.max_position_embeddings
@@ -129,7 +129,7 @@ def zip_model(self, framework: str = "pt", zip_fname: str = "model.zip") -> Path
129129
else:
130130
tk.model_max_length = 2**15 # =32768. Set to something big I guess
131131
print(
132-
f"The model_max_length is not properly defined in tokenizer_config.json. Setting it to be {tk.model_max_length}"
132+
f"The model_max_length is not found in tokenizer_config.json. Setting it to be {tk.model_max_length}"
133133
)
134134
_fix_tokenizer(tk.model_max_length, tk_path)
135135

0 commit comments

Comments
 (0)