GeorgyGUF commited on
Commit
ea0f56c
·
verified ·
1 Parent(s): 3b6ead2

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +173 -0
README.md ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: gguf
3
+ ---
4
+ <!-- markdownlint-disable first-line-h1 -->
5
+ <!-- markdownlint-disable html -->
6
+ <!-- markdownlint-disable no-duplicate-header -->
7
+
8
+ <div align="center">
9
+ <img src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/logo.svg?raw=true" width="60%" alt="DeepSeek-V3" />
10
+ </div>
11
+ <hr>
12
+ <div align="center" style="line-height: 1;">
13
+ <a href="https://www.deepseek.com/" target="_blank" style="margin: 2px;">
14
+ <img alt="Homepage" src="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/badge.svg?raw=true" style="display: inline-block; vertical-align: middle;"/>
15
+ </a>
16
+ <a href="https://chat.deepseek.com/" target="_blank" style="margin: 2px;">
17
+ <img alt="Chat" src="https://img.shields.io/badge/🤖%20Chat-DeepSeek%20V3-536af5?color=536af5&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
18
+ </a>
19
+ <a href="https://huggingface.co/deepseek-ai" target="_blank" style="margin: 2px;">
20
+ <img alt="Hugging Face" src="https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-DeepSeek%20AI-ffc107?color=ffc107&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
21
+ </a>
22
+ </div>
23
+
24
+ <div align="center" style="line-height: 1;">
25
+ <a href="https://discord.gg/Tc7c45Zzu5" target="_blank" style="margin: 2px;">
26
+ <img alt="Discord" src="https://img.shields.io/badge/Discord-DeepSeek%20AI-7289da?logo=discord&logoColor=white&color=7289da" style="display: inline-block; vertical-align: middle;"/>
27
+ </a>
28
+ <a href="https://github.com/deepseek-ai/DeepSeek-V2/blob/main/figures/qr.jpeg?raw=true" target="_blank" style="margin: 2px;">
29
+ <img alt="Wechat" src="https://img.shields.io/badge/WeChat-DeepSeek%20AI-brightgreen?logo=wechat&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
30
+ </a>
31
+ <a href="https://twitter.com/deepseek_ai" target="_blank" style="margin: 2px;">
32
+ <img alt="Twitter Follow" src="https://img.shields.io/badge/Twitter-deepseek_ai-white?logo=x&logoColor=white" style="display: inline-block; vertical-align: middle;"/>
33
+ </a>
34
+ </div>
35
+
36
+ <div align="center" style="line-height: 1;">
37
+ <a href="https://github.com/deepseek-ai/DeepSeek-V3/blob/main/LICENSE-CODE" style="margin: 2px;">
38
+ <img alt="Code License" src="https://img.shields.io/badge/Code_License-MIT-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
39
+ </a>
40
+ <a href="https://github.com/deepseek-ai/DeepSeek-V3/blob/main/LICENSE-MODEL" style="margin: 2px;">
41
+ <img alt="Model License" src="https://img.shields.io/badge/Model_License-Model_Agreement-f5de53?&color=f5de53" style="display: inline-block; vertical-align: middle;"/>
42
+ </a>
43
+ </div>
44
+
45
+ ## 1. Introduction
46
+
47
+ We introduce DeepSeek-Prover-V2, an open-source large language model designed for formal theorem proving in Lean 4, with initialization data collected through a recursive theorem proving pipeline powered by DeepSeek-V3. The cold-start training procedure begins by prompting DeepSeek-V3 to decompose complex problems into a series of subgoals. The proofs of resolved subgoals are synthesized into a chain-of-thought process, combined with DeepSeek-V3's step-by-step reasoning, to create an initial cold start for reinforcement learning. This process enables us to integrate both informal and formal mathematical reasoning into a unified model.
48
+
49
+ <p align="center">
50
+ <img width="100%" src="https://github.com/deepseek-ai/DeepSeek-Prover-V2/blob/main/figures/performance.png?raw=true">
51
+ </p>
52
+
53
+ ## 2. Model Summary
54
+
55
+ ---
56
+
57
+ **Synthesize Cold-Start Reasoning Data through Recursive Proof Search**
58
+
59
+ - To construct the cold-start dataset, we develop a simple yet effective pipeline for recursive theorem proving, utilizing DeepSeek-V3 as a unified tool for both subgoal decomposition and formalization. We prompt DeepSeek-V3 to decompose theorems into high-level proof sketches while simultaneously formalizing these proof steps in Lean 4, resulting in a sequence of subgoals.
60
+
61
+ - We use a smaller 7B model to handle the proof search for each subgoal, thereby reducing the associated computational burden. Once the decomposed steps of a challenging problem are resolved, we pair the complete step-by-step formal proof with the corresponding chain-of-thought from DeepSeek-V3 to create cold-start reasoning data.
62
+
63
+ ---
64
+
65
+ **Reinforcement Learning with Synthetic Cold-Start Data**
66
+
67
+ - We curate a subset of challenging problems that remain unsolved by the 7B prover model in an end-to-end manner, but for which all decomposed subgoals have been successfully resolved. By composing the proofs of all subgoals, we construct a complete formal proof for the original problem. This proof is then appended to DeepSeek-V3's chain-of-thought, which outlines the corresponding lemma decomposition, thereby producing a cohesive synthesis of informal reasoning and subsequent formalization.
68
+
69
+ - After fine-tuning the prover model on the synthetic cold-start data, we perform a reinforcement learning stage to further enhance its ability to bridge informal reasoning with formal proof construction. Following the standard training objective for reasoning models, we use binary correct-or-incorrect feedback as the primary form of reward supervision.
70
+ - The resulting model, DeepSeek-Prover-V2-671B, achieves state-of-the-art performance in neural theorem proving, reaching $88.9$% pass ratio on the MiniF2F-test and solving 49 out of 658 problems from PutnamBench. The proofs generated by DeepSeek-Prover-V2 for the miniF2F dataset are available for download as a [ZIP archive](https://github.com/deepseek-ai/DeepSeek-Prover-V2/blob/master/minif2f-solutions.zip).
71
+
72
+ ---
73
+
74
+ ## 3. ProverBench: Formalization of AIME and Textbook Problems
75
+
76
+ we introduce ProverBench, a benchmark dataset comprising 325 problems. Of these, 15 are formalized from number theory and algebra questions featured in the recent AIME competitions (AIME 24 and 25), offering authentic high-school competition-level challenges. The remaining 310 problems are drawn from curated textbook examples and educational tutorials, contributing a diverse and pedagogically grounded collection of formalized mathematical problems. This benchmark is designed to enable more comprehensive evaluation across both high-school competition problems and undergraduate-level mathematics.
77
+
78
+ <div align="center">
79
+
80
+ | Area | Count |
81
+ | :---------------------: | :-------: |
82
+ | AIME 24&25 | 15 |
83
+ | Number Theory | 40 |
84
+ | Elementary Algebra | 30 |
85
+ | Linear Algebra | 50 |
86
+ | Abstract Algebra | 40 |
87
+ | Calculus | 90 |
88
+ | Real Analysis | 30 |
89
+ | Complex Analysis | 10 |
90
+ | Functional Analysis | 10 |
91
+ | Probability | 10 |
92
+ | Total | 325 |
93
+
94
+ </div>
95
+
96
+ ## 4. Model & Dataset Downloads
97
+
98
+ We release DeepSeek-Prover-V2 in two model sizes: 7B and 671B parameters. DeepSeek-Prover-V2-671B is trained on top of DeepSeek-V3-Base. DeepSeek-Prover-V2-7B is built upon DeepSeek-Prover-V1.5-Base and features an extended context length of up to 32K tokens.
99
+
100
+ <div align="center">
101
+
102
+ | **Model** | **Download** |
103
+ | :-----------------------------: | :----------------------------------------------------------: |
104
+ | DeepSeek-Prover-V2-7B | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Prover-V2-7B) |
105
+ | DeepSeek-Prover-V2-671B | [🤗 HuggingFace](https://huggingface.co/deepseek-ai/DeepSeek-Prover-V2-671B) |
106
+
107
+ </div>
108
+
109
+ <div align="center">
110
+
111
+ | **Dataset** | **Download** |
112
+ | :-----------------------------: | :----------------------------------------------------------: |
113
+ | DeepSeek-ProverBench | [🤗 HuggingFace](https://huggingface.co/datasets/deepseek-ai/DeepSeek-ProverBench) |
114
+
115
+ </div>
116
+
117
+ ## 5. Quick Start
118
+
119
+ You can directly use [Huggingface's Transformers](https://github.com/huggingface/transformers) for model inference. DeepSeek-Prover-V2-671B shares the same architecture as DeepSeek-V3. For detailed information and supported features, please refer to [the DeepSeek-V3 documentation on Hugging Face](https://github.com/huggingface/transformers/blob/main/docs/source/en/model_doc/deepseek_v3.md).
120
+
121
+ The following is a basic example of generating a proof for a problem from the miniF2F dataset:
122
+ ````python
123
+ from transformers import AutoModelForCausalLM, AutoTokenizer
124
+ import torch
125
+ torch.manual_seed(30)
126
+
127
+ model_id = "DeepSeek-Prover-V2-7B" # or DeepSeek-Prover-V2-671B
128
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
129
+
130
+ formal_statement = """
131
+ import Mathlib
132
+ import Aesop
133
+
134
+ set_option maxHeartbeats 0
135
+
136
+ open BigOperators Real Nat Topology Rat
137
+
138
+ /-- What is the positive difference between $120\%$ of 30 and $130\%$ of 20? Show that it is 10.-/
139
+ theorem mathd_algebra_10 : abs ((120 : ℝ) / 100 * 30 - 130 / 100 * 20) = 10 := by
140
+ sorry
141
+ """.strip()
142
+
143
+ prompt = """
144
+ Complete the following Lean 4 code:
145
+
146
+ ```lean4
147
+ {}
148
+ ```
149
+
150
+ Before producing the Lean 4 code to formally prove the given theorem, provide a detailed proof plan outlining the main proof steps and strategies.
151
+ The plan should highlight key ideas, intermediate lemmas, and proof structures that will guide the construction of the final formal proof.
152
+ """.strip()
153
+
154
+ chat = [
155
+ {"role": "user", "content": prompt.format(formal_statement)},
156
+ ]
157
+
158
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", torch_dtype=torch.bfloat16, trust_remote_code=True)
159
+ inputs = tokenizer.apply_chat_template(chat, tokenize=True, add_generation_prompt=True, return_tensors="pt").to(model.device)
160
+
161
+ import time
162
+ start = time.time()
163
+ outputs = model.generate(inputs, max_new_tokens=8192)
164
+ print(tokenizer.batch_decode(outputs))
165
+ print(time.time() - start)
166
+ ````
167
+
168
+ ## 6. License
169
+ The use of DeepSeek-Prover-V2 models is subject to [the Model License](LICENSE-MODEL).
170
+
171
+ ## 7. Contact
172
+
173
+ If you have any questions, please raise an issue or contact us at [[email protected]](mailto:[email protected]).