LeanProgress is a regression model fine-tuned on proof states that predicts how many tactic steps remain before a proof is complete. By assigning aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/lean-dojo/LeanDojo-v2/llms.txt
Use this file to discover all available pages before exploring further.
steps_remaining score to each candidate tactic, LeanProgress transforms open-ended proof search into a guided process — the prover can prioritize paths that are predicted to terminate sooner, reducing wasted compute on dead ends. The model is fine-tuned on top of any HuggingFace encoder (e.g., bert-base-uncased) with a single scalar regression head using MSE loss.
Two-Step Workflow
Generate a training dataset
The The command creates the output directory if it does not exist and writes three illustrative examples:Each JSONL record has four fields:
create_sample_dataset module produces a JSONL file where each record describes a proof state together with its steps_remaining target. For a quick smoke-test, use the built-in sample generator:| Field | Type | Description |
|---|---|---|
goal | string | The Lean proof state (hypotheses + goal). |
prefix | string | Optional proof prefix already written before this tactic. |
tactic | string | Candidate tactic being evaluated. |
steps_remaining | int ≥ 0 | Target label: 0 means the tactic closes the goal. |
ProgressTrainer Details
ProgressTrainer wraps the HuggingFace Trainer API with sensible defaults for the regression task:
ProgressTrainer:
- Loads the JSONL file into a HuggingFace
DatasetviaProgressDataset. - Splits data into train and eval sets (default 80 / 20).
- Tokenizes each example by concatenating
goal,prefix, andtacticinto a single prompt: - Initializes
AutoModelForSequenceClassificationwithnum_labels=1andproblem_type="regression"— this adds a single linear head on top of the encoder’s[CLS]representation. - Trains with MSE loss, evaluating on both MSE and MAE after every epoch. The best checkpoint (lowest eval MSE) is loaded at the end.
- Saves the model and tokenizer to
output_dir.
Supported ProgressDataset formats
Supported ProgressDataset formats
ProgressDataset accepts a JSONL file produced by create_sample_dataset.py. Each line must be a JSON object with at minimum goal, tactic, and steps_remaining keys. The prefix key is optional and defaults to an empty string if absent.Command-Line Training Script
For automated pipelines or hyperparameter sweeps, usetrain_steps_model.py directly:
| Argument | Default | Description |
|---|---|---|
--dataset | (required) | Path to the JSONL training file. |
--output-dir | (required) | Directory to save the fine-tuned model. |
--model-name | bert-base-uncased | HuggingFace encoder model identifier. |
--max-length | 512 | Maximum token length per example. |
--batch-size | 8 | Per-device train and eval batch size. |
--epochs | 3.0 | Number of training epochs. |
--learning-rate | 1e-5 | AdamW learning rate. |
--eval-ratio | 0.2 | Fraction of data used for evaluation. |
--seed | 42 | Random seed for reproducibility. |
Using the Trained Model
In custom proof-search loops
After training, loadLeanProgressScorer from leanprogress.py to score candidate tactics at inference time:
LeanProgressScorer.predict returns a non-negative float. A prediction near 0.0 signals that the tactic is likely to close the goal. Use reward = -steps_remaining to turn this into a maximisation objective compatible with GRPO-style RL training.
Via the External API server
ExportLEANPROGRESS_MODEL before starting the server to attach the scorer to every model bundle:
"use_reward": true in /generate requests to receive per-tactic steps_remaining and reward values alongside the generated tactics. See the External API guide for full endpoint documentation.
LeanProgressScorer uses a custom PromptTemplate to render inputs. If you fine-tune on a dataset that uses a different input format, pass template as a Python format string with {goal}, {tactic}, and {prefix} placeholders when instantiating LeanProgressScorer — the scorer and trainer will then use the same text format.