1
00:00:00,120 --> 00:00:06,600
And we will come back to this, uh, from week six onwards and do a lot more in the way of discussing
我们将从第六周开始回到这个话题，并以讨论的方式做更多的事情

2
00:00:06,600 --> 00:00:08,480
and understanding evals.
和理解评估。

3
00:00:08,520 --> 00:00:09,920
Such an important topic.
如此重要的话题。

4
00:00:09,960 --> 00:00:10,600
Okay.
好的。

5
00:00:10,760 --> 00:00:13,080
So back back to the project at hand.
回到手头的项目。

6
00:00:13,080 --> 00:00:17,400
In our case, of course, we were very lucky that the metric that we were playing with, the metric
当然，就我们而言，我们非常幸运，我们正在使用的指标

7
00:00:17,400 --> 00:00:23,880
that we had the most insight to, was the business centric metric we were working directly with that
我们最有洞察力的是我们直接使用的以业务为中心的指标

8
00:00:23,920 --> 00:00:25,840
improve the performance of some code.
提高一些代码的性能。

9
00:00:25,920 --> 00:00:26,880
Doesn't happen often.
不经常发生。

10
00:00:26,880 --> 00:00:31,720
I got to tell you, most of the time the model metrics are quite far removed from the actual business
我必须告诉你，大多数时候模型指标与实际业务相去甚远

11
00:00:31,720 --> 00:00:35,040
metric, but in our case, we were working directly with that.
公制，但在我们的例子中，我们直接使用它。

12
00:00:35,040 --> 00:00:41,080
And it was about the performance of C++ with with with the same with needed to have the same output.
这是关于 C++ 的性能，并且需要具有相同的输出。

13
00:00:41,280 --> 00:00:45,840
And so far Gemini 2.5 Pro is our winner.
到目前为止，Gemini 2.5 Pro 是我们的赢家。

14
00:00:45,960 --> 00:00:52,360
It's time now for us to go back to the lab one more time for a harder test, to really put them through
现在是我们再次回到实验室进行更困难的测试的时候了，真正让它们通过

15
00:00:52,400 --> 00:00:56,840
the their final paces and see who we will crown the final winner.
看看他们最后的步伐，看看谁能成为最终的获胜者。

16
00:00:57,080 --> 00:01:01,420
And to shake it up, I've decided to change things around a bit.
为了改变现状，我决定稍微改变一下。

17
00:01:01,580 --> 00:01:09,300
And rather than rather than generating C++ code and translating from Python to C++, I have changed
我没有生成 C++ 代码并从 Python 转换为 C++，而是进行了更改

18
00:01:09,300 --> 00:01:09,500
it.
它。

19
00:01:09,500 --> 00:01:17,140
So we'll be generating from Python to Rust code rust, which happens to be, I think.
所以我们将从 Python 生成 Rust 代码 rust，我认为这恰好是。

20
00:01:17,180 --> 00:01:20,140
I think it is the most loved language.
我认为这是最受欢迎的语言。

21
00:01:20,260 --> 00:01:25,300
According to the StackOverflow developer survey for ten years in a row.
根据 StackOverflow 连续十年的开发者调查。

22
00:01:25,380 --> 00:01:27,740
Most loved ten years.
最喜欢十年。

23
00:01:27,780 --> 00:01:29,380
Let's see if we can figure out why.
让我们看看是否能找出原因。

24
00:01:29,420 --> 00:01:34,940
When we translate a hard challenge from Python to Rust, let's go to curse.
当我们将一个艰巨的挑战从 Python 转换为 Rust 时，我们就去诅咒吧。

25
00:01:34,980 --> 00:01:35,740
Okay.
好的。

26
00:01:35,780 --> 00:01:38,220
Back in curse, we're opening week four.
回到诅咒，我们即将开始第四周。

27
00:01:38,220 --> 00:01:40,260
We're going to day five.
我们即将迎来第五天。

28
00:01:40,860 --> 00:01:42,900
And here we have it.
现在我们有了它。

29
00:01:43,100 --> 00:01:48,300
As a reminder, it is optional to actually execute C++ or rust.
提醒一下，实际执行 C++ 或 Rust 是可选的。

