CMU's Feynman Builds 100,000 Science Diagrams for Under $400
A new agent pipeline pairs LLM knowledge planning with the Penrose diagramming engine to produce 100k+ textbook-quality diagrams for under $400.
ProTakeaways
- Feynman is an agent that writes declarative programs and renders them with Penrose to produce scientific diagrams.
- Pipeline has four stages: idea enumeration, code planning, critic-driven iteration, and optimization-based rendering.
- Generated 106,930 diagram-caption pairs from 10,693 programs for under $400 using GPT-4o-mini.
- Penrose L-BFGS layout optimizer adds visual diversity without changing semantics, yielding ten variants per program.
- Companion benchmark Diagramma evaluates 17 multimodal LLMs on contamination-free diagrams.
- Dataset, benchmark, and agent pipeline planned for open-source release covering chemistry, geometry, graphs, and sets.
High-quality vision-language data is the fuel behind every strong multimodal model, but the internet is stingy with the kind of tightly-aligned, knowledge-rich diagrams you find in a chemistry textbook. A team from Carnegie Mellon is trying to change that with Feynman, an agent that writes declarative programs describing scientific concepts and then hands them off to the Penrose diagramming system to render. The result: a synthesized corpus of more than 100,000 diagram-caption pairs and a fresh benchmark, Diagramma, for stress-testing vision-language models.

The missing training data
Visual reasoning is an essential ability of state-of-the-art multi-modal AI systems, and improving these systems requires high-quality vision-language data at scale. Despite the abundance of internet image and text data, knowledge-rich and well-aligned image-text pairs are rare. Scraped web images tend to be noisy, decorative, or paired with captions that describe the surrounding article rather than the visual content itself. Textbook-grade figures with clean, grounded captions are the exception.
Prior work tried to close the gap by mining TikZ code from arXiv papers or scraping SVGs, but those sources are limited in domain coverage and layout style. Feynman takes the opposite approach: instead of harvesting existing diagrams, it programmatically authors new ones from scratch, with the caption generated alongside the image so alignment is guaranteed by construction.
How the agent thinks in four steps
Feynman's diagram synthesis pipeline includes four steps: idea, plan, iterate, and render. By leveraging the knowledge capacity of LLMs and a conceptual diagramming tool, it can generate grounded and diverse visual representations of scientific concepts at scale. Each stage has a distinct job:
- Idea: the LLM enumerates domain-specific knowledge components. For a chemistry domain, that might be a list of reactions like photosynthesis, the Haber process, or acid-base neutralization.
- Plan: given an idea, the agent drafts a code plan that maps the concept to visual primitives such as atoms, bonds, arrows, and groupings.
- Iterate: Feynman translates ideas into simple declarative programs and iterates to receive feedback and visually refine diagrams. A critic MLLM reviews each rollout and scores it, letting the agent early-stop or retry.
- Render: the final declarative program is compiled by Penrose.
The clean split between knowledge and rendering matters. Using an LLM to provide general knowledge-focused planning decouples the domain knowledge elicitation from the domain-specific visual design. This choice alleviates the cost of obtaining diverse and high-quality knowledge for the generation of domain-specific diagrams. The LLM never has to worry about pixel coordinates, and the renderer never has to reason about chemistry.
Why Penrose is the secret sauce
Penrose is a research diagramming system that separates what you want to draw (a Substance program describing objects and relations) from how it should look (a Style program describing shapes and constraints). Penrose solves the layout problem by running L-BFGS with line search, an iterative optimizer that nudges shapes around until constraints like non-overlap, alignment, and containment are satisfied.

That optimization loop is what gives Feynman its visual diversity. The optimization-based rendering of Penrose preserves the visual semantics while injecting fresh randomness into the layout, thereby producing diagrams with visual consistency and diversity. As a result, Feynman can author diagrams along with grounded captions with very little cost and time. The same declarative program, reseeded, produces a legitimately different-looking figure every run, so the dataset does not collapse into a thousand copies of the same layout.
The economics of synthetic diagrams
The efficiency numbers are the headline result. With Feynman, the team generated 10,693 knowledge-infused programs, leading to the creation of 106,930 well-aligned diagram-caption pairs. This was accomplished within 1,550 million input and output tokens at a cost of under $400 with GPT-4o-mini. That works out to roughly four-tenths of a cent per diagram, orders of magnitude cheaper than commissioning human illustrators or paying artists to annotate figures.
Because each program yields ten diagrams via re-optimization, you get built-in data augmentation without the semantic drift that plagues image-model augmentation (e.g., a rotated molecule that now shows the wrong stereochemistry).
Diagramma and 17 models on the hot seat
Alongside the training corpus, the authors carved out an evaluation set. Diagramma is a new benchmark made of entirely fresh examples authored by Feynman, and the authors conducted a thorough quantitative evaluation of 17 MLLMs. Because the diagrams are freshly generated rather than scraped, there is no risk they leaked into any pretraining corpus, which is a growing concern for older benchmarks.

The domains covered span chemistry, geometry, graph theory, and set theory, which lines up with the four panel types Penrose is best at expressing. That breadth is important because it exercises different reasoning skills: parsing atomic structures, identifying triangulated meshes, tracing edges in a network, and reading intersections in a Venn diagram.
What is actually new here
The real breakthrough is not any single model but the pipeline design choice: generate diagrams as programs, not pixels. Text-to-image diffusion models still struggle to draw a correctly balanced chemical equation or a topologically valid graph because they operate on pixel statistics rather than symbolic structure. Feynman sidesteps that entirely by having an LLM write code in a diagram-native DSL and delegating spatial layout to a constraint solver.
Key innovations worth calling out:
- Knowledge-first planning: the LLM enumerates concepts before any code is written, so the diagram is grounded in something a textbook would agree with.
- Critic-in-the-loop iteration: a multimodal model judges intermediate renders and drives refinement, catching layout collisions or missing labels.
- Free augmentation via re-optimization: ten distinct renderings per program without any prompt engineering or re-sampling from the LLM.
- Grounded captions by construction: the caption comes from the same idea+plan step that produced the diagram, eliminating alignment noise.
Where it helps and where it will not
The obvious use case is training and evaluating vision-language models on scientific diagrams: chemistry tutors, geometry solvers, textbook-style question answering, and multimodal reasoning benchmarks that need contamination-free data. It is also a plausible substrate for RLHF-style visual reasoning training, since the ground-truth structure of each diagram is known symbolically.
The limits are honest. Coverage is bounded by what Penrose can express, which means anything requiring photorealism, freehand sketches, or unusual visual styles is out of scope. Future efforts will focus on systematically varying Style and Domain programs in Penrose, enabling more flexible and customizable diagram generation. Diagrams also inherit any factual errors the underlying LLM makes during the idea stage, so a critic pass on the concept itself (not just the render) will be important for domains like advanced physics.
Availability
The team plans to release the dataset, benchmark, and the full agent pipeline as an open-source project, which means anyone building a multimodal model can plug Diagramma into their evaluation harness or use the 100k-pair corpus as pretraining data. The OpenReview page hosts the current draft, and the arXiv HTML includes the full ablation tables on knowledge planning, code planning, and critic scoring. Given how cheap generation is at under $400 for six figures of examples, expect derivative datasets aimed at specific domains to follow quickly.