Skip to content

Commit 3bf5c71

Browse files
committed
update README
1 parent 072df41 commit 3bf5c71

File tree

2 files changed

+69
-57
lines changed

2 files changed

+69
-57
lines changed

README.md

Lines changed: 68 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ LeanDojo-v2 is an end-to-end framework for training, evaluating, and deploying A
1212
4. [Requirements](#requirements)
1313
5. [Installation](#installation)
1414
6. [Environment Setup](#environment-setup)
15-
7. [Quick Start](#quickstart)
15+
7. [Quick Start](#quick-start)
1616
8. [Working with Agents and Trainers](#working-with-agents-and-trainers)
1717
9. [Tracing and Dataset Generation](#tracing-and-dataset-generation)
18-
10. [External APIs and LeanCopilot](#external-apis-and-leancopilot)
18+
10. [LeanProgress Step-Prediction](#leanprogress-step-prediction)
1919
11. [Testing](#testing)
2020
12. [Troubleshooting & Tips](#troubleshooting--tips)
2121
13. [Contributing](#contributing)
@@ -113,13 +113,15 @@ pip install torch torchvision torchaudio --index-url https://download.pytorch.or
113113

114114
1. **GitHub Access Token (required)**
115115
The tracing pipeline calls the GitHub API extensively. Create a personal access token and export it before running any agent:
116+
116117
```sh
117-
export GITHUB_ACCESS_TOKEN=<your-token>
118+
export GITHUB_ACCESS_TOKEN=<token>
118119
```
119120

120121
2. **Hugging Face Token (optional but needed for gated models)**
122+
121123
```sh
122-
export HF_TOKEN=<your-hf-token>
124+
export HF_TOKEN=<hf-token>
123125
```
124126

125127
3. **Working directories**
@@ -160,32 +162,6 @@ This example:
160162
3. Fine-tunes the specified Hugging Face model (optionally with LoRA).
161163
4. Launches an `HFProver` backed by Pantograph to search for proofs.
162164

163-
---
164-
165-
## Working with Agents and Trainers
166-
167-
### Supervised Fine-Tuning (`SFTTrainer`)
168-
169-
- Accepts any Hugging Face causal LM identifier.
170-
- Supports LoRA by passing a `peft.LoraConfig`.
171-
- Key arguments: `epochs_per_repo`, `batch_size`, `max_seq_len`, `lr`, `warmup_steps`, `gradient_checkpointing`.
172-
- Produces checkpoints under `output_dir` that the `HFProver` consumes.
173-
174-
### GRPO Trainer (`GRPOTrainer`)
175-
176-
- Implements Group Relative Policy Optimization for reinforcement-style refinement.
177-
- Accepts `reference_model`, `reward_weights`, and `kl_beta` settings.
178-
- Useful for improving search policies on curated theorem batches.
179-
180-
### Retrieval Trainer & LeanAgent
181-
182-
- `RetrievalTrainer` trains the dense retriever that scores prior proofs.
183-
- `LeanAgent` wraps the trainer, maintains repository curricula, and couples it with `RetrievalProver`.
184-
185-
Each agent inherits `BaseAgent`, so you can implement your own by overriding `_get_build_deps()` and `_setup_prover()` to register new trainer/prover pairs.
186-
187-
---
188-
189165
## Tracing and Dataset Generation
190166

191167
The `lean_dojo_v2/lean_dojo/data_extraction` package powers repository tracing:
@@ -215,43 +191,81 @@ database.setup_github_repository(
215191

216192
The generated artifacts flow into the `DynamicDatabase`, which keeps repositories sorted by difficulty and appends new sorrys without retracing everything.
217193

218-
---
194+
## Working with Agents and Trainers
195+
196+
### Supervised Fine-Tuning (`SFTTrainer`)
197+
198+
- Accepts any Hugging Face causal LM identifier.
199+
- Supports LoRA by passing a `peft.LoraConfig`.
200+
- Key arguments: `epochs_per_repo`, `batch_size`, `max_seq_len`, `lr`, `warmup_steps`, `gradient_checkpointing`.
201+
- Produces checkpoints under `output_dir` that the `HFProver` consumes.
219202

220-
## External APIs and LeanCopilot
203+
### GRPO Trainer (`GRPOTrainer`)
221204

222-
`lean_dojo_v2/external_api` contains Lean and Python code to expose models through LeanCopilot:
205+
- Implements Group Relative Policy Optimization for reinforcement-style refinement.
206+
- Accepts `reference_model`, `reward_weights`, and `kl_beta` settings.
207+
- Useful for improving search policies on curated theorem batches.
223208

224-
- `LeanCopilot.lean` registers RPC endpoints inside Lean.
225-
- `python/server.py` hosts a FastAPI service with adapters for Anthropic, OpenAI, Google Generative AI, vLLM, and custom HF models.
226-
- Start the service with:
227-
```sh
228-
cd lean_dojo_v2/external_api/python
229-
pip install -r requirements.txt
230-
uvicorn server:app --port 23337
231-
```
232-
- Point your Lean client to the running server to interactively request tactics, proofs, or completions from external models.
209+
### Retrieval Trainer & LeanAgent
233210

234-
### LeanProgress Step-Prediction Workflow
211+
- `RetrievalTrainer` trains the dense retriever that scores prior proofs.
212+
- `LeanAgent` wraps the trainer, maintains repository curricula, and couples it with `RetrievalProver`.
213+
214+
Each agent inherits `BaseAgent`, so you can implement your own by overriding `_get_build_deps()` and `_setup_prover()` to register new trainer/prover pairs.
215+
216+
## LeanProgress Step-Prediction
235217

236218
- Generate a JSONL dataset with remaining-step targets (or replace it with your own LeanProgress export):
219+
237220
```sh
238221
python -m lean_dojo_v2.lean_progress.create_sample_dataset --output raid/data/sample_leanprogress_dataset.jsonl
239222
```
223+
240224
- Fine-tune a regression head that predicts `steps_remaining`:
241-
```sh
242-
python -m lean_dojo_v2.lean_progress.train_steps_model \
243-
--dataset raid/data/sample_leanprogress_dataset.jsonl \
244-
--output-dir raid/checkpoints/leanprogress_steps \
245-
--model-name bert-base-uncased
225+
226+
```python
227+
from pathlib import Path
228+
229+
from lean_dojo_v2.trainer.progress_trainer import ProgressTrainer
230+
231+
sample_dataset_path = Path("raid/data/sample_leanprogress_dataset.jsonl")
232+
233+
trainer = ProgressTrainer(
234+
model_name="bert-base-uncased",
235+
data_path=str(sample_dataset_path),
236+
output_dir="outputs-progress",
237+
)
238+
239+
trainer.train()
246240
```
247-
- Tell the LeanCopilot server where to find the checkpoint by exporting:
248-
```sh
249-
export LEANPROGRESS_MODEL=raid/checkpoints/leanprogress_steps
250-
uvicorn server:app --port 23337
241+
242+
## Proving Theorems
243+
244+
LeanDojo-v2 supports two methods for theorem proving:
245+
246+
- **Whole-proof generation**: generate complete proof in one forward pass of the prover.
247+
248+
```python
249+
from lean_dojo_v2.prover import ExternalProver
250+
251+
theorem = "theorem my_and_comm : ∀ {p q : Prop}, And p q → And q p := by"
252+
prover = ExternalProver()
253+
proof = prover.generate_whole_proof(theorem)
251254
```
252-
- Add `use_reward=true` when calling `/generate`. Each output now includes `steps_remaining` and a reward value (currently `-steps_remaining`) so agents can minimize proof length.
253255

254-
---
256+
- **Proof search**: generate tactics sequentially and update the goal state through interaction with Pantograph until the proof is complete.
257+
258+
```python
259+
from pantograph.server import Server
260+
from lean_dojo_v2.prover import HFProver
261+
262+
server = Server()
263+
prover = HFProver(ckpt_path="outputs-deepseek")
264+
265+
result, used_tactics = prover.search(
266+
server=server, goal="∀ {p q : Prop}, p ∧ q → q ∧ p", verbose=False
267+
)
268+
```
255269

256270
## Testing
257271

@@ -264,8 +278,6 @@ export HF_TOKEN=<hf-token> # only required for tests touching HF APIs
264278
pytest -v
265279
```
266280

267-
---
268-
269281
## Troubleshooting & Tips
270282

271283
- **401 Bad Credentials / rate limits**: Ensure `GITHUB_ACCESS_TOKEN` is exported and has `repo` + `read:org` scopes.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "lean-dojo-v2"
7-
version = "1.0.3"
7+
version = "1.0.4"
88
description = "A comprehensive library for AI-assisted theorem proving in Lean"
99
readme = "README.md"
1010
license = {text = "MIT"}

0 commit comments

Comments
 (0)