30
00:01:48,340 --> 00:01:49,500
You can do either.
你可以做任何一个。

31
00:01:49,500 --> 00:01:55,580
I'll set this up, this lab up for either one, or you can just run it on the C++ website from yesterday
我将对此进行设置，此实验适用于其中任何一个，或者您可以从昨天开始在 C++ 网站上运行它

32
00:01:55,580 --> 00:01:56,900
or just port the code.
或者只是移植代码。

33
00:01:56,900 --> 00:01:59,280
Don't bother with the running your choice.
不要为你的选择而烦恼。

34
00:01:59,280 --> 00:02:04,400
Also a reminder I will use some expensive models, but you can pick your own or just run it only open
另外提醒一下，我将使用一些昂贵的模型，但您可以选择自己的模型或仅运行它

35
00:02:04,400 --> 00:02:04,920
source.
来源。

36
00:02:05,280 --> 00:02:09,120
It's about the task, it's not about the compilation and so on.
这是关于任务的，而不是关于编译之类的。

37
00:02:09,120 --> 00:02:13,760
So as usual, some imports as usual load in some environment variables.
因此，像往常一样，一些导入照常加载到一些环境变量中。

38
00:02:13,760 --> 00:02:18,040
Make sure we've got everything keeping open router on the list again as well as grok.
确保我们已经将所有保持打开状态的路由器再次放在列表中以及 grok 上。

39
00:02:18,040 --> 00:02:22,680
With a queue we will get all of our client libraries initialized.
通过队列，我们​​将初始化所有客户端库。

40
00:02:22,920 --> 00:02:25,640
And as before, this is the list of models that we'll use.
和以前一样，这是我们将使用的模型列表。

41
00:02:25,640 --> 00:02:27,880
I'm keeping the same set as yesterday.
我保留了和昨天一样的设置。

42
00:02:28,080 --> 00:02:32,800
And here are they are linked to their client libraries okay.
这是他们链接到他们的客户端库的好方法。

43
00:02:33,200 --> 00:02:36,400
Let's now find out about rust.
现在我们就来了解一下关于生锈的知识。

44
00:02:36,400 --> 00:02:42,480
So there's a new function in that systeminfo thing that I added in there which is called rust info.
因此，我在 systeminfo 中添加了一个新函数，称为 rust info。

45
00:02:42,640 --> 00:02:46,880
And if I run that then as well as my system information, it's going to give a whole ton of information
如果我运行它以及我的系统信息，它将提供大量信息

46
00:02:46,880 --> 00:02:53,480
about whether or not I have a rust tool chain installed on my computer, which I do, and then I will
关于我的计算机上是否安装了 Rust 工具链，我安装了，然后我会

47
00:02:54,160 --> 00:02:59,220
run this, that will again ask Gpc5 to give me instructions for how to install rust if I don't have
运行这个，如果我没有，这将再次要求 Gpc5 给我如何安装 rust 的说明

48
00:02:59,220 --> 00:03:04,620
it, so it will give you instructions and this is very optional should you wish.
它会给你指示，如果你愿意的话，这是非常可选的。

49
00:03:04,620 --> 00:03:06,380
You can stick with C++.
您可以坚持使用 C++。

50
00:03:06,420 --> 00:03:09,940
Stick with what we did yesterday if you don't want to mess around, it's fun.
如果你不想搞砸的话，就坚持我们昨天做的事情吧，这很有趣。

51
00:03:09,940 --> 00:03:13,700
If you know the nerd in, you might be interested and might want to do this.
如果您认识这个书呆子，您可能会感兴趣并且可能想要这样做。

52
00:03:13,980 --> 00:03:19,180
It's especially cool if you don't know the language, because there's something very satisfying about
如果您不懂该语言，那就特别酷，因为有一些非常令人满意的东西

53
00:03:19,180 --> 00:03:22,420
seeing a model generating something which looks foreign to you.
看到一个模型生成了一些对你来说看起来很陌生的东西。

54
00:03:22,460 --> 00:03:24,860
You know, it's like, okay, I don't know what this means.
你知道，就像，好吧，我不知道这意味着什么。

55
00:03:24,860 --> 00:03:26,460
I'm going to see if it actually works.
我要看看它是否真的有效。

