普通视图

发现新文章,点击刷新页面。
昨天以前Enderfga's blog

GPT4泄露的技术细节

作者 Enderfga
2023年7月11日 09:12

From Twitter of Yam Peleg.

GPT-4's details are leaked.

It is over. Everything is here:

Parameters count

GPT-4 is more than 10x the size of GPT-3. We believe it has a totalof ~1.8 trillion parameters across 120 layers.

GPT-4的规模是GPT-3的10倍以上。我们认为它拥有约1,800亿个参数,分布在120层。

Mixture Of Experts -Confirmed

OpenAl was able to keep costs reasonable by utilizing a mixture ofexperts(MoE) model.

They utilizes 16 experts within their model, each is about ~111Bparameters for MLP 2 of these experts are routed to per forwardpass.

OpenAI通过使用专家混合(MoE)模型,能够将成本控制在合理的范围内。

他们的模型利用了16个专家,每个专家大约拥有1110亿个参数,其中每次前向传递(forwardpass)使用其中的2个专家。

MoE Routing

While the literature talks a lot about advanced routing algorithmsfor choosing which experts to route each token to, OpenAl's is allegedlyquite simple, for the current GPT-4 model.

There roughly ~55B shared parameters for attention.

尽管文献中谈到了很多关于选择将每个标记(token)路由到哪些专家的先进路由算法,但据称OpenAI在当前的GPT-4模型中采用的路由方法相当简单。

在注意力机制中,大约有550亿个共享参数。

Inference

Each forward pass inference (generation of 1 token) only utilizes~280B parameters and ~560 TFLOPs. This contrasts with the ~1.8 trillionparameters and ~3,700 TFLOP that would be required per forward pass of apurely dense model.

每次前向传递的推理(生成一个标记)只使用了大约280亿个参数和560TFLOPS的计算量。这与纯密集模型每次前向传递所需的约1,800亿个参数和3,700TFLOPS形成了对比。

Dataset

GPT-4 is trained on ~13T tokens. These are not unique tokens, theycount the epochs as more tokens as well.

Epoch number: 2 epochs for text-based data and 4 for code-baseddata.

There is millions of rows of instruction fine-tuning data fromScaleAl & internally.

GPT-4的训练使用了大约130万亿个标记(tokens)。这些标记不是唯一的标记,还计算了多个时期(epochs)的标记数量。

对于基于文本的数据,使用了2个时期,对于基于代码的数据,使用了4个时期。

此外,还有来自ScaleAl和内部的数百万行指令微调数据。

GPT-4 32K

There was an 8k context length (seq len) for the pre-training phase.The 32k seq len version of GPT-4 is based on fine-tuning of the 8k afterthe pre-training.

在预训练阶段,GPT-4使用了8,000个上下文长度(序列长度)。而32,000个序列长度的GPT-4版本是在预训练后对8,000个序列长度进行微调得到的。

Batch Size

The batch size was gradually ramped up over a number of days on thecluster, but by the end, OpenAl was using a batch size of 60 million!This, of course, is “only” a batch size of 75 million tokens per expertdue to not every expert seeing all tokens.

在集群上的几天时间里,批量大小逐渐增加,但最终OpenAI使用了6000万的批量大小!当然,由于并非每个专家都能看到所有的标记,因此每个专家实际上只处理了7500万个标记的批量大小。

For the real batch size

Divide this number by the seq len to get the real batch size. Juststop with this misleading numbers already.

将这个数字除以序列长度以获取实际的批量大小。请不要再提供这种误导性的数字了。

Parallelism Strategies

To parallelize across all their A100s GPUs

They utilized 8-way tensor parallelism as that is the limit forNVLink. Beyond that, they are using 15-way pipeline parallelism.

(likely used ZeRo Stage 1.lt is possiblethey used block-levelFSDP)

为了在所有A100 GPU上实现并行计算,他们采用了8路张量并行(tensorparallelism),因为这是NVLink的限制。此外,他们还使用了15路管道并行(pipelineparallelism)。

很可能他们使用了ZeRo阶段1,同时也可能使用了块级FSDP(Fully ShardedData Parallelism)。

