DeepSeekMath-V2 Documentation

repository·main·Indexed 23 days ago

https://github.com/deepseek-ai/deepseek-math-v2

A large language model for self-verifiable mathematical reasoning and theorem proving, built on DeepSeek-V3.2-Exp-Base. It features a verifier-based reward model and a multi-round iterative pipeline for proof generation, verification, meta-verification, and refinement.

Tokens
1K
Snippets
1
Records
6
Agent score
32%

What's inside DeepSeekMath-V2

  1. Understand the Proof Refinement mechanism

    main

    Proof refinement is the core mechanism for iterative improvement. It works by:

    1. Pooling: Storing proofs in a proof_pool_dirname indexed by problem ID.
    2. Selection: Selecting the n_best_proofs_to_sample based on their meanscore and self_eval_score.
    3. Combination: Creating new prompts that present multiple existing solutions (and their corresponding evaluations) to the model, asking it to refine them.
    4. Dependency Tracking: The system tracks dep_proof_ids to maintain a lineage of how proofs evolve across rounds.

    This process allows the model to learn from the best available reasoning paths discovered in previous rounds.

  2. Run the DeepSeekMath-V2 inference and verification pipeline

    main

    The main.py script implements a multi-round iterative process for mathematical reasoning, consisting of proof generation, proof verification, meta-verification, and proof refinement.

    Pipeline Workflow

    1. Round 1 (Initialization): Loads raw data from --input_paths, applies a proof_generation template, and runs inference to generate initial proofs.
    2. Proof Verification: Evaluates generated proofs using a proof_verification template.
    3. Meta-Verification: (Optional) Uses a meta_verification template to rate the quality of the verification results.
    4. Proof Refinement: Aggregates high-quality proofs into a pool and creates new prompts for the next round by combining multiple proofs and their evaluations.
    5. Iterative Rounds: Repeats the process for up to --max_rounds.

    Required CLI Arguments

    • --input_paths: Comma-separated list of paths to input data (JSON or JSONL).
    • --output_dirname: Directory where all round results and intermediate files will be stored.
    • --proof_pool_dirname: Directory to maintain a persistent pool of generated proofs for each problem.

    Key Configuration Options

    • --batch_size: Number of items per batch (default: 160).
    • --proof_gen_temp / --proof_verification_temp / --meta_verification_temp: Temperature for the respective inference stages.
    • --n_agg_trials: Number of different combinations of proofs used for refinements (default: 32).
    • --n_best_proofs_to_sample: Number of top-performing proofs to consider for refinement (default: 32).
    • --n_proofs_to_refine: Number of proofs to include in a single refinement prompt (default: 1).
    • --skip_meta_verification: If set, skips the meta-verification stage.
  3. Configure Proof Generation and Verification parameters

    main

    The pipeline uses several templates and hyperparameters to control the behavior of the LLM during different stages. These are passed to the underlying generate.py script via system calls.

    Proof Generation

    • --proof_gen_template: The template used for generating proofs (default: proof_generation).
    • --proof_gen_max_len: Maximum token length for generation (default: 128 * 1024).
    • --proof_gen_num_processes: Number of parallel processes for generation (default: 40).

    Proof Verification

    • --proof_verification_template: The template used for verifying proofs (default: proof_verification).
    • --proof_verification_max_len: Maximum token length for verification (default: 64 * 1024).
    • --n_verification_per_proof: Number of verification samples to generate per proof (default: 4).

    Meta-Verification

    • --meta_verification_template: The template used for meta-rating (default: meta_verification).
    • --meta_verification_max_len: Maximum token length (default: 64 * 1024).
    • --n_meta_verification_per_rating: Number of meta-verification samples per rating (default: 1).