from transformers import Qwen3VLMoeForConditionalGeneration, AutoProcessorfrom PIL import Image model_name = "PRIME-RL/P1-VL-30B-A3B" # Load model and processormodel = Qwen3VLMoeForConditionalGeneration.from_pretrained( model_name, dtype="auto", device_map="auto")processor = AutoProcessor.from_pretrained(model_name) # Load diagram imageimage = Image.open("physics_diagram.png") # Physics problem with visual inputmessages = [ { "role": "user", "content": [ { "type": "image", "image": image, }, { "type": "text", "text": """Analyze this physics diagram and solve the problem: A block of mass m is placed on an inclined plane with angle θ.The coefficient of kinetic friction is μ.Calculate the acceleration of the block down the incline.""", }, ], }] # Preparation for inferenceinputs = processor.apply_chat_template( messages, tokenize=True, add_generation_prompt=True, return_dict=True, return_tensors="pt") # Inference: Generation of the outputgenerated_ids = model.generate(**inputs, max_new_tokens=8192)generated_ids_trimmed = [ out_ids[len(in_ids) :] for in_ids, out_ids in zip(inputs.input_ids, generated_ids)]output_text = processor.batch_decode( generated_ids_trimmed, skip_special_tokens=True, clean_up_tokenization_spaces=False)print(output_text[0])