# ManimCode: Learning Visual Self-Correction for Educational Animation

ManimCode trains a small model to write, review and revise animation programs

Zhengyang Liang, Lizi Liao · arXiv · 2026-11-5

- **Problem** Manim programs can render yet look wrong, and small models lack revision training data.
- **Method** ManimCode is one 4B model that writes, reviews and revises Manim programs. It is trained with supervised fine-tuning on recorded correction trajectories, then with reinforcement learning on the model's own mistakes.
- **Results** With the full loop, ManimCode reaches 97.0% render success on ManimBench, compared with 82.0% for the untrained 4B model under the same setup.

![Figure 3: Overview of ManimCode.(1) Final programs and intermediate steps of ManimData trajectories supervise five tasks of one Qwen3.5-4B model. (2) Reinforce…](https://refivu.com/papers/2dea0667-9c10-420f-a180-d968b5fe7e6f/figures/figure-a9af250856e4e7ed0aade5a3e5c47dcd.png?thumb=512)

**Figure 3** .Overview of ManimCode.(1) Final programs and intermediate steps of ManimData trajectories supervise five tasks of one Qwen3.5-4B model. (2) Reinforcement learning further trains the Reviser on repair and critique states that the supervised model produces itself: the Reviser samples eight revisions per state, Qwen3.8-27B scores each rendered revision (request coverage for repair, two order-swapped comparisons with the draft for critique), and revisions that score above the rest of their group become more likely (Sec. 4.2). The two states shown are real training states; their revisions and scores are illustrative. (3) At inference, our model runs the render–review–revise loop. Qwen3.8-27B is used only to build the data and to compute training rewards.

[Original paper](https://arxiv.org/abs/2611.08294v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) · Zhengyang Liang, Lizi Liao · ManimCode: Learning Visual Self-Correction for Educational Animation · Original paper figure · Extracted the figure area from page 6 of the original PDF.

## Why a successful render is not enough

A Manim program can run cleanly and still produce a poor lesson. None of these defects raises an execution error, so the render step alone doesn't flag them. The video also doesn't point to the lines that need to change. Someone therefore has to inspect the output and revise the program based on the defects.

Agentic systems such as Code2Video, TheoremExplainAgent and ManimAgent revise programs from execution errors and sometimes visual feedback. These systems usually depend on large, often proprietary, models. Their refinement loops become much less reliable when a smaller open alternative runs them. Training data is limited as well, because ManimBench is render-verified but relatively small.

Community datasets and JanusCode-800K lack systematic rendering and quality checks, so they don't fill that gap.

Of the 20,976 Hugging Face community programs, roughly one-third fail to render as released. Even among the renderable programs, only 31% pass the quality criterion after revision.

The authors build ManimData through a render-guided pipeline that records how programs are corrected and improved. Execution errors, layout checks, and visual critiques guide the next revisions. The pipeline keeps the best version and admits a record only when it meets the quality criterion.

## Recording the repair process as ManimData

The central idea is to keep the whole correction history for each program rather than only the final version. Qwen3.8-27B plays the Writer, Reviewer and Reviser roles, and every version it writes is rendered and reviewed. For a Wikipedia request, the Writer first writes retrieval queries and drafts a program from the API cards it retrieves, while a community input starts from its released code.

The renderer either returns a video or an execution error, and a layout checker reports objects outside the frame, overlapping text and small labels.

The Reviser then rewrites the full program to fix a crash or to act on that critique. Each input gets up to 10 renders, and the loop keeps the best candidate by mean review score. A new version replaces the best one only if the mean score improves without a large loss in request alignment or content completeness. A record is admitted when its best version reaches a mean score of at least 3.75.

The pipeline yields 24,034 records, and most of them went through several refinement rounds. Those trajectories produce 305,452 role-conditioned training examples. The API knowledge base holds 2,219 cards for ManimCE v0.19.1 and eight domain plugins.

## Training one model on three roles

Each training example in ManimCode is a triple of role, context and target, and the same layout is used at inference. The Reviewer's examples pair the request, current program and sampled frames with four recorded scores and a critique. The Reviser's examples come from two kinds of successful transitions, and both of them are kept only when they succeed.

Execution repairs turn a crashed program into one that renders, which teaches the model to fix failures it can observe directly.

A quality revision keeps a revision whose mean review score beats the program it replaces. Quality revisions teach the Reviser to act on visual critiques, because it receives the critique and layout diagnostics as input. Retrieval-query examples teach the model to write the search queries used to fetch API cards, with a total of 187,183 examples.

Training one model on all five tasks lets a single 4B model play each role at inference.

The authors train one Qwen3.5-4B model on this mixture by minimizing the negative log likelihood of each target y given role and context. In the loss, the model pi with trainable parameters theta is trained on samples drawn from the SFT data distribution. The adapters are LoRA with rank 32 and alpha 64 on all linear layers, trained for one epoch with a learning rate of 1×10−4.

Supervised fine-tuning takes about 32 hours on four NVIDIA L40S GPUs. Thinking mode is disabled throughout training.

## Reinforcement learning on the model's own failures

The trajectories come from a stronger model, so they may miss the errors the 4B model actually makes. The authors therefore sample states from the supervised model itself, so the Reviser learns from its own mistakes. A draft that fails to render becomes a repair state, keeping the request, the program, the execution error and the retrieved API cards.

A draft that renders but fails the early-stopping criterion becomes a critique state, which adds the review and layout diagnostics. Both states follow the Reviser's inference input format, so training matches what the model sees at inference.

For each state, the Reviser samples eight candidate revisions, and the authors render each candidate. Near-duplicate revisions receive zero reward, which discourages trivial edits that don't change the program. A repair candidate that doesn't render earns zero, while a rendering candidate is scored by Qwen3.8-27B on request alignment and content completeness.

That pair of scores is averaged and mapped into the reward, so a better-covered request earns a higher reward. The reward is plus one when both comparisons prefer the new revision, minus one when both prefer the input, and zero otherwise.

Because the rewards come from renders and a reward model, the method needs no reference program or target video. The RL adapter starts from the merged supervised model, with a learning rate of 1×10−4 and a KL weight of 0.01. The RL run used the step-20 checkpoint from a run planned for 40 steps.

## Scene-level gains from the full loop

The full loop lifts render success for the 4B model far above its untrained baseline on both scene-level benchmarks. ManimCode reaches 96.6% render success on ManimData-test, while the untrained Qwen3.5-4B reaches 52.6% under the same loop. On ManimBench, ManimCode reaches 97.0% render success, compared with 82.0% for the untrained Qwen3.5-4B under the same loop.

The untrained model received the same retrieval and budget as the full system, so the gap comes from the trained weights.

![Table 2: Scene-level animation generation on ManimData-test and ManimBench. VQ is averaged over successfully rendered videos.†71 of the 100 ManimBench requests…](https://refivu.com/papers/2dea0667-9c10-420f-a180-d968b5fe7e6f/figures/figure-f908b85fd30ffe862eb538a67d60d639.png?thumb=512)

**Table 2** .Scene-level animation generation on ManimData-test and ManimBench. VQ is averaged over successfully rendered videos.†71 of the 100 ManimBench requests appear in JanusCoder’s training data.

[Original paper](https://arxiv.org/abs/2611.08294v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

Trajectory SFT alone moves the loop from 52.6% to 88.6% render success on ManimData-test. Reviser RL then adds 8.0 percentage points on top of the SFT loop, reaching 96.6%. On ManimBench, SFT inside the loop gives 92.0%, and RL adds 5.0 percentage points to reach 97.0%. Video quality on ManimData-test rises from 2.48 for the untrained model to 2.89 after SFT and 2.94 after RL.

The authors read this split as SFT helping both render success and quality, while RL mostly helps render success. Video quality is averaged only over successfully rendered videos, so it doesn't capture the failures counted in render success.

## Plugging ManimCode into long-form educational video systems

The authors swapped ManimCode in as the scene generator of two long-form systems, Code2Video and TheoremExplainAgent. Both runs share one lecture plan written by the untrained Qwen3.5-4B, so only the scene generator differs. The native run uses the untrained model to write and repair each scene, while the ManimCode run uses the trained system.

On MMMC, the 117 Code2Video lecture topics, completed videos rise from 19/117 to 107/117.

On TheoremExplainBench, the 239 distinct theorems, completed videos rise from 53/239 to 239/239. The visual score, averaged over visual relevance, element layout, and visual consistency, rises from 2.35 to 3.16. The narration-based dimensions were left out because they score the shared plan rather than the scene generator.

The authors judged all runs with Gemini 3.8 Flash, which replaced each benchmark's original judge. Absolute scores therefore aren't comparable with published numbers, so only the native and ManimCode runs in these tables can be compared. For the human check, a blinded annotator compared 98 pairs, and the judge agreed with the annotator most often when the VQ gap was large.

## Curation and the automatic judge

Curation helps the Writer on both benchmarks, so the training corpus matters as much as the model. The authors trained two Writers on the same 8,416 of the 8,497 community records, one on the original programs and one on curated versions. The other 81 records are JanusCode-800K programs that define no construct method, so they were left out of both runs.

Because both Writers see identical inputs, the gain comes from the supervision targets rather than from the requests.

![Figure 4: Effectofcuration. Onthesame8,416community requests with identical inputs, a Qwen3.5-4B Writer fine- tunedonourcuratedprograms(blue)scoreshigherinsing…](https://refivu.com/papers/2dea0667-9c10-420f-a180-d968b5fe7e6f/figures/figure-b2fe6b758fcf1d7fd8120969fe643d4e.png?thumb=512)

**Figure 4** .Effectofcuration. Onthesame8,416community requests with identical inputs, a Qwen3.5-4B Writer fine- tunedonourcuratedprograms(blue)scoreshigherinsingle- pass RS and VQ on both benchmarks than one fine-tuned on the released programs (gray).

[Original paper](https://arxiv.org/abs/2611.08294v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

Its VQ is the mean of a content score and a presentation score, and the two calls for the presentation side are averaged. To test whether the judge tracks human taste, one team member judged all 98 pairs without knowing which system made each video. The annotator agreed with the judge on 79% of decided pairs when the VQ gap was at least 0.5.

That agreement fell to 29% when the gap was below 0.25.

The agreement pattern shows the judge is most reliable when the quality difference is large. Among decided pairs, the annotator agreed with the judge's content ordering in 69% of cases. Its presentation ordering agreed in 65% of cases. At the system level, human preferences matched the judge's rankings in three of four comparisons. The one mismatch was Qwen3.8-27B on ManimData-test, where the human win rate was 0.33 and the judge recorded 14 wins, 3 ties, and 19 losses.

The regression of verdicts on the log2 length ratio gives slopes of 0.03 for the annotator and 0.05 for the judge, so length does not drive either verdict.

## Limitations and where the results stop

The human preference check covers 98 video pairs, and one team member judged all of them. Agreement with the judge is 79% for VQ gaps of at least 0.5, but only 29% for gaps below 0.25. So the judge is most useful when the quality difference between two videos is large.

The RL stage is motivated by a gap, because trajectories from a stronger model may not capture the errors that the 4B model makes. Training rewards come from Qwen3.8-27B, the same model that builds the data. The paper names Qwen3.8-27B as the reward model, so the reward depends on that judge.

The Reviser keeps the best-scored candidate, so a regression doesn't replace a better version. That same rule can't repair a defect the Reviser leaves behind, as the second revision in Figure 6 shows. In that case the loop keeps the first revision, which is still cut off.

![Figure 6: More revision steps of our system on ManimData-test.Each row is one revision step; the best-candidate rule decides which version the loop returns. Fr…](https://refivu.com/papers/2dea0667-9c10-420f-a180-d968b5fe7e6f/figures/figure-29ad14a7f398b7cc2b95ce3ac9cbd631.png?thumb=512)

**Figure 6** .More revision steps of our system on ManimData-test.Each row is one revision step; the best-candidate rule decides which version the loop returns. From the top: a crash repaired from the renderer’s error message; a wrong sum corrected in the explanation text; an overlap removed by moving the result below the derivation; and two consecutive revisions of the same request. In the last two rows, moving the transaction list down clears the progress bar but pushes the list past the bottom edge, and moving it back up restores the overlap; our Reviewer scores the second revision lower, so the loop keeps the first. Under each frame are our Reviewer’s mean score and the score that the judge, Gemini 3.8 Flash, gives the re-rendered video (1–5).

[Original paper](https://arxiv.org/abs/2611.08294v1) · [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)

The main results use 500 ManimData-test requests, excluded from training, with long-form scores judged by Gemini 3.8 Flash. Those long-form scores use Gemini 3.8 Flash instead of the original judges, so they can't be compared with published numbers. The evaluation covers only two scene-level benchmarks and two long-form systems.

## Paper info

- **Authors**: Zhengyang Liang, Lizi Liao
- **Venue**: arXiv · Preprint
- **First published**: 2026-11-5
- **Added**: 2026-11-7
- **Updated**: 2026-11-5
- **Version**: v1
- **arXiv**: 2611.08294
- **Category**: cs.CV
- **Original paper terms**: [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/)
- **What we show**: Paper info, commentary and permitted figures from the original paper

[Original paper ↗](https://arxiv.org/abs/2611.08294v1) · [PDF ↗](https://arxiv.org/pdf/2611.08294v1)

AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.

## Abstract

Manim supports precise, programmatic video generation, but a successfully rendered educational animation can still have visual defects, missing explanations, or incorrect content. Rendering does not directly identify the code changes needed to correct these visual failures, so feedback-driven revision is needed. Existing agentic frameworks use iterative rendering and revision but typically rely on large models, often proprietary. Existing Manim datasets primarily contain final programs and often lack quality verification and the trajectories of feedback and revisions needed to learn this refinement process. We introduce ManimData and ManimCode, a data and training framework for feedback-driven educational animation generation. We construct ManimData through a render-guided pipeline that iteratively generates, executes, reviews, and revises Manim programs with retrieved API documentation. Its 24,034 render-verified, quality-filtered records preserve intermediate programs, execution errors, visual critiques, and corrective revisions. We use role-conditioned supervised fine-tuning on these trajectories to train ManimCode, a single 4B model, to write, review, and revise animation programs. To improve correction of errors that differ from those in the collected trajectories, we then train the Reviser with reinforcement learning on self-generated states, using rendering outcomes and reference-free quality feedback. ManimCode achieves 96.6% and 97.0% render success on ManimData-test and ManimBench, compared with 52.6% and 82.0% for the untrained 4B model under the same inference setup, while also improving video quality scores from 2.48 to 2.94 and from 3.00 to 3.44. Integrating ManimCode into two long-form educational video generation systems increases completed videos from 19/117 to 107/117 and from 53/239 to 239/239, alongside improvements in educational effectiveness and visual quality.

## Quote from the paper

Zhengyang Liang, Lizi Liao (2026). ManimCode: Learning Visual Self-Correction for Educational Animation. arXiv:2611.08294v1. https://arxiv.org/abs/2611.08294v1

**BibTeX**

```
@misc{liang2026manimcode,
  title = {{ManimCode: Learning Visual Self-Correction for Educational Animation}},
  author = {Zhengyang Liang and Lizi Liao},
  year = {2026},
  eprint = {2611.08294},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.08294v1}
}
```

## Other paper commentary

- [SSD: Single Shot MultiBox Detector](https://refivu.com/en/papers/1889995f-3f80-4a7d-b734-c549e845a707-ssd-single-shot-multibox-detector.md)
- [BinsFormer: Revisiting Adaptive Bins for Monocular Depth Estimation](https://refivu.com/en/papers/7fc81cb2-3782-4326-9ffa-5af4ea6fe25b-binsformer-revisiting-adaptive-bins-for-monocular-depth.md)
- [Unifying Flow, Stereo and Depth Estimation](https://refivu.com/en/papers/a17a6b8c-5864-4598-9183-8a1c09180428-unifying-flow-stereo-and-depth-estimation.md)
- [Deep Gradient Learning for Efficient Camouflaged Object Detection](https://refivu.com/en/papers/ab2734b0-aadf-4a7a-9878-ec87828236f4-deep-gradient-learning-for-efficient-camouflaged-object.md)
- [Video Salient Object Detection via Fully Convolutional Networks](https://refivu.com/en/papers/bc9ebd0c-9bab-4b48-a6aa-5dc69dbeadea-video-salient-object-detection-via-fully-convolutional.md)
- [Analyzing and Improving the Image Quality of StyleGAN](https://refivu.com/en/papers/e2a72d06-1704-43a3-b07f-7a9c61ec260b-analyzing-and-improving-the-image-quality-of-stylegan.md)
- [AutoCompress: Automated Hardware-Guided Model Compression](https://refivu.com/en/papers/5025a49f-392e-468e-abdf-7134dc3d1463-autocompress-automated-hardware-guided-model-compression.md)
- [Hierarchical Incremental Beta Splatting for Online Reconstruction](https://refivu.com/en/papers/cf6f71fd-917a-4b31-9c86-428117538f72-hierarchical-incremental-beta-splatting-for-online.md)
- [From Twisted Facts to Rogue Agents: Can LLMs Reliably Detect Multi-Dimensional Hallucinations?](https://refivu.com/en/papers/c37b62c9-3ac8-42a8-92f7-3501bc3b9f16-from-twisted-facts-to-rogue-agents-can-llms.md)
- [Signals, Evidence, and Context: User Scrutiny in Real-World LLM Conversations](https://refivu.com/en/papers/8a124d7d-a03b-458e-b7ee-f9e496116a1a-signals-evidence-and-context-user-scrutiny-in-real.md)
- [Regret Bounds for Profit Maximization in Bilateral Trade: Learning the Best Posted-Price Mechanism](https://refivu.com/en/papers/14858590-a9ec-42f2-aa9c-bba898483506-regret-bounds-for-profit-maximization-in-bilateral-trade.md)
- [Decision Models as Retrieval Gates Against Injection and Pollution](https://refivu.com/en/papers/bd8c9c31-9e0d-4aa7-b98c-344a751f593c-decision-models-as-retrieval-gates-against-injection-and.md)

## Terms in this paper

- [reinforcement learning](https://refivu.com/en/terms/6c51042515d2-reinforcement-learning)
- [Qwen3.8-27B](https://refivu.com/en/terms/4cabdbb54f57-qwen3-8-27b)
- [Gemini 3.8 Flash](https://refivu.com/en/terms/bed5c391e267-gemini-3-8-flash)
- [GPT-4o](https://refivu.com/en/terms/bad3b84e1308-gpt-4o)
- [supervised fine-tuning (SFT)](https://refivu.com/en/terms/b08583cba2aa-supervised-fine-tuning-sft)
- [writer](https://refivu.com/en/terms/67580e2e96dd-writer)
- [RLOO](https://refivu.com/en/terms/6df6d1eb90cf-rloo)

---

AI-written text can contain mistakes. [Refivu](https://refivu.com/en/papers/2dea0667-9c10-420f-a180-d968b5fe7e6f-manimcode-learning-visual-self-correction-for-educational)
