File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,7 @@ class EmbeddingEncoder {
209
209
210
210
// Run tokenization
211
211
const model_inputs = this . tokenizer ( texts , {
212
- padding : true ,
212
+ padding : typeof texts !== "string" ,
213
213
truncation : true ,
214
214
max_length :
215
215
typeof max_length !== "undefined" && max_length > 0
@@ -334,6 +334,8 @@ class EmbeddingEncoder {
334
334
`Model \`${ model } \` is not supported. Supported models: ${ this . supportModels . join ( ", " ) } `
335
335
) ;
336
336
}
337
+ const modelOpts = this . getModelByName ( model ) ;
338
+ const { max_length } = modelOpts ;
337
339
opts = {
338
340
...opts ,
339
341
...( typeof opts . padding !== "boolean" ? { padding : true } : { } ) ,
@@ -343,8 +345,12 @@ class EmbeddingEncoder {
343
345
} ;
344
346
345
347
return this . tokenizer ( texts , {
346
- padding : true ,
347
- truncation : true
348
+ padding : typeof texts !== "string" ,
349
+ truncation : true ,
350
+ max_length :
351
+ typeof max_length !== "undefined" && max_length > 0
352
+ ? max_length
353
+ : DEFAULT_MAX_LENGTH
348
354
} ) ;
349
355
}
350
356
}
You can’t perform that action at this time.
0 commit comments