Add comprehensive empirical curation audit README card
Browse files
README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# FinetuningExps — Pure 16-Bit Dual-GPU ManimCE LLM Fine-Tuning & Compiler-Aligned Post-Training
|
| 2 |
+
|
| 3 |
+
[](https://huggingface.co/datasets/PRB1/ManimCE-Master-SFT)
|
| 4 |
+
[](https://huggingface.co/datasets/PRB1/ManimCE-Master-DPO)
|
| 5 |
+
[](https://huggingface.co/PRB1/Qwen2.5-Coder-7B-ManimCE-SFT-16bit)
|
| 6 |
+
[](https://huggingface.co/PRB1/Qwen2.5-Coder-7B-ManimCE-DPO-16bit)
|
| 7 |
+
|
| 8 |
+
An end-to-end, from-scratch **Pure 16-Bit (`torch.float16`) Dual-GPU Supervised Fine-Tuning (SFT) + Adapter-Reference Direct Preference Optimization (DPO) + Renderer-in-the-Loop (RITL)** framework engineered to train open-weight code LLMs (`Qwen/Qwen2.5-Coder-7B-Instruct`) to excel at **Manim Community Edition (`ManimCE v0.19+`)** mathematical animation generation on free Kaggle `GPU T4 x2` (`32 GB VRAM`) hardware—**with zero 4-bit quantization degradation**.
|
| 9 |
+
|
| 10 |
+
---
|
| 11 |
+
|
| 12 |
+
## Repository Version Branches
|
| 13 |
+
|
| 14 |
+
This repository is organized into progressive versioned release branches, each containing its own dedicated technical `README.md`:
|
| 15 |
+
|
| 16 |
+
| Branch | Milestone / Scope | Dedicated Documentation |
|
| 17 |
+
| :--- | :--- | :--- |
|
| 18 |
+
| **`v1.0-data-pipeline`** | Multi-source public dataset ingestion, AST verification, ManimCE v0.19+ canonicalizer, prompt-code alignment filter, and DPO/RITL pair synthesis. | [`docs/branches/README_v1_data.md`](docs/branches/README_v1_data.md) |
|
| 19 |
+
| **`v2.0-sft-16bit-engine`** | From-scratch Pure 16-Bit (`FP16`) Dual-T4 GPU `rsLoRA` ($r=64, \alpha=64$) SFT trainer with completion-only loss masking, `NEFTune` ($\alpha=5.0$), and fault-tolerant HF Hub checkpointing. | [`docs/branches/README_v2_sft.md`](docs/branches/README_v2_sft.md) |
|
| 20 |
+
| **`v3.0-dpo-compiler-alignment`** | Zero-memory-overhead 16-bit Adapter-Reference `DPO` + `RPO-NLL` alignment engine eliminating legacy `ManimGL`/v0.14 hallucinations and layout overlap. | [`docs/branches/README_v3_dpo.md`](docs/branches/README_v3_dpo.md) |
|
| 21 |
+
| **`v4.0-kaggle-automation-and-eval`** | Automated Kaggle GPU kernel deployment (`priyadharsanbalaji18/manimce-qwen25-coder-7b-16bit-sft-dpo`), 1-turn `RITL` self-repair agent, and held-out `ManimBench-v1` / `autoresearch-manim` evaluation suite. | [`docs/branches/README_v4_kaggle_eval.md`](docs/branches/README_v4_kaggle_eval.md) |
|
| 22 |
+
| **`main`** | Complete unified production codebase integrating all four stages. | This document (`README.md`) |
|
| 23 |
+
|
| 24 |
+
---
|
| 25 |
+
|
| 26 |
+
## 1. End-to-End Architecture
|
| 27 |
+
|
| 28 |
+
```mermaid
|
| 29 |
+
flowchart TD
|
| 30 |
+
subgraph P1["Phase 1: AST & Alignment Data Curation (v1.0-data-pipeline)"]
|
| 31 |
+
D1["68,239 Raw Rows Across 13+ Public HF Datasets"] --> D2["AST Parser + ManimCE v0.19+ Canonicalizer"]
|
| 32 |
+
D2 --> D3["Prompt-Code Semantic Alignment & Contradiction Filter"]
|
| 33 |
+
D3 --> D4["SHA-256 Deduplication & Zero-Leakage Split Isolation"]
|
| 34 |
+
D4 --> D5["PRB1/ManimCE-Master-SFT (24,033 Train / 500 Val / 159 Test)\n& PRB1/ManimCE-Master-DPO (2,623 Train / 138 Val)"]
|
| 35 |
+
end
|
| 36 |
+
|
| 37 |
+
subgraph P2["Phase 2: Pure 16-Bit Dual-GPU SFT (v2.0-sft-16bit-engine)"]
|
| 38 |
+
D5 --> S1["Qwen2.5-Coder-7B-Instruct in Native FP16 Across 2x T4 (32GB VRAM)"]
|
| 39 |
+
S1 --> S2["High-Rank rsLoRA (r=64, alpha=64) + Completion-Only Masking + NEFTune"]
|
| 40 |
+
S2 --> S3["Live Checkpointing -> PRB1/Qwen2.5-Coder-7B-ManimCE-SFT-16bit"]
|
| 41 |
+
end
|
| 42 |
+
|
| 43 |
+
subgraph P3["Phase 3: 16-Bit Compiler-Aligned DPO (v3.0-dpo-compiler-alignment)"]
|
| 44 |
+
S3 --> A1["In-Memory 16-Bit Merge (Stage-1 Backbone = pi_ref, 0 Extra VRAM)"]
|
| 45 |
+
A1 --> A2["RPO-Stabilized DPO (beta=0.1, lambda_NLL=0.1) vs. Legacy APIs & Bugs"]
|
| 46 |
+
A2 --> A3["Aligned Model -> PRB1/Qwen2.5-Coder-7B-ManimCE-DPO-16bit"]
|
| 47 |
+
end
|
| 48 |
+
|
| 49 |
+
subgraph P4["Phase 4: RITL Self-Repair & ManimBench Eval (v4.0-kaggle-automation-and-eval)"]
|
| 50 |
+
A3 --> E1["Pass@1 Generation + Static AST / Headless ManimCE Verification"]
|
| 51 |
+
E1 --> E2["Pass@2 1-Turn Compiler Traceback Self-Repair (RITL)"]
|
| 52 |
+
end
|
| 53 |
+
```
|
| 54 |
+
|
| 55 |
+
---
|
| 56 |
+
|
| 57 |
+
## 2. Empirical Dataset Curation & Sanitization Audit (`data/curation_audit_report.json`)
|
| 58 |
+
|
| 59 |
+
Our automated audit of **68,239 raw rows** across public Hugging Face Manim datasets revealed massive syntax corruption (`>23,000` invalid Python ASTs), row-shuffled prompt-code misalignments, and legacy `ManimGL` (`manimlib`) contamination. Below is the exact breakdown produced by `src/data_pipeline/build_master_dataset.py`:
|
| 60 |
+
|
| 61 |
+
| Public Dataset Source | Raw Rows | AST Valid | Aligned | Deduplicated Kept | Key Rejection / Sanitization Reasons |
|
| 62 |
+
| :--- | :---: | :---: | :---: | :---: | :--- |
|
| 63 |
+
| `sebastianboehler/autoresearch-manim` | 150 | 150 | 150 | **150** | 100% Gold render-verified ManimCE v0.20.1 (30 held out for test). |
|
| 64 |
+
| `SuienR/ManimBench-v1` | 416 | 381 | 380 | **371** | 31 `<6` line fragments, 9 duplicates (129 held out for test). |
|
| 65 |
+
| `bespokelabs/bespoke-manim` | 100 | 100 | 96 | **96** | Execution-verified ManimCE v0.19.0 + synthesized `<think>` timeline traces. |
|
| 66 |
+
| `nabin2004/qwen3-8b-manimator-gold-sft` | 733 | 733 | 730 | **712** | 18 cross-dataset duplicate hashes removed. |
|
| 67 |
+
| `nabin2004/AOS-Manim-SFT` | 371 | 371 | 367 | **367** | 2 legacy calls modernized (`ShowCreation` $\rightarrow$ `Create`). |
|
| 68 |
+
| `nabin2004/AOS-Narrated-Manim-400` | 361 | 361 | 357 | **357** | Canonicalized proprietary speech service imports to standard `GTTSService`. |
|
| 69 |
+
| `nabin2004/manim-sft-10k` | 10,000 | 7,951 | 7,722 | **6,934** | Filtered 1,953 non-English/malformed prompts, 788 duplicates, 211 contradictions. |
|
| 70 |
+
| `Chimanwakis/manim_animation_dataset` | 6,023 | 5,516 | 5,156 | **5,156** | Filtered 507 `SyntaxError`s and 360 unaligned literal mismatches. |
|
| 71 |
+
| `RY7Games/ry_manim_codegen` | 4,625 | 2,209 | 2,076 | **361** | Filtered 1,065 `SyntaxError`s, 1,198 1-line stubs, 1,715 duplicates; 374 API repairs. |
|
| 72 |
+
| `mistral-hackaton-2026/manim-finetune-data` | 2,705 | 1,316 | 818 | **220** | Filtered 1,037 `SyntaxError`s, 432 unaligned pairs, 598 duplicates; 192 API repairs. |
|
| 73 |
+
| `priyanshutomar2024/adaption-unified-manim-instructions` | 40,383 | 9,007 | 8,782 | **8,759** | Bypassed corrupted `output` column; extracted aligned `reasoning_trace` + `enhanced_completion`; filtered 21,395 `SyntaxError`s & 4,516 short stubs. |
|
| 74 |
+
| **RITL Compiler Self-Repair Trajectories** | — | 1,200 | 1,200 | **1,200** | 2-turn `Broken Code + Manim Traceback -> Fixed ManimCE Code` trajectories. |
|
| 75 |
+
| **Total Master Corpus (`PRB1/ManimCE-Master-SFT`)** | **68,239** | **29,304** | **27,834** | **24,692** | **24,033 Train (`8,671` with `<think>` CoT) \| 500 Val \| 159 Held-Out Test** |
|
| 76 |
+
|
| 77 |
+
---
|
| 78 |
+
|
| 79 |
+
## 3. Repository Structure
|
| 80 |
+
|
| 81 |
+
```text
|
| 82 |
+
ManimFineTuneExperiment/
|
| 83 |
+
├── src/
|
| 84 |
+
│ ├── data_pipeline/
|
| 85 |
+
│ │ ├── manim_canonicalizer.py # Python AST parser & ManimCE v0.19+ code modernizer
|
| 86 |
+
│ │ ├── alignment_filter.py # Semantic & lexical prompt-to-code alignment verifier
|
| 87 |
+
│ │ ├── dpo_pair_builder.py # Hard-negative DPO & 2-turn RITL self-repair generator
|
| 88 |
+
│ │ ├── hf_loader.py # Pure-Python & PyArrow HuggingFace dataset loader
|
| 89 |
+
│ │ └── build_master_dataset.py # Full curation orchestrator & HF Hub uploader
|
| 90 |
+
│ ├── training/
|
| 91 |
+
│ │ ├── sft_trainer.py # Custom 16-bit Dual-GPU rsLoRA + NEFTune SFT trainer
|
| 92 |
+
│ │ └── dpo_trainer.py # Custom 16-bit Adapter-Reference DPO + RPO-NLL trainer
|
| 93 |
+
│ ├── inference/
|
| 94 |
+
│ │ └── ritl_agent.py # Renderer-in-the-Loop (RITL) 1-turn compiler self-repair
|
| 95 |
+
│ └── eval/
|
| 96 |
+
│ └── manim_benchmark_eval.py # Held-out ManimBench-v1 & Autoresearch evaluator
|
| 97 |
+
├── kaggle_kernel/
|
| 98 |
+
│ ├── kernel-metadata.json # Kaggle GPU kernel configuration
|
| 99 |
+
│ └── train_manimce_16bit_kaggle.py # Standalone fault-tolerant Kaggle Dual-T4 training script
|
| 100 |
+
├── scripts/
|
| 101 |
+
│ └── push_kaggle_kernel.py # Automated Kaggle CLI/API kernel deployment & status check
|
| 102 |
+
├── docs/branches/ # Dedicated technical READMEs for v1.0, v2.0, v3.0, v4.0
|
| 103 |
+
├── data/curation_audit_report.json # Complete per-dataset AST & alignment audit metrics
|
| 104 |
+
└── requirements.txt
|
| 105 |
+
```
|
| 106 |
+
|
| 107 |
+
---
|
| 108 |
+
|
| 109 |
+
## 4. Quickstart Usage
|
| 110 |
+
|
| 111 |
+
### A. Curate & Upload Master Datasets
|
| 112 |
+
```bash
|
| 113 |
+
export HF_TOKEN="your_hf_token"
|
| 114 |
+
python src/data_pipeline/build_master_dataset.py
|
| 115 |
+
```
|
| 116 |
+
|
| 117 |
+
### B. Deploy & Launch 16-Bit Training on Kaggle Free GPU (`T4 x2`)
|
| 118 |
+
```bash
|
| 119 |
+
export KAGGLE_API_TOKEN="your_kaggle_token"
|
| 120 |
+
export HF_TOKEN="your_hf_token"
|
| 121 |
+
python scripts/push_kaggle_kernel.py
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
### C. Run Local/Cloud Multi-GPU 16-Bit SFT & DPO Directly
|
| 125 |
+
```bash
|
| 126 |
+
python src/training/sft_trainer.py --base_model Qwen/Qwen2.5-Coder-7B-Instruct
|
| 127 |
+
python src/training/dpo_trainer.py --base_model Qwen/Qwen2.5-Coder-7B-Instruct
|
| 128 |
+
```
|