{
  "chapter": "04-ocr-detection-and-recognition",
  "milestone": "docmind-v0.4",
  "environment": {
    "gpu_name": "NVIDIA L4",
    "gpu_total_mib": 22563.1,
    "pytorch": "2.14.1+cu130",
    "transformers": "4.57.6",
    "typst_python": "0.15.2"
  },
  "lesson_01_and_03_synth_and_ctc": {
    "synthesis_benchmark": {
      "rendered_lines": 4700,
      "elapsed_seconds": 6.67,
      "throughput_lines_per_sec": 704.7,
      "projected_50k_lines_seconds": 70.95,
      "dataset_sha256_prefix": "64768ec402406aad"
    },
    "cjk_font_verified": true,
    "scratch_ctc_math_verification": {
      "forward_loss_abs_err": 0.0,
      "backward_grad_max_abs_err": 1.46e-15
    },
    "charset_hotswap": {
      "old_vocab": 81,
      "new_vocab": 105,
      "preserved_prefix_weight_max_diff": 0.0
    },
    "clean_pretrained_on_distorted_test": {
      "train_seconds": 32.18,
      "peak_vram_mib": 1434.9,
      "cer_pct": 77.38,
      "exact_line_match_pct": 0.0,
      "sample_predictions": [
        {
          "gt": "2026年05月 第25页 公司章表",
          "pred": "20 第页 审核签表"
        },
        {
          "gt": "2026年05月 第17页 公司章表",
          "pred": "合0 元页 公审核章表"
        }
      ]
    },
    "domain_finetuned_on_distorted_test": {
      "train_seconds": 51.16,
      "peak_vram_mib": 1433.3,
      "cer_pct": 0.03,
      "exact_line_match_pct": 99.33,
      "sample_predictions": [
        {
          "gt": "2026年05月 第25页 公司章表",
          "pred": "2026年05月 第25页 公司章表"
        },
        {
          "gt": "2026年05月 第17页 公司章表",
          "pred": "2026年05月 第17页 公司章表"
        }
      ]
    }
  },
  "lesson_02_dbnet_detection": {
    "dataset_sha256_prefix": "28c19f4a283fdb87",
    "db_step_gradient_check": {
      "boundary_grad_at_p_eq_t": 12.5,
      "analytic_grad_max_abs_err": 5.33e-15
    },
    "train_seconds": 65.1,
    "peak_vram_mib": 1458.5,
    "loss_curve": [
      {
        "epoch": 1,
        "joint_loss": 2.5314
      },
      {
        "epoch": 10,
        "joint_loss": 0.2318
      },
      {
        "epoch": 22,
        "joint_loss": 0.1092
      },
      {
        "epoch": 36,
        "joint_loss": 0.0877
      }
    ],
    "epoch1_metrics": {
      "precision_pct": 0.0,
      "recall_pct": 0.0,
      "f1_pct": 0.0
    },
    "finetuned_best_metrics": {
      "unclip_ratio": 1.0,
      "precision_pct": 100.0,
      "recall_pct": 100.0,
      "f1_pct": 100.0
    },
    "unclip_ratio_sweep": [
      {
        "unclip_ratio": 1.0,
        "precision_pct": 100.0,
        "recall_pct": 100.0,
        "f1_pct": 100.0
      },
      {
        "unclip_ratio": 1.4,
        "precision_pct": 100.0,
        "recall_pct": 100.0,
        "f1_pct": 100.0
      },
      {
        "unclip_ratio": 1.8,
        "precision_pct": 100.0,
        "recall_pct": 100.0,
        "f1_pct": 100.0
      },
      {
        "unclip_ratio": 2.2,
        "precision_pct": 100.0,
        "recall_pct": 100.0,
        "f1_pct": 100.0
      },
      {
        "unclip_ratio": 2.8,
        "precision_pct": 89.69,
        "recall_pct": 89.69,
        "f1_pct": 89.69
      }
    ]
  },
  "lesson_04_end2end_typst_ocr": {
    "model_id": "facebook/nougat-small",
    "dataset_sha256_prefix": "0c87f8844bf41ae9",
    "total_params": 247383672,
    "train_cards": 220,
    "test_cards": 40,
    "train_seconds": 475.39,
    "peak_vram_mib": 11111.2,
    "loss_curve": [
      {
        "epoch": 1,
        "train_seq2seq_loss": 0.5048
      },
      {
        "epoch": 5,
        "train_seq2seq_loss": 0.0034
      },
      {
        "epoch": 10,
        "train_seq2seq_loss": 0.0008
      },
      {
        "epoch": 16,
        "train_seq2seq_loss": 0.0
      }
    ],
    "zero_shot_markdown_latex_baseline": {
      "normalized_edit_distance": 0.7219,
      "edit_similarity_pct": 27.81,
      "bleu4_score": 0.82,
      "typst_compile_pass_rate_pct": 0.0,
      "valid_typst_table_and_math_pct": 0.0,
      "sample_prediction": "## Benchmark 5\n\n\\begin{tabular}{|l|l|l|} \\hline Model & mAP50 & Latency \\\\ \\hline YOLOv11n & 0.97 & 8.6ms \\\\ \\hline Qwen3-0.6B & 0.94 & 12.4ms \\\\ \\hline \\end{tabular}\n\n\\[L_{\\rm all",
      "sample_reference": "= Benchmark 5\n#table(columns: 3, [Model], [mAP50], [Latency], [YOLOv11n], [0.97], [8.6ms], [Qwen3-0.6B], [0.94], [12.4ms])\n$ L_\"all\" = alpha L_\"bce\" + beta L_\"dice\" $"
    },
    "finetuned_typst_end2end": {
      "normalized_edit_distance": 0.0,
      "edit_similarity_pct": 100.0,
      "bleu4_score": 100.0,
      "typst_compile_pass_rate_pct": 100.0,
      "valid_typst_table_and_math_pct": 100.0,
      "sample_prediction": "= Benchmark 5\n#table(columns: 3, [Model], [mAP50], [Latency], [YOLOv11n], [0.97], [8.6ms], [Qwen3-0.6B], [0.94], [12.4ms])\n$ L_\"all\" = alpha L_\"bce\" + beta L_\"dice\" $",
      "sample_reference": "= Benchmark 5\n#table(columns: 3, [Model], [mAP50], [Latency], [YOLOv11n], [0.97], [8.6ms], [Qwen3-0.6B], [0.94], [12.4ms])\n$ L_\"all\" = alpha L_\"bce\" + beta L_\"dice\" $"
    }
  }
}
