Home Technology peripherals AI Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills

Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills

Jul 02, 2024 am 01:14 AM
project diffusion model

It turns out that diffusion models can be used not only to generate images and videos, but also to synthesize new programs.

Suppose we give the model a hand-drawn "5" shape graphic, it can modify the program through continuous mutations, and finally get a program that can output the target graphic. Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
This model comes from a research team at the University of California, Berkeley. This new method of program synthesis proposed by them uses a neural diffusion model to directly operate syntax trees.

Paper 1 As Shreyas Kapur, a doctoral student at the school, his supervisor is Stuart Russell, professor of computer science at the school.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
  • Paper title: Diffusion On Syntax Trees For Program Synthesis
  • Paper address: https://arxiv.org/pdf/2405.20519
  • Project address: https://diffusion-diffusion. github.io/
  • Code base: https://github.com/revalo/tree-diffusion

Diffusion models have previously achieved great success in the field of image generation. The team found that by utilizing the diffusion mechanism, the model can learn to iteratively optimize the program while ensuring syntactic validity. The key to this new approach is to enable an efficient debugging process by allowing the model to observe the output of the program at each step.

The ability to iterate has been demonstrated in systems such as AlphaZero, and the iterative nature of the diffusion mechanism will naturally be used in search-based program synthesis.

The team found that by training a value model at the same time as the diffusion model, they could guide the denoising process in it to a program that outputs the desired results. This allows efficient exploration of the program space and makes more informed decisions at every step of the generation process.

To implement this approach, the team chose an inverse graphics task, which assumes that a domain-specific language is used to draw images.

The team said: "The task of reverse engineering is a natural fit for our approach, because a small change in the code can lead to meaningful semantic changes in the resulting image."

For example, if A misplaced shape appears in the image and can be easily seen and positioned in program space. Figure 1 gives some examples.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
The main contributions of this research include:

1. Propose a new method using diffusion on syntax trees
2. Implement the method for the inverse graphics task and find that the new method is superior than the previous method.
Method

In short, the core idea of ​​this method is: develop a denoising diffusion model for syntax trees, similar to the image diffusion model developed for vision tasks.

First, let’s look at a task example from Ellis et al.’s paper “Write, execute, assess: Program synthesis with a repl”: generating a constructed solid geometry (CSG2D) program based on an image. Using CSG2D, we can combine simple primitives like circles and quadrilaterals using Boolean operations like addition and subtraction to create more complex shapes using the following context-free grammar (CFG):
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
in Figure 2 , z₀ is the target program, x₀ is the rendered version of z₀.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
The task is to reverse x₀ to recover z₀. First, the denoising process randomly mutates y=16 to y=10. Then transform the subtree with two shapes on the left into a new subtree with only one shape. The goal here is to train a neural network that can reverse this denoising process, starting from z₃ and x₃, based on the image x₀, to get z₀.

The following will first describe how to add "noise" to the syntax tree, then describe in detail how to train a neural network that reverses this noise, and finally describe how to use this neural network to perform a search.

Sampling small mutations

Let z_t be the program at time t. Let p_N (z_{t+1}|z_t) be the distribution on which program z_t is randomly mutated to z_{t+1}. Here we hope that the p_N mutation satisfies two points: (1) it is small, and (2) it can obtain syntactically valid z_{t+1}.

To do this, the team explored a large body of computer security literature on grammar-based fuzz testing. To ensure that mutations are small, they first define a function σ(z) that gives the "size" of program z. In the experiment, a set of endpoints (terminals) in CFG are defined as primitives.

For example, if written in their CSG2D language, the above primitives would be {Quad, Circle}. When working with this language, the team's approach is to let σ(z) = σ_primitive (z), which counts the number of primitives. σ(z) may also contain options such as depth, number of nodes, etc.

Then, randomly sample the procedure from CFG based on the exact constraint σ_min

