The problem LearnOra solves
Creating mathematical visualizations using libraries like Manim requires both programming skills and a deep understanding of mathematical syntax.
While Manim is incredibly powerful for animations, it’s inaccessible to non-programmers - especially educators or students who just want to visualize a math concept quickly.
Existing tools either:
Focus only on symbolic math (like WolframAlpha or Desmos), or
Require manual coding and debugging.
There’s no tool that bridges natural language understanding with precise code generation for Manim, ensuring that the output is both mathematically accurate and syntactically correct.
LearnOra solves this by using a RAG model trained on Manim documentation, code examples, and mathematical concepts, enabling it to retrieve the right code snippets and generate working visualizations from plain English prompts.
Challenges we ran into
- Understanding the Abstraction Gap
Natural language like
“Show a sine wave expanding and rotating in 3D”
is very high-level, while Manim code requires exact classes, methods, and scene structures.
Bridging that semantic gap required fine-tuning prompt templates and curating example-rich documentation chunks for retrieval.
- Chunking the Manim Documentation Effectively
Manim’s documentation mixes API references, tutorials, and code examples.
If chunked incorrectly, the retriever would bring irrelevant or incomplete snippets (e.g., only function definitions without context).
We had to experiment with hierarchical chunking (function → class → usage) and semantic embedding models (e.g., all-MiniLM / OpenAI text-embedding-3-large) to ensure the model retrieved complete and meaningful references.
- Retrieval Noise
Sometimes multiple Manim methods achieve similar effects (e.g., Transform vs. ReplacementTransform).
The retriever often fetched overlapping code blocks that confused the generator.
We mitigated this using similarity score thresholds and context ranking based on prior successful generations.
- Syntax-Safe Code Generation
LLMs sometimes hallucinate methods that don’t exist in Manim (e.g., Wave3D()), which breaks rendering.
We introduced a post-processing validator that:
Runs a static syntax check (python -m py_compile)
Searches retrieved documentation for all functions used in the code
Re-prompts the model with feedback if invalid methods are detected.
- Rendering Bottlenecks
Even with correct code, video rendering using Manim (via Cairo/OpenGL) is heavy and slow.
We optimized by:
Using low-res previews (480p) for instant demos
Caching repeated renders
Deploying asynchronous render queues using Celery + Redis.
- Aligning Math Semantics with Animation Logic
Prompts like
“Show area under curve y = x² from 0 to 3”
require both symbolic math understanding and animation sequencing (graph → fill area → highlight region).
We integrated a math parser (SymPy) to interpret functions, then passed structured data to the RAG model so it could generate Manim scenes with logical flow.
- Evaluation & Debugging
It’s tricky to evaluate whether generated animations “match the intent” of a prompt.
We implemented a 3-level evaluation:
Syntax validity
Render success
Semantic alignment (manual check + feedback loop)