Training Cost

OpenAl's training FLOPS for GPT-4 is ~2.15e25,

on~25,000 A100s for 90 to 100 days at about 32% to 36% MFU.

Part of this extremely low utilization is due to an absurd number offailures requiring checkpoints that needed to be restarted from.

If their cost in the cloud was about $1 per A100 hour, the trainingcosts for this run alone would be about $63 million

(Today, the pre-training could be done with ~8,192 H100 in ~55 daysfor $21.5 million at $2 per H100 hour.)

OpenAI的GPT-4训练的浮点运算速度(FLOPS)约为2.15e25次。

在大约25,000个A100GPU上进行训练,持续时间为90至100天,利用率约为32%至36%。

这种极低的利用率部分是由于大量的故障导致需要重新启动检查点。

如果他们在云端的成本约为每个A100每小时1美元,单单这次训练的成本将约为6300万美元。

(现在,使用大约8,192个H100GPU进行预训练,需要大约55天时间,成本为2150万美元,每个H100每小时2美元。)

Mixture of Expert Tradeoffs

There are multiple MoE tradeoffs taken:

For example, MoE is incredibly difficult to deal with on inferencebecause not every part of the model is utilized on every tokengeneration.

This means parts may sit dormant when other parts are being used.When serving users, this really hurts utilization rates.

Researchers have shown that using 64 to 128 experts achieves betterloss than 16 experts, but that's purely research.

There are multiple reasons to go with fewer experts. One reason forOpenAI choosing 16 experts is because more experts are difficult togeneralize at many tasks. More experts can also be more difficult toachieve convergence with.

With such a large training run, OpenAI Instead chose to be moreconservative onthe number of experts.

有多个专家混合(MoE)的权衡被考虑:

例如,在推理过程中,处理MoE非常困难,因为并非每个模型的部分在每个标记生成过程中都被利用。

这意味着某些部分可能处于闲置状态,而其他部分正在被使用。在为用户提供服务时,这会极大地降低利用率。

研究人员已经证明,使用64到128个专家比使用16个专家可以获得更好的损失结果,但这仅仅是研究结果。

选择较少的专家有多个原因。OpenAI选择使用16个专家之一的原因是因为更多的专家在许多任务上很难进行泛化。更多的专家也可能更难实现收敛。

在如此庞大的训练过程中,OpenAI选择在专家数量上更加保守。

GPT-4 Inference Cost

GPT-4 costs 3x that of the 175B parameter Davinchi.

This is largely due to the larger clusters required for GPT-4 andmuch lower utilization achieved.

AN estimate of it's costs is $0.0049 cents per 1k tokens for 128A100s to inference GPT-4 8k seq len and $0.0021cents per 1k tokens for128 H100's to inference GPT-4 8k seq len. It should be noted, we assumedecent high utilization,and keeping batch sizes high.

GPT-4的成本是1750亿参数的Davinci模型的3倍。

这主要是由于GPT-4需要更大规模的集群,并且实现了更低的利用率。

据估计,使用128个A100 GPU进行GPT-48,000个序列长度的推理,每1,000个标记的成本约为0.0049美分;使用128个H100GPU进行GPT-48,000个序列长度的推理,每1,000个标记的成本约为0.0021美分。需要注意的是,我们假设了良好的高利用率,并保持了较高的批量大小。

Multi-Query Attention

OpenAl are using MQA just like everybody else.

Because of that only 1 head is needed and memory capacity can besignificantly reduced for the KV cache. Even then, the 32k seq len GPT-4definitely cannot run on 40GB A10Os, and the 8k is capped onmax bsz.

OpenAI也像其他人一样使用了MQA(Multi-QKV Attention)。

由于使用了MQA,只需要一个注意力头(head),并且可以显著降低KV缓存的内存需求。即便如此,32,000个序列长度的GPT-4肯定无法在40GB的A10O上运行,而8,000个序列长度则有最大批量大小的限制。

Continuous batching

OpenAl implements both variable batch sizes and continuous batching.This is so as to allow some level of maximum latency as well optimizingthe inference costs.