56
00:03:26,460 --> 00:03:27,860
So I find that kind of cool.
所以我觉得这很酷。

57
00:03:27,980 --> 00:03:32,700
Uh, and, and it has, uh, done it and it's told me that I am already set up.
呃，而且，它已经，呃，完成了，它告诉我，我已经准备好了。

58
00:03:32,700 --> 00:03:38,820
I have rust toolchain, and it's told me that this is the command that I need to run, and it looks
我有 Rust 工具链，它告诉我这是我需要运行的命令，它看起来

59
00:03:38,820 --> 00:03:42,660
like a pretty legit command, and I've just copied that and pasted it down here.
就像一个非常合法的命令，我刚刚复制了它并将其粘贴到这里。

60
00:03:42,660 --> 00:03:48,020
But you can leave this being your C++ one from yesterday if you'd like.
但如果您愿意，可以将其保留为昨天的 C++ 版本。

61
00:03:48,260 --> 00:03:49,220
As you wish.
如你所愿。

62
00:03:49,380 --> 00:03:54,580
Now let's go on to the main part and I begin here I've got language equals rust.
现在让我们进入主要部分，我从这里开始，我的语言等于生锈。

63
00:03:54,580 --> 00:03:58,520
And just change that to C++ if you'd like to stick with C++.
如果您想坚持使用 C++，只需将其更改为 C++。

64
00:03:58,640 --> 00:04:02,240
Everything else should work exactly as yesterday all the way through.
其他一切都应该和昨天一样。

65
00:04:02,440 --> 00:04:05,800
Everything in this code works for either rust or C++.
这段代码中的所有内容都适用于 Rust 或 C++。

66
00:04:06,120 --> 00:04:12,840
Rust, of course, also is a compiled language, so it compiles all the way down to a native machine
当然，Rust 也是一种编译语言，因此它可以一直编译到本机机器

67
00:04:12,840 --> 00:04:14,240
code, just like C++.
代码，就像C++一样。

68
00:04:14,400 --> 00:04:20,360
What famously rust is something which which is considered safe in that it compiles all the way down.
著名的 Rust 是一种被认为是安全的东西，因为它可以一直编译下去。

69
00:04:20,360 --> 00:04:26,240
But what C++ lets you, if you wish, do very dangerous things that can cause the machine to crash horribly
但是，如果您愿意，C++ 可以让您做非常危险的事情，从而导致机器严重崩溃

70
00:04:26,240 --> 00:04:29,000
or cause buffer overflows and security risks.
或造成缓冲区溢出和安全风险。

71
00:04:29,240 --> 00:04:30,960
Rust does not permit that.
Rust 不允许这样做。

72
00:04:30,960 --> 00:04:36,680
So so, uh, we've we've, uh, we're gonna we're gonna see how that affects performance of the code.
所以，呃，我们已经，呃，我们将看看这如何影响代码的性能。

73
00:04:36,680 --> 00:04:38,960
If it does and what we're able to do.
如果确实如此以及我们能够做什么。

74
00:04:39,000 --> 00:04:39,680
Let's see.
让我们来看看。

75
00:04:39,680 --> 00:04:44,600
So, uh, I've got I've got this part, as I say, that that puts in the word rust, but otherwise everything
所以，呃，我已经得到了这部分，正如我所说，其中包含“生锈”一词，但除此之外一切

76
00:04:44,600 --> 00:04:45,840
is exactly the same as before.
和以前一模一样。

77
00:04:45,840 --> 00:04:47,160
The same system prompt.
一样的系统提示。

78
00:04:47,200 --> 00:04:51,360
Your task is to convert Python code into high performance language code.
您的任务是将 Python 代码转换为高性能语言代码。

79
00:04:51,760 --> 00:04:52,920
That'll be rust, of course.
当然，那会生锈。

80
00:04:52,960 --> 00:04:58,830
Respond only with rust Ross code, and it needs to produce identical output in the fastest time.
仅使用 Rust Ross 代码进行响应，并且需要在最快的时间内产生相同的输出。

81
00:04:59,110 --> 00:05:00,830
The same user prompt as before.
与之前相同的用户提示。

