Beyond physics reasoning, P1 improves across multiple domains. As shown below, P1-30B-A3B outperforms its base model Qwen3-30B-A3B-Thinking-2507 on math, coding, and STEM benchmarks, demonstrating strong generalization of physics reasoning.
1from transformers import AutoModelForCausalLM, AutoTokenizer
2import torch
3
4# Load model and tokenizer
5model_name = "P1-30B-A3B"
6tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 trust_remote_code=True
12)
13
14# Physics problem solving
15prompt = """Solve this physics problem:
16
17A pendulum of length L = 1.0 m swings with small amplitude.
18Calculate the period of oscillation and explain your reasoning.
19
20Use g = 9.8 m/s²"""
21
22inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
23outputs = model.generate(
24 **inputs,
25 max_length=81920,
26 temperature=0.6,
27 top_p=0.9,
28 do_sample=True
29)
30
31solution = tokenizer.decode(outputs[0], skip_special_tokens=True)
32print(solution)
We are grateful to the open-source community for their invaluable contributions. Special thanks to:
1@misc{p1-2025,
2 title={P1: Mastering Physics Olympiads with Reinforcement Learning},
3 author={P1 Team},
4 year={2025},
5 url={https://prime-rl.github.io/P1/}
6}