OpenAI实现了可变批量大小和连续批处理。这样做可以在一定程度上允许最大延迟,并优化推理成本。

Vision Multi-Modal

It is a separate vision encoder from the text encoder, withcross-attention. The architecture is similar to Flamingo. This adds moreparameters on top of the 1.8T of GPT-4. lt is fine-tuned with another ~2trillion tokens, after the text only pre-training.

On the vision model, OpenAl wanted to train it from scratch, but itwasn't mature enough, so they wanted to derisk it by starting withtext.

One of the primary purposes of this vision capability is forautonomous agents able to read web pages and transcribe what's in imagesand video.

Some of the data they train on is joint data (rendered LaTeX/text),screen shots of web page, youtube videos: samplingframes, and runWhisper around it to get transcript.

GPT-4引入了一个与文本编码器分离的独立视觉编码器,并具有交叉注意力机制。其架构类似于Flamingo模型。这使得GPT-4的参数量在1,800亿的基础上增加了更多。在仅进行文本预训练之后,还对该视觉模型进行了约2万亿个额外的微调标记。

在视觉模型方面,OpenAI原本希望从头开始训练,但该模型尚未足够成熟,所以他们选择通过从文本开始来减轻风险。

该视觉功能的主要目的之一是使自主代理能够阅读网页并转录图像和视频中的内容。

他们训练的一部分数据是联合数据,包括渲染的LaTeX/文本、网页截图、YouTube视频(采样帧),并使用Whisper技术对其进行转录。

Speculative Decoding

OpenAl might be using speculative decoding on GPT-4's inference. (notsure100%)

The idea is to use a smaller faster model to decode several tokens inadvance, and then feeds them into a large oracle model as a singlebatch.

lf the small model was right about its predictions-the larger modelagrees and we can decode several tokens in a single batch.

But if the larger model rejects the tokens predicted by the draftmodel then the rest of the batch is discarded. And wecontinue with thelarger model.

The conspiracy theory that the new GPT-4 quality had beendeteriorated might be simply because they are letting the oracle modelaccept lower probability sequences from the speculative decodingmodel.

OpenAI可能正在使用GPT-4推理中的推测解码(speculativedecoding),但无法确定。

这种方法是使用一个更小更快的模型提前解码多个标记,然后将它们作为一个批次输入到大型的预测模型中。

如果小型模型的预测正确,大型模型会同意并可以一次性解码多个标记。

但是,如果大型模型拒绝了草稿模型预测的标记,那么批次中的剩余部分将被丢弃,并继续使用大型模型。

有一种阴谋论认为,GPT-4的质量下降是因为他们让预测模型接受了由推测解码模型生成的低概率序列。

请注意,以上内容仅为推测,实际情况可能与之有所不同。

Inference Architecture

The inference runs on a cluster of 128 GPUs.

There are multiple of these clusters in multiple datacenters indifferent locations.

It is done in 8-way tensor parallelism and 16-way pipelineparallelism.

Each node of 8 GPUs has only ~130B parameters, or less than 30GB perGPU at FP16 and less than 15GB at FP8/int8.

The model has 120, so it fits in 15 different nodes. [Possibly thethere are less layers on the first node since it needs to also computethe embeddings]

According to these numbers: OpenAl should have trained on 2x thetokens if they were trying to go by chinchilla'soptimal.

[let alone surpass it like we do]

This goes to show that they are strugglingto get high qualitydata.

推理过程在由128个GPU组成的集群上运行。

这些集群分布在不同地点的多个数据中心中。

推理过程采用8路张量并行和16路管道并行。

每个包含8个GPU的节点只有约1,300亿个参数,即每个GPU约30GB(FP16)或15GB(FP8/INT8)。

模型有120层,因此需要15个不同的节点来容纳模型。(可能第一个节点的层数较少,因为它还需要计算嵌入层)

根据这些数字,如果OpenAI试图按照chinchilla的最优设置进行训练,他们应该训练2倍的标记。

这表明他们在获取高质量数据方面遇到了困难。

