3030import torch
3131from pydantic import NonNegativeFloat , NonNegativeInt , PositiveInt
3232from tqdm import tqdm
33+ from vllm .inputs .data import TokensPrompt
3334
3435from lighteval .data import GenerativeTaskDataset , LoglikelihoodDataset
3536from lighteval .models .abstract_model import LightevalModel , ModelConfig
@@ -415,6 +416,8 @@ def _generate(
415416 generate : bool = True ,
416417 ) -> list :
417418 """Contains the actual logic of the generation."""
419+ # Wrap inputs with TokensPrompt to make compatible with VLLM >= 0.10.2
420+ inputs = [TokensPrompt (prompt_token_ids = token_ids ) for token_ids in inputs ]
418421 sampling_params = SamplingParams (** self .config .generation_parameters .to_vllm_dict ())
419422
420423 if generate :
@@ -437,7 +440,7 @@ def _generate(
437440 @ray .remote (num_gpus = self .tensor_parallel_size )
438441 def run_inference_one_model (model_args : dict , sampling_params : SamplingParams , requests ):
439442 llm = LLM (** model_args )
440- return llm .generate (prompt_token_ids = requests , sampling_params = sampling_params )
443+ return llm .generate (requests , sampling_params = sampling_params )
441444
442445 # dispatch requests to all self.data_parallel_size workers, in interleaved fashion
443446 # interleaved important to balance context lengths across workers
@@ -455,7 +458,7 @@ def run_inference_one_model(model_args: dict, sampling_params: SamplingParams, r
455458 ]
456459 else :
457460 outputs = self .model .generate (
458- prompt_token_ids = inputs ,
461+ inputs ,
459462 sampling_params = sampling_params ,
460463 use_tqdm = True ,
461464 )
0 commit comments