Phi3V Example
Source vllm-project/vllm.
1from vllm import LLM, SamplingParams2from vllm.assets.image import ImageAsset345def run_phi3v():6 model_path = "microsoft/Phi-3-vision-128k-instruct"78 # Note: The default setting of max_num_seqs (256) and9 # max_model_len (128k) for this model may cause OOM.10 # You may lower either to run this example on lower-end GPUs.1112 # In this example, we override max_num_seqs to 5 while13 # keeping the original context length of 128k.14 llm = LLM(15 model=model_path,16 trust_remote_code=True,17 max_num_seqs=5,18 )1920 image = ImageAsset("cherry_blossom").pil_image2122 # single-image prompt23 prompt = "<|user|>\n<|image_1|>\nWhat is the season?<|end|>\n<|assistant|>\n" # noqa: E50124 sampling_params = SamplingParams(temperature=0, max_tokens=64)2526 outputs = llm.generate(27 {28 "prompt": prompt,29 "multi_modal_data": {30 "image": image31 },32 },33 sampling_params=sampling_params)34 for o in outputs:35 generated_text = o.outputs[0].text36 print(generated_text)373839if __name__ == "__main__":40 run_phi3v()