Why no FSDP?

A possible reason for this could be that some of the hardware infrathey secured is of an older generation.

This is pretty common at local compute clusters as theorganisationusually upgrade the infra in several "waves" to avoid acomplete pause ofoperation.

With such a high amount of pipeline parallelism it is very likelythat just like the rest of us they suffer from the "batch bubble":slight idle timebetween batches.

Again: There is no magic.

They know what they are doing but it is not magic.

一个可能的原因是,他们所使用的硬件基础设施中有一部分是较旧一代的。

这在本地计算集群中非常常见,通常组织会分几个"波次"进行基础设施的升级,以避免完全停止运营。

由于存在如此高的管道并行性,他们很可能像其他人一样遭受"批处理泡沫"的影响:批次之间存在轻微的空闲时间。

再次强调:没有什么魔法。

他们知道自己在做什么,但这并非魔法。


OpenAI是将GPT-4的架构保密,这并不是因为对人类存在着某种潜在风险,而是因为他们所构建的东西是可复制的。实际上,我们预计在不久的将来,谷歌、Meta、Anthropic、Inflection、Character、腾讯、字节跳动、百度等公司都将拥有与GPT-4同等甚至更强大的模型能力。

不要误会,OpenAI的工程能力非常出色,他们所构建的东西令人难以置信,但是他们所采取的解决方案并非神奇。这是一个优雅的解决方案,需要考虑许多复杂的权衡。扩大规模只是战斗的一部分。OpenAI最持久的优势在于他们在实际应用中拥有最多的用户、领先的工程人才,并且可以通过未来的模型继续超越其他竞争对手。

最优化理论与算法

作者 Enderfga
2023年5月31日 15:30

期中与期末,笔记1链接;笔记2链接。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
% 利用最速梯度下降法求解函数的极小点

% 函数定义
f = @(x) 0.5*x(1)^2 + x(2)^2;

% 梯度定义
grad_f = @(x) [x(1); 2*x(2)];

% 初始值和收敛阈值
x0 = [2; 1];
epsilon = 1e-2;

% 最速梯度下降法
alpha = 0.1; % 初始步长
x = x0;
grad = grad_f(x);
iter = 0;

while norm(grad) > epsilon
% 计算步长
% 这里可以使用线搜索方法来选择合适的步长 alpha,如 Armijo 规则或 Wolfe 条件

% 更新变量
x = x - alpha * grad;
grad = grad_f(x);

iter = iter + 1;
end

% 输出结果
fprintf('最小值点: (%f, %f)\n', x(1), x(2));
fprintf('迭代次数: %d\n', iter);

% 利用牛顿法求解函数的极小点

% 函数定义
f = @(x) 100*(x(2) - x(1)^2)^2 + (1 - x(1))^2;

% 梯度定义
grad_f = @(x) [-400*x(1)*(x(2) - x(1)^2) - 2*(1 - x(1));
200*(x(2) - x(1)^2)];

% Hessian 矩阵定义
hessian = @(x) [1200*x(1)^2 - 400*x(2) + 2, -400*x(1);
-400*x(1), 200];

% 初始值和收敛阈值
x0 = [-2; 2];
epsilon = 1e-2;

% 牛顿法
x = x0;
grad = grad_f(x);
iter = 0;

while norm(grad) > epsilon
% 计算 Hessian 矩阵和其逆矩阵
H = hessian(x);
inv_H = inv(H);

% 更新变量
x = x - inv_H * grad;
grad = grad_f(x);

iter = iter + 1;
end

% 输出结果
fprintf('最小值点: (%f, %f)\n', x(1), x(2));
fprintf('迭代次数: %d\n', iter);

% 利用共轭梯度法求解方程组的根

% 原始方程组的系数矩阵 A
A = [4, -3; 2, 1];

% 原始方程组的右侧向量 b
b = [11; 13];

% 转化为对称正定矩阵 B = A^T * A
B = A' * A;

% 转化后的方程组的右侧向量
b_new = A' * b;

% 初始值和收敛阈值
x0 = [0; 0];
epsilon = 1e-6;

