diffusion model (八) Dalle3 技术小结

2023-10-30 22:54

本文主要是介绍diffusion model (八) Dalle3 技术小结,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

paper:https://cdn.openai.com/papers/dall-e-3.pdf

创建时间: 2023-10-25

相关阅读

  • diffusion model(一)DDPM技术小结 (denoising diffusion probabilistic)
  • diffusion model(二)—— DDIM技术小结
  • diffusion model(三)—— classifier guided diffusion model
  • diffusion model(四)文生图diffusion model(classifier-free guided)
  • diffusion model(五)stable diffusion底层原理(latent diffusion model, LDM
  • diffusion model(六)Dalle2技术小结
  • diffusion model(七) diffusion model是一个zero-shot 分类器

Motivation

目前的文生图模型所生成的图片很难对应prompt的一些细节的描述,并且经常会忽视某些单词。作者假设造成生成与prompt不一致的原因是因为训练样本中image caption的噪声导致。针对上述问题,作者训练了一个image-captioner对之前训练样本的caption进行重写,随后重新训练text-to-image模型。

OpenAI没有公开Dalle3的架构,这个技术报告仅包含部分data engineering的工作

Method

method部分主要阐述作者如何对公开数据集的caption进行改写。

data Recaptioning

作者认为现在的large-scale数据集有这么一个特点:图片描述基本只包含主体而忽视了背景、常识关系等更为细节的描述。作者认为,图片比较重要的细节应当包括:

  • 物体存在的场景。如:在厨房的水槽(场景为厨房)、人行道上的标志
  • 物体在场景的位置、物体的数量
  • 物体的颜色,大小
  • 图片中的文本

基于以上考虑,作者重新构建了训练样本的caption。

不妨将数据集中的图片-文本pair记作 ( t , i ) (t, i) (t,i)其中 i i i是图片, t t t是文本描述。

base captioner training

此处将image用CLIP的image encode提取图片表征,送入到image captioner模型中作为上下文,随后用Language Model的任务进行训练即可。训练数据为text-to-image的图片文本对。公式化如下:
L ( t , i ) = ∑ j log ⁡ P ( t j ∣ t j − k , … , t j − 1 ; z j ; F ( i ) ; Θ ) (1) L ( t , i ) = \sum _ { j } \log P ( t _ { j } \vert t _ { j - k } , \dots , t _ { j - 1 } ; z _ { j } ; F ( i ) ; \Theta ) \tag{1} L(t,i)=jlogP(tjtjk,,tj1;zj;F(i);Θ)(1)
其中:

  • L ( t , i ) L(t, i) L(t,i)是目标函数

  • F ( ⋅ ) F(\cdot) F()CLIP的image encoder部分模型。

  • Θ \Theta Θ是模型需要训练的参数

论文没说用的什么模型,也没有描述如何将图片特征融入到image captioner模型中。

一般来说图片特征融入的方式有:

  • 作为soft visual token。将图片的embedding对齐到language model的输入层,与其它文本token concat起来。
  • 作为language model里面cross-attention的key, value
  • 将其与language model里面self-attention的key,value进行concat。如: [ k ] → [ k , F ( i ) ] [k] \rightarrow [k, F(i)] [k][k,F(i)]

训练完成,我们可以得到一个image caption模型。给定图片,模型会生成图片的描述。但是,该模型生成的caption依旧有上面提出的“忽视了背景、常识关系等更为细节的描述”的问题。因此需要对captioner进行进一步微调。

base captioner fine-tune

在微调阶段,同样分为两步

(一)short captioner

作者构建了一个较小的图片-文本对数据集,在这个数据集上文本仅包含对图片主体部分的描述(称为"short synthetic captions")。随后对Step1的captioner进行微调。

(二) descriptive captioner

在该阶段作者又构建了一个数据集。这个数据集的文本包含"背景、常识关系等更为细节的描述”(称为“descriptive synthetic captions”)。随后对Step1的captioner进行微调。
在这里插入图片描述

the validity of re-captioner

为了评估re-captioner方案的有效性。作者训练了3个text-to-image模型,效果如下图所示。

  • 模型一:仅用ground-truth的caption
  • 模型二:用95% “short synthetic captions”,和5%ground-truth的caption
  • 模型三:用95% “descriptive synthetic captions”,和5%ground-truth的caption
    在这里插入图片描述

可能有读者会问为什么混合的比例是95%。作者分别进行了混合比例(65%,80%,90%,95%)的对比实验。(作者说65%的效果远低于其它,就没有放图)。
在这里插入图片描述

从上述的实验结果可以看出,“descriptive synthetic captions”比例越多,指标越好。但是这也带来了一个问题:

“训练数据的caption都是非常的descriptive与用户实际使用的prompt差异过大,这将导致out of domain的问题“

为了解决问题DALLE3接入了large language model(LLM)。实现方式是:用LLM来将用户的prompt进行改写使其尽可能的“descriptive”

prompt如下:

you are a part of team of bots that creates image. You work with an assistant bot that will draw anything you say in square brackets . For example , outputting "a beautiful morning in the woods with the sun peaking through the trees" will trigger your partner bot to output an image of a forest morning , as described .
You will be prompted by people looking to create detailed , amazing images. The way to accomplish this is to take their short prompts and make them extremely detailed and descriptive .
There are a few rules to follow: - You will only ever output a single image description per user request .- Sometimes the user will request that you modify previous captions . In this case , you should refer to your previous conversations with the user and make the modifications requested .
- When modifications are requested , you should not simply make the description longer. You should refactor the entire description to integrate the suggestions .
- Other times the user will not want modifications , but instead want a new image. In this case , you should ignore your previous conversation with the user.
- Image descriptions must be between 15 -80 words. Extra words will be ignored .{" role ": "user", " content ": "Create an imaginative image descriptive caption or modify an earlier \ caption for the user input: "a man holding a sword \""} , {" role ": " assistant ", " content ": "a pale figure with long white hair stands in the center of a dark \ forest , holding a sword high above his head.the blade glows with a blue light , casting a soft glow on the trees and bushes surrounding him ."}, {" role ": "user", " content ": "Create an imaginative image descriptive caption or modify an earlier caption \ for the user input: "make the light red"}, {" role ": " assistant ", " content ": "a pale figure with long white hair stands in the center of a dark forest , \ holding a sword high above his head.the blade glows with a red light , casting a warm glow on the trees and bushes surrounding him ."}, {" role ": "user", " content ": "Create an imaginative image descriptive caption or modify an earlier caption for the \ user input: "draw a frog playing dominoes "}, {" role ": " assistant ", " content ": "a frog sits on a worn table playing a game of dominoes with an elderly raccoon .the table is covered in a green cloth , and the frog is wearing a jacket and a pair of jeans. The scene is set in a forest , with a large tree in the background ."}

Result

作者从CLIP score, Drawbench, T2I-CompBench, Human Evaluations四个方面对Dalle3和其它生成模型进行了评估。

在这里插入图片描述

注意:Dalle3并不是在Dalle2基础上用了re-caption的方式进行微调,还加入了其它的优化,但作者没有开源。论文的指标是整体的指标。

就如原文写到:
“DALL-E 3 has many improvements over DALL-E 2, many of which are not covered in this document and could not be ablated for time and compute reasons. The evaluation metrics discussed in this document should not be construed as a performance comparison resulting from simply training on synthetic captions.”

在这里插入图片描述

一些生成的sample:

在这里插入图片描述

小结

这篇dalle3的技术报告看似写了19页,但没太多实质性的内容。OpenAI真的往close方向越走越远!有趣的是,没多久google也在arxiv发了一篇类似方案的paper《A Picture is Worth a Thousand Words: Principled Recaptioning Improves Image Generation》,还在paper里的related word注明比dalle3有更多细节:

Concurrently with our work, Dall-E 3 [25] proposes to use an automatic captioning system to regenerate the captions used to train a T2I model. Our work uses an open model (Stable Diffusion) and we provide more details and focus more on analysis and evaluation, but otherwise the main ideas are very similar.

这篇关于diffusion model (八) Dalle3 技术小结的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/311114

相关文章

MySQL 分区与分库分表策略应用小结

《MySQL分区与分库分表策略应用小结》在大数据量、复杂查询和高并发的应用场景下,单一数据库往往难以满足性能和扩展性的要求,本文将详细介绍这两种策略的基本概念、实现方法及优缺点,并通过实际案例展示如... 目录mysql 分区与分库分表策略1. 数据库水平拆分的背景2. MySQL 分区策略2.1 分区概念

Python基础语法中defaultdict的使用小结

《Python基础语法中defaultdict的使用小结》Python的defaultdict是collections模块中提供的一种特殊的字典类型,它与普通的字典(dict)有着相似的功能,本文主要... 目录示例1示例2python的defaultdict是collections模块中提供的一种特殊的字

Pydantic中model_validator的实现

《Pydantic中model_validator的实现》本文主要介绍了Pydantic中model_validator的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价... 目录引言基础知识创建 Pydantic 模型使用 model_validator 装饰器高级用法mo

Spring Security方法级安全控制@PreAuthorize注解的灵活运用小结

《SpringSecurity方法级安全控制@PreAuthorize注解的灵活运用小结》本文将带着大家讲解@PreAuthorize注解的核心原理、SpEL表达式机制,并通过的示例代码演示如... 目录1. 前言2. @PreAuthorize 注解简介3. @PreAuthorize 核心原理解析拦截与

C++变换迭代器使用方法小结

《C++变换迭代器使用方法小结》本文主要介绍了C++变换迭代器使用方法小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录1、源码2、代码解析代码解析:transform_iterator1. transform_iterat

SpringBoot3实现Gzip压缩优化的技术指南

《SpringBoot3实现Gzip压缩优化的技术指南》随着Web应用的用户量和数据量增加,网络带宽和页面加载速度逐渐成为瓶颈,为了减少数据传输量,提高用户体验,我们可以使用Gzip压缩HTTP响应,... 目录1、简述2、配置2.1 添加依赖2.2 配置 Gzip 压缩3、服务端应用4、前端应用4.1 N

SpringBoot实现数据库读写分离的3种方法小结

《SpringBoot实现数据库读写分离的3种方法小结》为了提高系统的读写性能和可用性,读写分离是一种经典的数据库架构模式,在SpringBoot应用中,有多种方式可以实现数据库读写分离,本文将介绍三... 目录一、数据库读写分离概述二、方案一:基于AbstractRoutingDataSource实现动态

Java中的String.valueOf()和toString()方法区别小结

《Java中的String.valueOf()和toString()方法区别小结》字符串操作是开发者日常编程任务中不可或缺的一部分,转换为字符串是一种常见需求,其中最常见的就是String.value... 目录String.valueOf()方法方法定义方法实现使用示例使用场景toString()方法方法

Java中List的contains()方法的使用小结

《Java中List的contains()方法的使用小结》List的contains()方法用于检查列表中是否包含指定的元素,借助equals()方法进行判断,下面就来介绍Java中List的c... 目录详细展开1. 方法签名2. 工作原理3. 使用示例4. 注意事项总结结论:List 的 contain

Java利用JSONPath操作JSON数据的技术指南

《Java利用JSONPath操作JSON数据的技术指南》JSONPath是一种强大的工具,用于查询和操作JSON数据,类似于SQL的语法,它为处理复杂的JSON数据结构提供了简单且高效... 目录1、简述2、什么是 jsONPath?3、Java 示例3.1 基本查询3.2 过滤查询3.3 递归搜索3.4