In order to mutate a given program z, first generate a set of candidate nodes in a certain σ_small range in its syntax tree:
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Then, uniformly sample a mutation node from this set :
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Since it can read the entire syntax tree and CFG, it knows which generation rule can get m, and thus can ensure that syntactically valid mutations are obtained. For example, if m is a number, its replacement should also be a number. If m is a general subexpression, it can be replaced by any general subexpression. Therefore, m' can be sampled, which is a surrogate for m:
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Strategy

Forward process

The team treats the program synthesis problem as an inference problem. Let p (x|z) be an observation model, where x can be any type of observation. The task is to reverse the direction of this observation model, i.e. to obtain a program z given some observation x.

First, take a program z₀ from a data set D, or in this case randomly sample a program from the CFG. That is, sample a z₀ that satisfies σ(z₀) ≤ σ_max. Noise is then added to z₀, taking s steps, where s ∼ Uniform [1, s_max] and s_max is a hyperparameter:
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Then, a conditional neural network is trained that models the following distribution .
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
where ϕ is the parameter of the neural network, z_t is the current program, x_t is the current output of the program, and x₀ is the target output that needs to be solved.

Reverse mutation path

Due to the ability to obtain ground truth mutations, the trajectories sampled can be reversed simply through the forward process Markov chain z₀ → z₁ →... to generate The goal of training a neural network. At first glance, this might seem like a reasonable choice. However, directly training the model to reverse the last mutation risks creating a far noisier signal for the neural network.

For example, in a much larger syntax tree, the mutation path of a color is:
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
The color of the target image x₀ is Red, and the color of the mutated image x₂ is Green.If you simply teach the model to reverse the above Markov chain, you may train the network to turn Green into Blue, even though you can directly train the network to turn Green into Red.

Therefore, in order to create a better training signal, the editing path between the target tree and the mutation tree can be calculated. The team used a tree edit path algorithm loosely based on tree edit distance. The generalized tree edit distance problem allows insertion, deletion, and replacement of arbitrary nodes. But the setting here is different. Tree editing can only be achieved in an action space that only allows small mutations.

For two trees z_A and z_B, their syntactic structures can be compared in a linear way. For changes that satisfy ≤ σ_small, they are added to the mutation list. For changes > σ_small, look for the first mutation that reduces the distance between the two trees. Therefore, for any two programs z_A and z_B, the first step of the mutation path can be calculated in O (|z_A| + |z_B|) time.
Value Network and Search

The team also trained a value network v_ϕ (x_A, x_B), whose input is two rendered images x_A and x_B, and the prediction is to generate these two The edit distance between the underlying programs of the image. Since the edit distance between trees has been calculated during training, for any pair of rendered images, their ground truth procedural edit distance is directly obtained, which can be used to train this value in a supervised manner network.

Using the above new strategy and new value network proposed by the team, it is possible to perform beam search for any target image x₀ and a randomly initialized program z_t. At each iteration, a set of nodes in the search tree with the most promising values ​​is maintained and only these nodes are expanded. Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Architecture

Figure 3 shows an overview of the newly proposed neural architecture.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Their denoising model q_ϕ (z_{t−1}|z_t, x_t; x₀) uses the visual- Language model. As for the image encoder, they used an off-the-shelf implementation of NF-ResNet-26; a normalizer-less convolutional architecture that avoids the temporal instability issues when using Batch-Norm.

The team implemented a customized tokenizer that uses their CFG’s endpoint as token. The remainder of the editing model is a small decoder-only Transformer.

They also added two other types of tokens: which serves as a sentence starting token for the model, and token which allows the model to refer to locations within its context.

Given a current image, a target image, and the current tokenized program, train the Transformer model to predict edit positions and replacement text in an autoregressive manner. When making predictions, the decoding process is constrained by the grammar. The team masked the predicted logit to include only edit positions that represent syntactic tree nodes, and only obtained substitutions that were syntactically valid for the selected edit positions.