% 共轭梯度法
x = x0;
r = b_new - B * x;
p = r;
iter = 0;

while norm(r) > epsilon
alpha = (r' * r) / (p' * B * p);
x = x + alpha * p;
r_new = r - alpha * B * p;
beta = (r_new' * r_new) / (r' * r);
p = r_new + beta * p;
r = r_new;
iter = iter + 1;
end

% 输出结果
fprintf('方程的根: (%f, %f)\n', x(1), x(2));
fprintf('迭代次数: %d\n', iter);

% 利用DFP算法求解函数的极小点

% 函数定义
f = @(x) x(1)^2 + 2*x(2)^2 - 4*x(1) - 2*x(1)*x(2);

% 梯度定义
grad_f = @(x) [2*x(1) - 4 - 2*x(2); 4*x(2) - 2*x(1)];

% 初始点和初始近似Hessian矩阵
x0 = [1; 1];
H0 = eye(2);

% 最大迭代次数和停止迭代的阈值
max_iter = 100;
epsilon = 1e-6;

% DFP算法
x = x0;
H = H0;
g = grad_f(x);
iter = 0;

while norm(g) > epsilon && iter < max_iter
d = -H * g; % 计算搜索方向

% 使用线搜索方法选择合适的步长
alpha = 1; % 这里可以使用固定步长或者其他线搜索方法

x_new = x + alpha * d;
g_new = grad_f(x_new);
s = x_new - x;
y = g_new - g;

