Views
No views yet

1from vllm import LLM, SamplingParams
2from transformers import AutoTokenizer
3model_name = "AI-MO/Kimina-Prover-Distill-8B"
4model = LLM(model_name)
5tokenizer = AutoTokenizer.from_pretrained(model_name, trust_remote_code=True)
6problem = "The volume of a cone is given by the formula $V = \frac{1}{3}Bh$, where $B$ is the area of the base and $h$ is the height. The area of the base of a cone is 30 square units, and its height is 6.5 units. What is the number of cubic units in its volume?"
7formal_statement = """import Mathlib
8import Aesop
9set_option maxHeartbeats 0
10open BigOperators Real Nat Topology Rat
11/-- The volume of a cone is given by the formula $V = \frac{1}{3}Bh$, where $B$ is the area of the base and $h$ is the height. The area of the base of a cone is 30 square units, and its height is 6.5 units. What is the number of cubic units in its volume? Show that it is 65.-/
12theorem mathd_algebra_478 (b h v : ℝ) (h₀ : 0 < b ∧ 0 < h ∧ 0 < v) (h₁ : v = 1 / 3 * (b * h))
13 (h₂ : b = 30) (h₃ : h = 13 / 2) : v = 65 := by
14"""
15prompt = "Think about and solve the following problem step by step in Lean 4."
16prompt += f"\n# Problem:{problem}"""
17prompt += f"\n# Formal statement:\n```lean4\n{formal_statement}\n```\n"
18messages = [
19 {"role": "system", "content": "You are an expert in mathematics and Lean 4."},
20 {"role": "user", "content": prompt}
21]
22text = tokenizer.apply_chat_template(
23 messages,
24 tokenize=False,
25 add_generation_prompt=True
26)
27sampling_params = SamplingParams(temperature=0.6, top_p=0.95, max_tokens=8096)
28output = model.generate(text, sampling_params=sampling_params)
29output_text = output[0].outputs[0].text
30print(output_text)