Here we set σ_small = 2, which means that the network is only allowed to produce edits with less than two primitives. For training data, what they do is sample an infinite stream of random expressions from the CFG. For noise steps s, they randomly select one from [1, 5]. A certain proportion of the samples ρ is completed by randomly sampling new expressions as mutated expressions. They trained for three days using a single NVIDIA A6000 GPU.
Experiments

They conducted experiments on 4 domain-specific graphics languages: CSG2D, CSG2D-Sketch, TinySVG, Rainbow.

The selected benchmark methods are "Write, execute, assess: Program synthesis with a repl" proposed by Ellis et al. and "CSGNet: Neural shape parser for constructive solid geometry" proposed by Sharma et al.

Figure 4 compares the performance of the new method with the baseline method.

It can be seen that in the CSG2D and TinySVG environments, the newly proposed tree diffusion strategy is significantly better than the strategy of the previous method.The performance of this strategy can be further improved if combined with beam search, allowing the problem to be solved with fewer calls to the renderer than other methods.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
The figure below gives some successful examples of the new system and the output of the benchmark method. As you can see, the new system can fix smaller problems that other methods miss.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
The following video shows two examples of sketch-based recovery procedures using the CSG2D-Sketch language, which shows that the observation model does not necessarily require deterministic rendering; it can also be composed of random hand-drawn images. Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skillsCompose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
To understand the impact of these new designs, the team also conducted ablation experiments using a smaller Transformer model in a simplified Rainbow environment, the results are shown in Figure 5. Overall, the results of these design choices are proven.
Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills
Please refer to the original paper for more details.

The above is the detailed content of Compose a graphics program just by looking at a hand-drawn sketch. Berkeley, California, teaches diffusion models new skills. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1262
29
C# Tutorial
1235
24
The author of ControlNet has another hit! The whole process of generating a painting from a picture, earning 1.4k stars in two days The author of ControlNet has another hit! The whole process of generating a painting from a picture, earning 1.4k stars in two days Jul 17, 2024 am 01:56 AM

It is also a Tusheng video, but PaintsUndo has taken a different route. ControlNet author LvminZhang started to live again! This time I aim at the field of painting. The new project PaintsUndo has received 1.4kstar (still rising crazily) not long after it was launched. Project address: https://github.com/lllyasviel/Paints-UNDO Through this project, the user inputs a static image, and PaintsUndo can automatically help you generate a video of the entire painting process, from line draft to finished product. follow. During the drawing process, the line changes are amazing. The final video result is very similar to the original image: Let’s take a look at a complete drawing.

Topping the list of open source AI software engineers, UIUC's agent-less solution easily solves SWE-bench real programming problems Topping the list of open source AI software engineers, UIUC's agent-less solution easily solves SWE-bench real programming problems Jul 17, 2024 pm 10:02 PM

The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com The authors of this paper are all from the team of teacher Zhang Lingming at the University of Illinois at Urbana-Champaign (UIUC), including: Steven Code repair; Deng Yinlin, fourth-year doctoral student, researcher

From RLHF to DPO to TDPO, large model alignment algorithms are already 'token-level' From RLHF to DPO to TDPO, large model alignment algorithms are already 'token-level' Jun 24, 2024 pm 03:04 PM