82
00:05:00,870 --> 00:05:02,670
The same messages as before.
与之前相同的消息。

83
00:05:02,830 --> 00:05:05,070
The same write output as before.
与之前相同的写入输出。

84
00:05:05,390 --> 00:05:07,270
The same port as before.
与之前相同的端口。

85
00:05:07,270 --> 00:05:07,550
Just.
只是。

86
00:05:07,550 --> 00:05:12,030
I've also made sure that we wipe out any special tags for rust.
我还确保清除了所有生锈的特殊标签。

87
00:05:12,390 --> 00:05:20,230
And then the run python as before, which is going to run the python version of the code and compile
然后像以前一样运行python，这将运行python版本的代码并编译

88
00:05:20,230 --> 00:05:21,430
and run where.
并跑到哪里。

89
00:05:21,470 --> 00:05:22,590
Now this is.
现在是这样。

90
00:05:23,030 --> 00:05:27,670
So it's the same code here because uh, it's just going to take the compile command and the run command
所以这里的代码是相同的，因为呃，它只是采用编译命令和运行命令

91
00:05:27,670 --> 00:05:29,270
that you've got above.
你上面有的。

92
00:05:29,870 --> 00:05:30,470
Okay.
好的。

93
00:05:30,750 --> 00:05:32,550
Now let's look at some python.
现在让我们看一些Python。

94
00:05:32,590 --> 00:05:33,030
Okay.
好的。

95
00:05:33,070 --> 00:05:36,950
So last time we had some Python code to calculate digits of pi.
上次我们有一些 Python 代码来计算 pi 的数字。

96
00:05:37,390 --> 00:05:39,550
We've got something harder this time.
这次我们遇到了更难的事情。

97
00:05:39,590 --> 00:05:41,950
There's quite a lot of complicated code.
有很多复杂的代码。

98
00:05:41,950 --> 00:05:47,550
And I will go through it later when we, uh, see it presented nicer and talking about it presented
稍后当我们，呃，看到它呈现得更好并谈论它时，我会再讲一遍

99
00:05:47,550 --> 00:05:47,870
nicer.
更好。

100
00:05:47,910 --> 00:05:49,310
This is where we're going to do that.
这就是我们要做的地方。

101
00:05:49,310 --> 00:05:55,250
So we now have a little gradio app that's a little bit more involved than last time.
所以我们现在有了一个比上次更复杂的小渐变应用程序。

102
00:05:55,250 --> 00:05:58,810
I bring in some styles that I've got sitting in another file there.
我引入了一些位于另一个文件中的样式。

103
00:05:58,810 --> 00:06:04,050
You can check out the styles if you want, but but uh, yeah, I'm not much good at CSS, and I will.
如果需要，您可以查看样式，但是，呃，是的，我不太擅长 CSS，但我会的。

104
00:06:04,090 --> 00:06:08,050
I will tell you that it was, uh, an LLM that generated this CSS right here.
我会告诉你，是一个法学硕士在这里生成了这个 CSS。

105
00:06:08,050 --> 00:06:10,570
Of course, that's the way to do it these days.
当然，这就是现在的做法。

106
00:06:10,770 --> 00:06:16,210
Uh, so we take in some CSS, we create our user interface as before.
呃，所以我们采用一些 CSS，像以前一样创建用户界面。

107
00:06:16,450 --> 00:06:19,730
It's got it's actually it's now it's now got three rows.
实际上现在已经有三行了。

108
00:06:19,930 --> 00:06:27,770
The first row has the, uh, Python code and the C++ code and then the set of buttons.
第一行有，呃，Python 代码和 C++ 代码，然后是一组按钮。

109
00:06:27,970 --> 00:06:29,530
And then there's the second row.
然后是第二排。

110
00:06:29,530 --> 00:06:36,490
And the third row has output cells for Python output and C++ output.
第三行有用于 Python 输出和 C++ 输出的输出单元。

111
00:06:36,490 --> 00:06:41,730
And the other thing I mentioned is we're using a special gradient field called a GR code.
我提到的另一件事是我们正在使用一种称为 GR 代码的特殊梯度场。

