{"slug": "math-to-manim", "title": "Math-to-Manim", "summary": "Math-To-Manim, a new open-source agent pipeline, converts short natural-language prompts into structured lesson plans and generated Manim code for mathematical animations. The system uses a chain of specialized agents to reverse-reason from a target concept to prerequisites, then produces inspectable artifacts including knowledge graphs, storyboards, and rendered videos. The project aims to make visual math explanations reproducible and auditable for teachers, tutors, and learners.", "body_md": "[Motion showcase](/HarleyCoops/Math-To-Manim/blob/main/docs/showcase/README.md) · [Architecture](/HarleyCoops/Math-To-Manim/blob/main/docs/ARCHITECTURE.md) · [Prime RL](/HarleyCoops/Math-To-Manim/blob/main/docs/PRIME_INTELLECT_RL.md) · [Roadmap](/HarleyCoops/Math-To-Manim/blob/main/docs/ROADMAP.md) · [Agent guide](/HarleyCoops/Math-To-Manim/blob/main/AGENTS.md)\n\n**Math-To-Manim turns short prompts into reverse-reasoned lesson plans, typed pipeline artifacts, generated Manim code, and reusable visual explanations.**\n\n**Browse the local GIF gallery →**\n\n*Code-grounded workflow: every run stays inspectable from prompt to artifacts to render.*\n\n**Math to Manim** is for the moment when a learner asks, “Can you show me why?” A teacher, tutor, parent, or guardian can type a question and get back a visual explanation plan: the concept, the missing prerequisites, the order of ideas, the screen beats, the generated Manim code, and optionally the rendered video.\n\nThe input can be short, but the product is the explanation: what the learner needs to understand, what should appear first, where the aha moment lives, and which visual metaphor makes the idea feel inevitable.\n\nMath-To-Manim proves that calculus, topology, chaos, spacetime, stochastic finance, and ML concepts can become useful mathematical motion when agents plan the explanation before they write code.\n\nThis repo turns that idea into a durable agent pipeline:\n\n- a prerequisite-story pipeline inspired by the original reverse knowledge tree;\n- typed Pydantic artifacts between every stage;\n- OpenAI Agents SDK-compatible adapters for planning and generation;\n- optional Codex CLI-backed codegen for subscription-authenticated iteration;\n- a reproducible\n`runs/<run_id>/`\n\nbundle for every generation; - static validation, render metadata, review artifacts, and manifests that are easy to inspect in CI or by another agent.\n\nThe design principle is simple: **story before symbols, geometry before algebra, artifacts before side effects.**\n\nA normal text-to-code demo jumps from request to Python. Math-To-Manim takes the long way on purpose: it reasons backward from the final concept to the prerequisites, then walks forward through a teachable visual sequence.\n\nThe code path is explicit in [ math_to_manim/pipeline/runner.py](/HarleyCoops/Math-To-Manim/blob/main/math_to_manim/pipeline/runner.py).\n\n`AnimationPipeline.generate()`\n\nruns a fixed stage chain: `IntentAgent`\n\n, `PrerequisiteGraphAgent`\n\n, `CurriculumAgent`\n\n, `MathAgent`\n\n, `StoryboardAgent`\n\n, `SceneSpecAgent`\n\n, `ManimCodeAgent`\n\n, `StaticReviewAgent`\n\n, `RenderAgent`\n\n, `VideoReviewAgent`\n\n, and `PublisherAgent`\n\n.| Stage | Why it exists | Artifact |\n|---|---|---|\n| Intent | Clarify what the learner is really asking. | `intent.json` |\n| Reverse prerequisites | Build the knowledge graph needed before the target idea. | `knowledge_graph.json` |\n| Curriculum | Turn the graph into a teachable order. | `curriculum.json` |\n| Math packet | Select definitions, equations, assumptions, and examples. | `math_packet.json` |\n| Storyboard | Decide the screen beats before code exists. | `storyboard.json` |\n| Scene spec | Compile the visual plan into Manim objects, animations, timing, and camera notes. | `scene_spec.json` |\n| Code, validation, render, review | Generate runnable Manim, gate it with static checks, render when allowed, and package the evidence. | `generated_scene.py` , reports, manifest |\n\nThat gives every run a memory: JSON contracts, generated code, render results, review notes, and a manifest. The output is not just a video; it is an inspectable path from **question** to **understanding** to **animation**.\n\nFor current editable-video status and the planned prompt/spec/code edit loop, see the [roadmap](/HarleyCoops/Math-To-Manim/blob/main/docs/ROADMAP.md).\n\nMath-To-Manim is also becoming a Prime Intellect reinforcement-learning environment. The first RL target is not \"make the whole video in one shot.\" It is the repair move that matters most when generated animation code fails: take the typed scene plan, the broken `generated_scene.py`\n\n, and validation/render evidence, then return corrected Manim Python that is safe, sparse, and more likely to render.\n\nRun bundle as environment |\nReward function as critic |\nPolicy update as repair engine |\n\nThe current hub environment is `harleycooper/math-to-manim`\n\n. A repair task carries the original prompt, typed `scene_spec`\n\n, generated Manim Python, static-validation report, and render/recovery evidence when available. The model must return one strict `GeneratedCode`\n\nJSON block. The Verifiers reward checks whether the proposed code parses, defines the expected Manim scene, avoids unsafe imports and calls, preserves expected math terms, and reduces obvious text/layout crowding hazards.\n\n``` php\ngenerated_scene.py + scene_spec + validation/render evidence\n  -> Prime Intellect Verifiers environment\n  -> model proposes corrected GeneratedCode JSON\n  -> static reward checks parseability, scene shape, safety, terms, layout\n  -> hosted RL updates the repair policy\n  -> corrected, renderable Manim Python flows back into M2M2 recovery\n```\n\nThat keeps the fast RL loop text-and-AST based while the slower Manim renderer remains the audit gate. The intended result is a model that learns the house style of this repo: cinematic but readable scenes, sparse formulas, staged captions, safe Manim code, and scripts that are much more likely to render on the first recovery attempt.\n\nCurrent hosted-training status: the environment action passes on Prime, the hub package is published as `harleycooper/math-to-manim@0.1.1`\n\n, a 1-step smoke completed, and a 25-step W&B-enabled pilot has been launched on `Qwen/Qwen3.5-35B-A3B`\n\n.\n\nSee the full integration notes in [ docs/PRIME_INTELLECT_RL.md](/HarleyCoops/Math-To-Manim/blob/main/docs/PRIME_INTELLECT_RL.md).\n\nWindows PowerShell:\n\n```\ngit clone https://github.com/HarleyCoops/Math-To-Manim.git\ncd Math-To-Manim\npython -m venv .venv\n.\\.venv\\Scripts\\Activate.ps1\npython -m pip install -U pip\npython -m pip install -e \".[dev]\"\npython -m pytest\n```\n\nmacOS / Linux / WSL:\n\n```\ngit clone https://github.com/HarleyCoops/Math-To-Manim.git\ncd Math-To-Manim\npython3 -m venv .venv\nsource .venv/bin/activate\npython -m pip install -U pip\npython -m pip install -e \".[dev]\"\npython -m pytest\n```\n\nThis proves the CLI, artifact contracts, and validators are wired before you spend model or render time:\n\n```\nmath-to-manim generate \"Explain why derivatives are slopes\" --deterministic --no-render\n```\n\nEquivalent module form:\n\n```\npython -m math_to_manim.cli generate \"Explain why derivatives are slopes\" --deterministic --no-render\n```\n\nSet an OpenAI key and choose a model if desired:\n\n```\nexport OPENAI_API_KEY=\"sk-...\"\nexport OPENAI_MODEL=\"gpt-4.1\"\nmath-to-manim generate \"Explain Fourier epicycles as rotating vectors\" --no-render\n```\n\nPowerShell:\n\n```\n$env:OPENAI_API_KEY = \"sk-...\"\n$env:OPENAI_MODEL = \"gpt-4.1\"\nmath-to-manim generate \"Explain Fourier epicycles as rotating vectors\" --no-render\n```\n\nPython render dependency:\n\n```\npython -m pip install -e \".[dev,render]\"\n```\n\nSystem render dependencies are also needed for real Manim output, especially FFmpeg and LaTeX for `MathTex`\n\n. On Debian/Ubuntu/WSL:\n\n```\n./scripts/bootstrap-render.sh\n```\n\nThe package list lives in [ requirements-system.txt](/HarleyCoops/Math-To-Manim/blob/main/requirements-system.txt).\n\nMath-To-Manim can keep the typed planning pipeline while sending the Manim codegen and repair loop through a locally authenticated Codex CLI session.\n\nCheck Codex first:\n\n```\ncodex --version\ncodex exec \"Say ready from inside this repo\"\n```\n\nThen route codegen through Codex:\n\n```\nmath-to-manim generate \"Explain derivatives as slopes with a cinematic tangent-line reveal\" \\\n  --codegen-provider codex-cli \\\n  --codex-full-auto \\\n  --style cinematic \\\n  --quality l\n```\n\nEarlier planning stages remain on the typed adapters; only the generated-code and repair stages move first. That makes the migration incremental instead of all-or-nothing.\n\nA generation writes a self-contained run bundle:\n\n```\nruns/<run_id>/\n  request.json\n  intent.json\n  knowledge_graph.json\n  curriculum.json\n  math_packet.json\n  storyboard.json\n  scene_spec.json\n  generated_code.json\n  generated_scene.py\n  validation_report.json\n  render_result.json\n  review_report.json\n  recovery_manifest.json  # after recover-render\n  draft_review/\n    draft_review.md\n    contact_sheet.png\n    frames/\n  animation_package.json\n  manifest.json\n```\n\nAfter editing `generated_scene.py`\n\ninside a run bundle, rerun the recovery path:\n\n```\nmath-to-manim recover-render runs/<run_id> --quality l\n```\n\nThat command refreshes validation, render, review, draft-review assets, and\n`recovery_manifest.json`\n\nwithout regenerating upstream planning artifacts.\n\nPackage layout:\n\n```\nmath_to_manim/\n  agents/      # stage adapters\n  schemas/     # versioned artifact contracts\n  tools/       # graph, validation, rendering, video, artifact helpers\n  pipeline/    # orchestration, tracing, repair loop\n  rendering/   # Manim and FFmpeg wrappers\n  review/      # static and visual review scoring\n```\n\nHermes is the contributor/operator agent around this repository. It is not imported by Math-To-Manim and is not a runtime dependency; it uses the repo the way a developer would: read files, search code, patch docs and code, run terminal checks, inspect generated artifacts, review frames or GIFs, track todos, delegate larger work, and preserve stable context through skills.\n\nThat makes Hermes useful for maintaining the reverse-reasoning pipeline without becoming part of it. A Hermes session can inspect `AGENTS.md`\n\n, `pyproject.toml`\n\n, schemas, tests, and `runs/<run_id>/`\n\nbundles; run `pytest`\n\n, CLI smoke commands, Manim, FFmpeg, and git checks; then verify that docs, code, and showcase media still match the artifact contracts.\n\nRepo-local Hermes skills live under [ hermes/skills/](/HarleyCoops/Math-To-Manim/blob/main/hermes/skills). The old Claude\n\n`./skill`\n\npath is historical; current contributor guidance is in [, with launch notes in](/HarleyCoops/Math-To-Manim/blob/main/AGENTS.md)\n\n`AGENTS.md`\n\n[.](/HarleyCoops/Math-To-Manim/blob/main/docs/HERMES_LEARNS_MANIM.md)\n\n`docs/HERMES_LEARNS_MANIM.md`\n\nSixteen curated GIFs are tracked under [ docs/showcase/assets/](/HarleyCoops/Math-To-Manim/blob/main/docs/showcase/assets) as the\n\n**art direction target** for Math-To-Manim's visual explanations.\n\nGeometry as spectacle |\nTopology as choreography |\nChaos as intuition |\n\nSee the full gallery with descriptions: .\n\n`docs/showcase/README.md`\n\n```\nMP4=\"media/videos/your_scene/480p15/YourScene.mp4\"\n\nffmpeg -y -ss 95 -t 24 -i \"$MP4\" \\\n  -vf \"fps=12,scale=720:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=96[p];[s1][p]paletteuse=dither=bayer:bayer_scale=5\" \\\n  docs/showcase/assets/your-clip.gif\n```\n\nAdjust `-ss`\n\nand `-t`\n\nto capture the teaching beat you want.\n\nMIT.", "url": "https://wpnews.pro/news/math-to-manim", "canonical_source": "https://github.com/HarleyCoops/Math-To-Manim", "published_at": "2026-05-27 12:18:19+00:00", "updated_at": "2026-05-27 12:46:22.167669+00:00", "lang": "en", "topics": ["generative-ai", "ai-tools", "ai-agents", "artificial-intelligence", "machine-learning"], "entities": ["HarleyCoops", "Math-To-Manim"], "alternates": {"html": "https://wpnews.pro/news/math-to-manim", "markdown": "https://wpnews.pro/news/math-to-manim.md", "text": "https://wpnews.pro/news/math-to-manim.txt", "jsonld": "https://wpnews.pro/news/math-to-manim.jsonld"}}