The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com In the development process of artificial intelligence, the control and guidance of large language models (LLM) has always been one of the core challenges, aiming to ensure that these models are both powerful and safe serve human society. Early efforts focused on reinforcement learning methods through human feedback (RL

Posthumous work of the OpenAI Super Alignment Team: Two large models play a game, and the output becomes more understandable Posthumous work of the OpenAI Super Alignment Team: Two large models play a game, and the output becomes more understandable Jul 19, 2024 am 01:29 AM

If the answer given by the AI ​​model is incomprehensible at all, would you dare to use it? As machine learning systems are used in more important areas, it becomes increasingly important to demonstrate why we can trust their output, and when not to trust them. One possible way to gain trust in the output of a complex system is to require the system to produce an interpretation of its output that is readable to a human or another trusted system, that is, fully understandable to the point that any possible errors can be found. For example, to build trust in the judicial system, we require courts to provide clear and readable written opinions that explain and support their decisions. For large language models, we can also adopt a similar approach. However, when taking this approach, ensure that the language model generates

arXiv papers can be posted as 'barrage', Stanford alphaXiv discussion platform is online, LeCun likes it arXiv papers can be posted as 'barrage', Stanford alphaXiv discussion platform is online, LeCun likes it Aug 01, 2024 pm 05:18 PM

cheers! What is it like when a paper discussion is down to words? Recently, students at Stanford University created alphaXiv, an open discussion forum for arXiv papers that allows questions and comments to be posted directly on any arXiv paper. Website link: https://alphaxiv.org/ In fact, there is no need to visit this website specifically. Just change arXiv in any URL to alphaXiv to directly open the corresponding paper on the alphaXiv forum: you can accurately locate the paragraphs in the paper, Sentence: In the discussion area on the right, users can post questions to ask the author about the ideas and details of the paper. For example, they can also comment on the content of the paper, such as: "Given to

A significant breakthrough in the Riemann Hypothesis! Tao Zhexuan strongly recommends new papers from MIT and Oxford, and the 37-year-old Fields Medal winner participated A significant breakthrough in the Riemann Hypothesis! Tao Zhexuan strongly recommends new papers from MIT and Oxford, and the 37-year-old Fields Medal winner participated Aug 05, 2024 pm 03:32 PM

Recently, the Riemann Hypothesis, known as one of the seven major problems of the millennium, has achieved a new breakthrough. The Riemann Hypothesis is a very important unsolved problem in mathematics, related to the precise properties of the distribution of prime numbers (primes are those numbers that are only divisible by 1 and themselves, and they play a fundamental role in number theory). In today's mathematical literature, there are more than a thousand mathematical propositions based on the establishment of the Riemann Hypothesis (or its generalized form). In other words, once the Riemann Hypothesis and its generalized form are proven, these more than a thousand propositions will be established as theorems, which will have a profound impact on the field of mathematics; and if the Riemann Hypothesis is proven wrong, then among these propositions part of it will also lose its effectiveness. New breakthrough comes from MIT mathematics professor Larry Guth and Oxford University

The first Mamba-based MLLM is here! Model weights, training code, etc. have all been open source The first Mamba-based MLLM is here! Model weights, training code, etc. have all been open source Jul 17, 2024 am 02:46 AM

The AIxiv column is a column where this site publishes academic and technical content. In the past few years, the AIxiv column of this site has received more than 2,000 reports, covering top laboratories from major universities and companies around the world, effectively promoting academic exchanges and dissemination. If you have excellent work that you want to share, please feel free to contribute or contact us for reporting. Submission email: liyazhou@jiqizhixin.com; zhaoyunfeng@jiqizhixin.com. Introduction In recent years, the application of multimodal large language models (MLLM) in various fields has achieved remarkable success. However, as the basic model for many downstream tasks, current MLLM consists of the well-known Transformer network, which

Axiomatic training allows LLM to learn causal reasoning: the 67 million parameter model is comparable to the trillion parameter level GPT-4 Axiomatic training allows LLM to learn causal reasoning: the 67 million parameter model is comparable to the trillion parameter level GPT-4 Jul 17, 2024 am 10:14 AM

Show the causal chain to LLM and it learns the axioms. AI is already helping mathematicians and scientists conduct research. For example, the famous mathematician Terence Tao has repeatedly shared his research and exploration experience with the help of AI tools such as GPT. For AI to compete in these fields, strong and reliable causal reasoning capabilities are essential. The research to be introduced in this article found that a Transformer model trained on the demonstration of the causal transitivity axiom on small graphs can generalize to the transitive axiom on large graphs. In other words, if the Transformer learns to perform simple causal reasoning, it may be used for more complex causal reasoning. The axiomatic training framework proposed by the team is a new paradigm for learning causal reasoning based on passive data, with only demonstrations

See all articles