112
00:06:41,850 --> 00:06:43,370
So let's see what all this looks like.
让我们看看这一切是什么样子的。

113
00:06:43,370 --> 00:06:45,850
If I run this up comes the user interface.
如果我运行它，就会出现用户界面。

114
00:06:45,970 --> 00:06:47,170
And it's kind of cool.
这有点酷。

115
00:06:47,170 --> 00:06:52,950
We've got ourselves this, uh, this code block right here and we can see what's going on really nicely.
我们已经有了这个，呃，这个代码块，我们可以很好地看到发生了什么。

116
00:06:52,950 --> 00:06:54,150
Let me zoom out a bit.
让我把镜头缩小一点。

117
00:06:54,190 --> 00:06:54,950
There we go.
我们开始吧。

118
00:06:55,190 --> 00:06:55,990
Zoom all the way out.
一直缩小。

119
00:06:55,990 --> 00:06:58,790
We can see this is all the code we're talking about.
我们可以看到这就是我们正在讨论的所有代码。

120
00:06:58,830 --> 00:07:00,750
It probably looks super tiny for you.
它对你来说可能看起来非常小。

121
00:07:00,790 --> 00:07:03,710
You have to squint, but I can make it a bit bigger.
你必须眯着眼睛，但我可以把它弄大一点。

122
00:07:03,870 --> 00:07:04,510
There we go.
我们开始吧。

123
00:07:04,510 --> 00:07:08,430
And I can just quickly tell you what it is that we're going to be running here.
我可以快速告诉你我们将在这里运行什么。

124
00:07:08,470 --> 00:07:10,750
Okay, so what is this Python code?
好的，那么这个 Python 代码是什么？

125
00:07:10,750 --> 00:07:13,590
What are we challenging our model with, right.
我们用什么来挑战我们的模型，对吧。

126
00:07:13,630 --> 00:07:19,470
Well, to start with, we have something here which is a pseudo random number generator.
好吧，首先，我们有一个伪随机数生成器。

127
00:07:19,470 --> 00:07:27,110
It generates fake random numbers I'm not relying on on like the random library in Python, because I
它生成我不依赖的假随机数，就像 Python 中的随机库一样，因为我

128
00:07:27,110 --> 00:07:32,110
want to do something that will be totally reproducible in any other programming language, but also
想要做一些可以在任何其他编程语言中完全重现的事情，而且

129
00:07:32,150 --> 00:07:36,270
because the way I do this, which is with a couple of big, big numbers, and then doing something where
因为我这样做的方式是用几个很大很大的数字，然后做一些事情

130
00:07:36,270 --> 00:07:38,350
you multiply, add and take the remainder.
你乘法、加法并取余数。

131
00:07:38,550 --> 00:07:44,710
The way that this is done is, is using a generator function using a yield of a value.
完成此操作的方法是使用使用值的产量的生成器函数。

132
00:07:44,710 --> 00:07:50,270
And that's going to be something hard for the model to understand and translate to other languages with
这对于模型来说很难理解并翻译成其他语言

133
00:07:50,490 --> 00:07:51,650
different constructs.
不同的构造。

134
00:07:51,650 --> 00:07:54,130
So that was a sort of cool trick to use here.
所以这是一个在这里使用的很酷的技巧。

135
00:07:54,570 --> 00:07:56,730
So okay, we can generate random numbers.
好吧，我们可以生成随机数。

136
00:07:56,730 --> 00:07:57,250
So what.
所以呢。

137
00:07:57,290 --> 00:07:59,290
Well, I wanted the kind of kind of formula here.
嗯，我想要这里的那种公式。

138
00:07:59,290 --> 00:08:02,330
That's the kind of thing you might come across maybe in a game.
这就是你可能在游戏中遇到的事情。

139
00:08:02,490 --> 00:08:05,970
Uh, so maybe if you're a games programmer or games dev, this might be the sort of thing that you've
呃，也许如果您是游戏程序员或游戏开发人员，这可能是您遇到过的事情

140
00:08:05,970 --> 00:08:06,570
had to do.
不得不做。

141
00:08:06,930 --> 00:08:13,050
But basically I make 10,000 of these random numbers between minus ten and plus ten.
但基本上我会在负十到正十之间生成 10,000 个随机数。