rho = 1 / (y' * s);
H = (eye(2) - rho * s * y') * H * (eye(2) - rho * y * s') + rho * s * s'; % 更新近似Hessian矩阵

x = x_new;
g = g_new;
iter = iter + 1;
end

% 输出结果
fprintf('最小值点: (%f, %f)\n', x(1), x(2));
fprintf('迭代次数: %d\n', iter);


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
%% 第一题
% 定义目标函数
fun = @(x) x(1)^2 + x(2)^2;

% 定义约束条件
A = []; b = []; % 无线性不等式约束
Aeq = [1 1]; beq = 1; % 线性等式约束 x1 + x2 = 1
lb = [-Inf, -Inf]; ub = [Inf, 1/4]; % x2 <= 1/4

% 定义初始值
x0 = [0, 0];

% 调用 fmincon 函数求解
options = optimoptions('fmincon','Display','iter','Algorithm','interior-point');
[x,fval] = fmincon(fun, x0, A, b, Aeq, beq, lb, ub, [], options);

% 输出结果
disp('The solution is:'), disp(x)
disp('The minimum value of the objective function is:'), disp(fval)

%% 第二题
% 定义目标函数和罚函数
fun = @(x) x(1)^2 + x(2)^2 + x(3)^2;
g = @(x) abs(x(1) + 2*x(2) - x(3) - 4) + abs(x(1) - x(2) + x(3) + 2);
P = @(x, r) fun(x) + r * g(x);

% 定义初始值和罚项权重
x0 = [0, 0, 0];
r = 1;

% 使用 fminunc 函数求解
options = optimoptions('fminunc','Display','iter','Algorithm','quasi-newton');
[x,fval] = fminunc(@(x) P(x, r), x0, options);

% 输出结果
disp('The solution is:'), disp(x)
disp('The minimum value of the objective function is:'), disp(fval)

%% 第三题
% 定义目标函数
fun = @(x) -(x + 5*sin(5*x) + 10*cos(4*x)); % 注意我们取负值,因为MATLAB的遗传算法默认是求最小值

% 定义遗传算法的参数
numberOfVariables = 1;

% 定义约束上下界
lb = 0;
ub = 10;

% 使用 ga 函数求解
[x,fval] = ga(fun,numberOfVariables,[],[],[],[],lb,ub);

% 输出结果
disp('The solution is:'), disp(x)
disp('The maximum value of the objective function is:'), disp(-fval)

%% 第四题
% 定义目标函数和罚函数
fun = @(x) x(1)^2 + x(2)^2;
g = @(x) x(1) - 2;
P = @(x, r) fun(x) - r * log(g(x));

% 定义初始值和罚项权重
x0 = [3, 0]; % 初始值需要满足约束条件
r = 0.0001;

% 使用 fminunc 函数求解
options = optimoptions('fminunc','Display','iter','Algorithm','quasi-newton');
[x,fval] = fminunc(@(x) P(x, r), x0, options);

% 输出结果
disp('The solution is:'), disp(x)
disp('The minimum value of the objective function is:'), disp(fval)

%% 第五题
% 定义目标函数
fun = @(x) sum(x.^2);

% 定义参数
alphas = [0.001,0.1,0.5, 1, 2, 5]; % 邻域大小
T = 100; % 初始温度
T_min = 1e-3; % 最小温度
cooling_rate = 0.95; % 冷却率
max_iter = 100; % 每个温度下的最大迭代次数

% 定义约束条件
lb = -15 * ones(1, 10); % 下界
ub = 15 * ones(1, 10); % 上界

results = zeros(length(alphas), 2);

for a = 1:length(alphas)
% 初始化解
x = lb + (ub - lb) .* rand(1, 10);
alpha = alphas(a);

T_current = T;
while T_current > T_min
for i = 1:max_iter
% 在邻域中随机生成新解
x_new = x + alpha * (2*rand(1, 10) - 1);
x_new = max(min(x_new, ub), lb); % 确保新解满足约束条件

% 计算目标函数的改变量
delta_f = fun(x_new) - fun(x);

% 如果新解更好,或者满足 Metropolis 准则,则接受新解
if delta_f < 0 || rand() < exp(-delta_f / T_current)
x = x_new;
end
end

% 降低温度
T_current = cooling_rate * T_current;
end

% 记录结果
results(a, :) = [alpha, fun(x)];

% 输出结果
fprintf('For alpha = %f:\n', alpha);
disp('The solution is:'), disp(x)
disp('The minimum value of the objective function is:'), disp(fun(x))
end

% 可视化结果
figure;
semilogy(results(:, 1), results(:, 2), '-o', 'Color', [0.2 0.4 0.6], 'LineWidth', 2, 'MarkerSize', 8);
xlabel('Alpha');
ylabel('Minimum Value of Objective Function');
title('Impact of Alpha on the Solution');



RLHF

作者 Enderfga
2023年3月1日 11:17

RLHF

AligningText-to-Image Models using Human Feedback

  • Google Research ,University of California

  • 2023.2.23

Motivation

深度生成模型在文本到图像合成方面取得了令人印象深刻的成果,但当前的文本到图像模型往往生成与文本提示不够相符的图像。

本文的动机是改进文本到图像合成模型,使其能够更好地与文本提示对齐。

作者的方法比预训练模型更准确地生成具有指定颜色、计数和背景的对象。

Proposal

  • 提出了一种简单而有效的微调方法,用于使用人类反馈对文本到图像模型进行对齐。
  • 使用人类反馈进行微调可以显着提高文本到图像模型的图像文本对齐,在人类评估中,我们的模型在图像文本对齐方面达到了高达47%的改善,但图像保真度略有降低。
  • 学习的奖励函数比CLIP分数更准确地预测了人类对质量的评估。
  • 基于作者学习的奖励函数的采样也可以显着改善图像文本对齐。

Related Work

  • T2I models
  • Evaluating image-text alignment
  • Learning with human feedback

与先前关注利用人类反馈改善语言模型和RL代理的工作相比,该工作探索了使用人类反馈来调整多模式文本到图像模型与人类偏好的方法。许多关于利用人类反馈学习的先前工作都包括学习一个奖励函数并最大化奖励加权可能性(通常被称为监督微调)。受其成功的启发,作者提出了一种利用人类反馈进行微调的方法来改善文本到图像模型。

Method

包括三个阶段:

  1. 首先从一系列文本提示中生成一组不同的图像,这些文本提示旨在测试文本到图像模型的各种功能。
  2. 然后,人类评级者对这些图像提供二进制反馈。
  3. 接下来,训练一个奖励模型,以文本提示和图像作为输入来预测人类反馈。
  4. 最后,我们使用奖励加权对数似然度来微调文本到图像模型,以改善文本图像对齐。

Experiment

实验部分旨在测试人类反馈参与模型微调的有效性。实验用到的模型为 StableDiffusion v1.5

本文方法显著提高了图像 - 文本对齐,具体来说,模型生成的图像中有 50%的样本获得至少三分之二的赞成票(投票数量为 7票或更多赞成票),然而,微调会稍微降低图像保真度(15% 比 10%)。

本文模型生成的图像符合 prompt指定的颜色、计数和背景。值得注意的是,本文模型还能生成没有见过的文本prompt 图像,并且质量非常高

有奖励(绿色)比 CLIP 分数(红色)更符合典型的人类意图。

Limitations and futuredirections

  1. 更细致的人类反馈,存在一些较差的生成,如高饱和度的图像颜色,指示评级者寻找更多样化的失败模式(过度饱和的颜色,不切实际的动物解剖学,物理违规等)将提高这些方面的性能。

  2. 多样化和大型人类数据集,为了简化问题,作者考虑了有限的文本类别(计数,颜色,背景),因此人类反馈也相对简单(好或坏)。由于这一点,人类反馈数据的多样性有限。将其扩展到更主观的文本类别(如艺术创作)和更细致的人类反馈将是未来研究的重要方向。

  3. 不同的目标和算法,为了更新文本到图像模型,作者使用奖励加权的最大似然。然而,与语言领域的先前工作类似,使用RL算法将是一个有趣的方向。作者相信RLHF微调可能会产生更好的模型,因为

    (a)在更新期间使用在线样本生成

    (b)KL正则化可以减轻对奖励函数的过度拟合。

Test to 3d随笔

作者 Enderfga
2023年2月9日 16:51

随便记的笔记

Text-to-3D

NeRF:Representing Scenes as Neural Radiance Fields for View Synthesis

输入为连续的5维坐标(xyz坐标,以及视野角度theta和phi);输出是空间位置的体密度以及该位置的发射射线(这里射线是根据视角变化的)。

  1. 用 network 存体素信息: (x, y, z, , ) (, )
  2. 然后用体素渲染方程获得生成视角图片:光线采样+积分\[C(\mathbf{r})=\int_{t_n}^{t_f} T(t) \sigma(\mathbf{r}(t))\mathbf{c}(\mathbf{r}(t), \mathbf{d}) d t, \text { where } T(t)=\exp\left(-\int_{t_n}^t \sigma(\mathbf{r}(s)) d s\right)\]
  3. 最后与原视角图片计算损失更新网络

DreamFusion:Text-to-3D using 2D Diffusion

三维合成并不存在大规模的标注数据,也没有一个高效的模型架构对3D数据进行降噪

使用NERF的格式,使用预训练的text to2d,加上他们提出的一个基于概率密度蒸馏的loss,证明了预训练图像扩散模型作为先验模型的有效性

Magic3D:High-Resolution Text-to-3D Content Creation

用一个两阶段的优化框架来提高速度和分辨率:利用低分辨率的扩散先验获得一个粗略的模型,并以稀疏的三维哈希网格结构加速。使用粗略表示作为初始化,进一步优化纹理三维网格模型,用高效的可微分渲染器与高分辨率的stablediffusion模型交互。

Point-E:A System for Generating 3D Point Clouds from Complex Prompts

不输出传统意义上的 3D 图像,它会生成点云,或空间中代表 3D形状的离散数据点集

点云更容易合成,但它们无法捕获对象的细粒度形状或纹理,训练了一个额外的人工智能系统来将Point-E 的点云转换为网格

算力和时间需求小 但质量差

Dream3D:Zero-Shot Text-to-3D Synthesis Using 3D Shape Prior and Text-to-ImageDiffusion Models

引入一个显式3D先验形状,来优化CLIP引导的3D优化任务。具体的讲,首先在文本到形状转换时,使用输入文本生成了一个质量的3D形状来作为先验知识。然后使用它来初始化神经辐射场,并使用完整prompt进行优化

❌
❌