File tree 1 file changed +6
-1
lines changed
1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -238,14 +238,19 @@ def generate(self,
238
238
Returns:
239
239
(a list of/batched) text/chat completion
240
240
"""
241
+ from lmdeploy .messages import GenerationConfig
242
+
241
243
batched = True
242
244
if isinstance (inputs , str ):
243
245
inputs = [inputs ]
244
246
batched = False
245
247
prompt = inputs
246
248
gen_params = self .update_gen_params (** kwargs )
249
+ max_tokens = gen_params .pop ('max_tokens' )
250
+ gen_config = GenerationConfig (** gen_params )
251
+ gen_config .max_new_tokens = max_tokens
247
252
response = self .model .batch_infer (
248
- prompt , do_preprocess = do_preprocess , ** gen_params )
253
+ prompt , gen_config = gen_config , do_preprocess = do_preprocess )
249
254
response = [resp .text for resp in response ]
250
255
# remove stop_words
251
256
response = filter_suffix (response , self .gen_params .get ('stop_words' ))
You can’t perform that action at this time.
0 commit comments