142
00:08:13,250 --> 00:08:18,570
And the challenge that this code solves is, all right, I've got these 10,000 random numbers.
这段代码解决的挑战是，好吧，我已经得到了这 10,000 个随机数。

143
00:08:18,810 --> 00:08:25,330
Tell me if you could pick any subset of numbers in a row, you could pick the first ten numbers, the
告诉我你是否可以选择连续的数字子集，你可以选择前十个数字，

144
00:08:25,330 --> 00:08:29,090
middle 30, the last 20, any subset.
中间 30 个、最后 20 个、任意子集。

145
00:08:29,570 --> 00:08:31,210
Then you could add those numbers up.
然后你可以将这些数字相加。

146
00:08:31,210 --> 00:08:32,410
You would get a total.
你会得到一个总数。

147
00:08:32,650 --> 00:08:40,650
What is the highest total that you could get by taking any sum subarray, any any number of numbers
通过取任意总和子数组、任意数量的数字，您可以获得的最高总数是多少

148
00:08:40,650 --> 00:08:43,930
in a row within this array of 10,000 numbers.
在这个由 10,000 个数字组成的数组中的一行中。

149
00:08:43,930 --> 00:08:46,890
And you might say, well, hang on, why isn't it just that just keep going.
你可能会说，好吧，坚持住，为什么不继续前进呢。

150
00:08:46,930 --> 00:08:47,930
Just take the whole list.
只需获取整个列表即可。

151
00:08:47,930 --> 00:08:50,590
Because remember, it has negative numbers in there too.
因为请记住，它也有负数。

152
00:08:50,630 --> 00:08:55,230
So you might not want to take you might you might get the best possible outcome just by taking the three
所以你可能不想采取你也许你可能会得到最好的结果只是通过采取这三个

153
00:08:55,230 --> 00:08:57,270
numbers in the middle if they're all positive.
如果它们都是正数，则将其放在中间。

154
00:08:57,270 --> 00:08:59,310
So it's figuring that out.
所以它正在解决这个问题。

155
00:08:59,310 --> 00:09:04,630
And of course, the way to do that which is shown here, which is a pretty standard approach, is to
当然，这里展示的方法是一种非常标准的方法，那就是

156
00:09:04,670 --> 00:09:08,870
loop all the way through the whole array and as your starting point.
一直循环整个数组并作为起点。

157
00:09:08,870 --> 00:09:14,470
And then for each one you have like a sub loop here, which then loops to see what the end could be.
然后对于每一个，你都有一个子循环，然后循环查看最终结果是什么。

158
00:09:14,510 --> 00:09:16,710
And then you add that up and find the total.
然后将其相加并得出总数。

159
00:09:16,710 --> 00:09:21,270
And you have to just make double sure that you don't accidentally check everything twice, which is
而且你必须双重确保你不会意外地将所有内容检查两次，这就是

160
00:09:21,270 --> 00:09:22,710
easy to do if you're not careful.
如果你不小心，很容易做到。

161
00:09:23,030 --> 00:09:25,030
And so that is what this does.
这就是它的作用。

162
00:09:25,070 --> 00:09:26,710
And then I say, you know what?
然后我说，你知道吗？

163
00:09:26,750 --> 00:09:28,790
Let's do that 20 times.
让我们这样做 20 次。

164
00:09:29,110 --> 00:09:31,470
20 times with different sets of random numbers.
使用不同组的随机数进行 20 次。

165
00:09:31,670 --> 00:09:33,710
Add the whole lot up and return it.
将全部添加并返回。

166
00:09:33,710 --> 00:09:37,430
So there's a lot of calculations happening there, an awful lot.
所以那里发生了大量的计算，非常多。

167
00:09:37,590 --> 00:09:42,830
And it's going to be hard for the model to understand all that, to translate it and to get exactly
模型将很难理解所有这些、翻译它并准确地得到

168
00:09:42,830 --> 00:09:46,550
the same output, let alone make it faster at the same time.
相同的输出，更不用说同时使其更快了。

169
00:09:46,750 --> 00:09:48,470
So we will see how they all do.
所以我们将看看他们都是如何做的。
