1
00:00:00,160 --> 00:00:04,160
Next we're going to peel back the onion a little bit more on workflows.
接下来，我们将在工作流程上进一步深入探讨。

2
00:00:04,320 --> 00:00:11,840
Looking at different types of workflow, anthropic identifies five different design patterns that you'll
着眼于不同类型的工作流程，人择确定了五种不同的设计模式，您将使用它们

3
00:00:11,840 --> 00:00:16,320
find when building a genetic systems that have workflows in them.
在构建具有工作流程的遗传系统时发现。

4
00:00:16,320 --> 00:00:18,840
And let's go through each of them and talk about them.
让我们逐一讨论并讨论它们。

5
00:00:19,280 --> 00:00:20,240
This is the first one.
这是第一个。

6
00:00:20,240 --> 00:00:21,960
They call it prompt chaining.
他们称之为即时链接。

7
00:00:21,960 --> 00:00:23,160
And it's a simple one.
这很简单。

8
00:00:23,400 --> 00:00:26,800
What you're seeing here in this diagram obviously the in and the out on the left and the right is the
您在此图中看到的显然左侧和右侧的输入和输出是

9
00:00:26,800 --> 00:00:28,360
beginning and the end of the workflow.
工作流程的开始和结束。

10
00:00:28,720 --> 00:00:32,440
The yellow boxes represent calls to models to Llms.
黄色框代表对 Llm 模型的调用。

11
00:00:32,440 --> 00:00:37,680
And the blue boxes is where you potentially have just some code that you've written, some some software
蓝色方框中可能只有您编写的一些代码，一些软件

12
00:00:37,960 --> 00:00:38,920
and it's optional.
并且它是可选的。

13
00:00:39,240 --> 00:00:44,800
And what you'll see there is that this is simply saying you could have an LLM carry out some task and
你会看到这只是说你可以让法学硕士执行一些任务并且

14
00:00:44,800 --> 00:00:49,520
then potentially based on some code, you could then pass that to a second LLM and that output could
然后可能基于一些代码，您可以将其传递给第二个LLM，并且该输出可以

15
00:00:49,520 --> 00:00:50,680
go to a third LLM.
去第三个法学硕士。

16
00:00:50,680 --> 00:00:52,320
And that could be the conclusion.
这可能就是结论。

17
00:00:52,520 --> 00:00:55,480
And actually this is really similar to what you just did.
实际上，这与您刚刚所做的非常相似。

18
00:00:55,520 --> 00:00:58,040
This is similar to that commercial question.
这与商业问题类似。

19
00:00:58,040 --> 00:01:00,560
When we ask an LLM first pick a sector.
当我们要求法学硕士时，首先选择一个部门。

20
00:01:00,560 --> 00:01:04,240
And then given that sector pick a pain point and then pick a solution.
然后针对该领域选择一个痛点，然后选择一个解决方案。

21
00:01:04,240 --> 00:01:06,020
And obviously it doesn't need to be three LMS.
显然它不需要是三个 LMS。

22
00:01:06,020 --> 00:01:08,220
It can be as many as you want, but this is the idea.
你想要多少都可以，但这就是想法。

23
00:01:08,220 --> 00:01:14,020
You are chaining a series of LM calls decomposing into a fixed set of subtasks.
您将一系列 LM 调用链接起来，分解为一组固定的子任务。

24
00:01:14,220 --> 00:01:21,500
And the reason you might want to do that is because you can take care to frame each LM call very precisely
您可能想要这样做的原因是因为您可以非常精确地构建每个 LM 调用

25
00:01:21,500 --> 00:01:27,100
to get the the best, the most effective LM response based on that prompt.
根据该提示获得最佳、最有效的 LM 响应。

26
00:01:27,140 --> 00:01:32,700
So it allows you to to really work on each of those tasks being very effective.
因此，它可以让您真正有效地完成每一项任务。

27
00:01:32,700 --> 00:01:39,300
And then keep your whole process, your workflow on guardrails by taking it step by step through a sequence
然后通过按顺序逐步进行，让整个过程、工作流程保持在护栏上

28
00:01:39,300 --> 00:01:41,300
of well-defined tasks.
明确定义的任务。

29
00:01:41,940 --> 00:01:44,260
Now I want to make a point that you might have already thought of.
现在我想指出一个你可能已经想到的观点。

30
00:01:44,740 --> 00:01:52,220
Whilst anthropic is quite clear to define this as a workflow and not an agent pattern, it is perfectly
虽然人类很清楚地将其定义为工作流程而不是代理模式，但它是完美的

31
00:01:52,220 --> 00:01:59,740
possible for prompt chaining workflow like this to be giving the LM some discretion on what activities
像这样的提示链接工作流程可以让LM在哪些活动上有一定的自由裁量权

32
00:01:59,740 --> 00:02:05,060
happen, because just as we did in our example, the first call to the LM might come up with a topic,
发生这种情况是因为正如我们在示例中所做的那样，对 LM 的第一次调用可能会提出一个主题，

33
00:02:05,060 --> 00:02:09,570
and it's that topic that gets worked on by LMS two and three.
这正是学习管理系统二号和三号所研究的主题。

34
00:02:09,770 --> 00:02:16,490
So in some ways, the way that anthropic distinguishes between workflows and agents, it's a little
所以在某些方面，人类区分工作流和代理的方式有点不同

35
00:02:16,530 --> 00:02:17,730
bit artificial.
有点人工。

36
00:02:17,770 --> 00:02:20,090
There is definitely a blurred line between them.
他们之间肯定有一条模糊的界限。

37
00:02:20,090 --> 00:02:26,810
It's perfectly possible for there to be an element of autonomy about a workflow pattern like this.
像这样的工作流程模式完全有可能存在自治元素。

38
00:02:27,530 --> 00:02:28,330
Onwards.
以后。

39
00:02:28,330 --> 00:02:33,970
The second design pattern is called routing, and this is where an input comes in.
第二种设计模式称为路由，这就是输入的用武之地。

40
00:02:34,210 --> 00:02:42,810
And an LLM has the task of deciding which of multiple possible models are selected to carry out this
法学硕士的任务是决定选择多个可能的模型中的哪一个来执行此操作

41
00:02:42,810 --> 00:02:43,450
function.
功能。

42
00:02:43,690 --> 00:02:47,170
And the idea is that you might have specialist models in here.
我们的想法是，这里可能有专业模型。

43
00:02:47,170 --> 00:02:49,250
They're shown by LLM one, two and three.
它们由法学硕士一、二和三展示。

44
00:02:49,290 --> 00:02:51,530
And they're each good at different tasks.
他们各自擅长不同的任务。

45
00:02:51,530 --> 00:02:57,930
And the router's job is to classify the task, understand which of the specialists will be best equipped
路由器的工作是对任务进行分类，了解哪些专家最适合

46
00:02:57,930 --> 00:02:59,330
to tackle this task.
来完成这项任务。

47
00:02:59,490 --> 00:03:05,570
And it allows for, as I say here, separation of concerns for being able to have different LMS that
正如我在这里所说，它允许关注点分离，以便能够拥有不同的 LMS

48
00:03:05,570 --> 00:03:12,990
have different levels of expertise and have them and have an LLM decide how to route to those experts.
拥有不同水平的专业知识，让他们和法学硕士决定如何联系这些专家。

49
00:03:13,390 --> 00:03:15,350
So this is a powerful model.
所以这是一个强大的模型。

50
00:03:15,350 --> 00:03:16,790
It's very common.
这很常见。

51
00:03:16,950 --> 00:03:22,990
And it's something which again, I would say I would argue there is some it's a bit artificial to say
我想说的是，我认为有些说法有点不自然

52
00:03:22,990 --> 00:03:28,990
that there's no autonomy here, because clearly that router is able to make some decisions, albeit
这里没有自主权，因为显然路由器能够做出一些决定，尽管

53
00:03:29,030 --> 00:03:29,950
on guardrails.
在护栏上。

54
00:03:29,990 --> 00:03:33,190
Again, it still has to follow a given workflow.
同样，它仍然必须遵循给定的工作流程。

55
00:03:33,990 --> 00:03:36,350
And on to the third design pattern.
接下来是第三种设计模式。

56
00:03:36,390 --> 00:03:41,270
Parallelization, which is at first blush, might look quite similar to what we just talked about.
乍一看，并行化可能与我们刚才讨论的非常相似。

57
00:03:41,310 --> 00:03:43,390
But there is a lot in common with these design patterns.
但这些设计模式有很多共同点。

58
00:03:43,390 --> 00:03:45,830
But the idea here is that you have.
但这里的想法是你已经有了。

59
00:03:46,230 --> 00:03:49,830
Remember, the blue boxes represent code R code, not an LM.
请记住，蓝色框代表代码 R 代码，而不是 LM。

60
00:03:49,830 --> 00:03:56,470
So we write some code that takes a task and breaks it down into multiple pieces that should all run
因此，我们编写一些代码来接受一个任务并将其分解为多个部分，这些部分都应该运行

61
00:03:56,470 --> 00:03:57,430
in parallel.
并联。

62
00:03:57,430 --> 00:04:01,430
So in the previous design pattern it was an LM doing the routing.
因此，在之前的设计模式中，是由 LM 进行路由。

63
00:04:01,470 --> 00:04:06,870
And it was one of these three experts that was given the task in this design pattern.
在这个设计模式中，正是这三位专家之一被赋予了任务。

64
00:04:06,870 --> 00:04:07,950
It's code.
这是代码。

65
00:04:07,990 --> 00:04:11,910
It's let's say Python code that's deciding what to do or how to coordinate.
假设 Python 代码决定做什么或如何协调。

66
00:04:11,910 --> 00:04:18,900
And in parallel, it's being sent to three llms to carry out three different activities concurrently.
与此同时，它被发送到三个 llms，同时开展三项不同的活动。

67
00:04:18,900 --> 00:04:20,900
And then there's more code.
然后还有更多代码。

68
00:04:20,900 --> 00:04:24,580
Maybe it's Python code that takes those answers and stitches them together.
也许是 Python 代码获取了这些答案并将它们拼接在一起。

69
00:04:24,780 --> 00:04:29,940
And actually, anthropic makes the point that these tasks don't necessarily need to be different tasks.
实际上，人择指出这些任务不一定需要是不同的任务。

70
00:04:29,940 --> 00:04:36,140
You could imagine a situation where you send the same task and have it be done three times, and you
您可以想象这样一种情况，您发送相同的任务并让它完成三次，然后您

71
00:04:36,140 --> 00:04:39,180
use the aggregator, perhaps to take the average or something like that.
使用聚合器，也许可以取平均值或类似的东西。

72
00:04:39,180 --> 00:04:43,140
So there are various situations where this might be the same thing that you're doing three times doesn't
所以在很多情况下，这可能是你做三遍的同一件事，但并非如此

73
00:04:43,140 --> 00:04:49,340
need to be different, but I think most commonly it's when there are multiple subtasks happening concurrently.
需要有所不同，但我认为最常见的是当多个子任务同时发生时。

74
00:04:49,500 --> 00:04:51,660
That is the parallelization.
这就是并行化。

75
00:04:51,700 --> 00:04:54,420
It's hard to say of the design patterns.
设计模式很难说。

76
00:04:54,900 --> 00:04:55,460
Okay.
好的。

77
00:04:55,500 --> 00:04:58,780
And now this one orchestrator worker.
现在是这一位协调员。

78
00:04:59,180 --> 00:05:07,060
This is when a difficult, challenging task is broken down and recombined.
这是一个困难的、具有挑战性的任务被分解和重新组合的时候。

79
00:05:07,420 --> 00:05:10,260
And you might be thinking, hang on, isn't that just what we just did?
你可能会想，等等，这不正是我们刚刚所做的吗？

80
00:05:10,300 --> 00:05:11,260
I just flick between them.
我只是在它们之间快速浏览。

81
00:05:11,260 --> 00:05:14,300
Don't these two slides, these two design patterns are really similar?
难道这两张幻灯片，这两种设计模式真的很相似吗？

82
00:05:14,340 --> 00:05:17,980
Well, you'll notice a subtle color change along with the change in terminology.
好吧，您会注意到随着术语的变化，颜色也发生了微妙的变化。

83
00:05:18,180 --> 00:05:25,280
The key point is that this is exactly like the prior design pattern, except it's no longer code that's
关键点是，这与之前的设计模式完全相同，只是不再是代码

84
00:05:25,280 --> 00:05:26,600
doing the orchestration.
进行编排。

85
00:05:26,600 --> 00:05:27,720
It's an LLM.
这是一个法学硕士。

86
00:05:28,040 --> 00:05:35,880
So you are using a model to break down a complex task into smaller steps, and then you are using a
因此，您正在使用模型将复杂的任务分解为较小的步骤，然后使用

87
00:05:35,880 --> 00:05:38,520
model to combine the results.
模型来组合结果。

88
00:05:38,520 --> 00:05:45,920
And so this is a much more dynamic kind of system where the orchestrator can choose how to divvy up
所以这是一个更加动态的系统，协调者可以选择如何分配

89
00:05:45,920 --> 00:05:46,680
the task.
任务。

90
00:05:46,800 --> 00:05:54,200
And again, I would argue that it's quite artificial to categorize this as a workflow rather than an
再说一遍，我认为将其归类为工作流程而不是流程是相当人为的。

91
00:05:54,240 --> 00:05:59,560
agent pattern that we'll look at in a minute, because clearly that orchestrator has discretion over
我们稍后会讨论代理模式，因为很明显，编排者可以自行决定

92
00:05:59,560 --> 00:06:04,920
how it divvies up the tasks, and it could choose how many different llms get assigned the activity.
它如何分配任务，并且可以选择为多少个不同的 LLMS 分配该活动。

93
00:06:04,920 --> 00:06:09,480
So saying that this is just a fixed workflow is perhaps a stretch.
所以说这只是一个固定的工作流程也许有点夸张。

94
00:06:09,480 --> 00:06:12,000
So, you know, I think you get the overall idea.
所以，你知道，我认为你已经了解了总体想法。

95
00:06:12,000 --> 00:06:17,680
There's certainly more constraints on this than when we come to the more flexible agent flows.
与我们采用更灵活的代理流程相比，这肯定有更多的限制。

96
00:06:17,680 --> 00:06:25,950
But but generally the idea here LLM breaks down the task Llms carry out each expert task, LM synthesizes
但一般来说，这里的想法 LLM 分解了任务 Llm 执行每个专家任务，LM 综合

97
00:06:25,950 --> 00:06:30,750
the task for an output that is pattern for the orchestrator worker.
输出的任务是 Orchestrator Worker 的模式。

98
00:06:31,270 --> 00:06:34,030
And now on to pattern five.
现在来看模式五。

99
00:06:34,070 --> 00:06:38,710
The final workflow pattern and the one that I use most commonly.
最终的工作流程模式也是我最常用的一种。

100
00:06:38,710 --> 00:06:45,310
This is one that I come against all the time, and it's called an evaluator optimizer by anthropic.
这是我一直遇到的一个问题，anthropic 将其称为评估器优化器。

101
00:06:45,350 --> 00:06:49,510
I tend to call them just evaluators or validation validation agents.
我倾向于称他们为评估者或验证验证代理。

102
00:06:49,510 --> 00:06:52,990
You hear that a lot, but the idea is it's very simple.
你听过很多这样的说法，但想法很简单。

103
00:06:53,150 --> 00:06:55,590
You have an LM that's doing your job.
你有一个 LM 正在做你的工作。

104
00:06:55,590 --> 00:06:57,470
Let's call it the LM generator.
我们将其称为 LM 生成器。

105
00:06:57,510 --> 00:06:58,710
It's it's doing something.
它正在做某事。

106
00:06:58,710 --> 00:07:02,190
And it comes up with a solution shown in this white arrow here.
它提出了一个解决方案，如此处的白色箭头所示。

107
00:07:02,470 --> 00:07:07,390
And you have a second LM that's playing the role of evaluator.
还有第二个 LM 扮演评估者的角色。

108
00:07:07,390 --> 00:07:10,390
It's there to check the work of the first LM.
它的作用是检查第一个 LM 的工作。

109
00:07:10,510 --> 00:07:16,590
And it's given any extra information, any context, everything to, to arm itself to, to not be trying
它被给予任何额外的信息，任何背景，一切，武装自己，而不是尝试

110
00:07:16,590 --> 00:07:21,550
to generate content, but check the work of a prior LM.
生成内容，但要检查先前 LM 的工作。

111
00:07:21,910 --> 00:07:26,470
And based on that it can choose to either accept or reject the work.
并据此可以选择接受或拒绝该工作。

112
00:07:26,510 --> 00:07:30,140
If it accepts it, then that's it goes to the output.
如果它接受它，那么它就会进入输出。

113
00:07:30,140 --> 00:07:31,260
If it rejects it.
如果它拒绝的话。

114
00:07:31,300 --> 00:07:32,860
It should come up with a reason.
它应该拿出一个理由。

115
00:07:32,860 --> 00:07:36,940
And the rejection and the reason goes back to the LM generator.
拒绝和原因可以追溯到 LM 发电机。

116
00:07:36,940 --> 00:07:41,620
And that can then choose to come up with another solution which comes back here.
然后可以选择提出另一个回到这里的解决方案。

117
00:07:41,940 --> 00:07:45,540
And so you can see this, this sort of feedback loop setup.
所以你可以看到这种反馈循环设置。

118
00:07:45,660 --> 00:07:47,180
It's very powerful.
它非常强大。

119
00:07:47,300 --> 00:07:55,700
Of course, one of the key concerns of building production systems with LMS is about accuracy, predictability,
当然，使用 LMS 构建生产系统的关键问题之一是准确性、可预测性、

120
00:07:55,740 --> 00:07:59,940
robustness of the responses and having validation agents.
响应的稳健性和验证代理。

121
00:07:59,940 --> 00:08:07,940
Having these kinds of evaluator optimizer flows in your LMS solutions is a really powerful way to increase
在您的 LMS 解决方案中拥有这些类型的评估器优化器流程是一种非常有效的提高效率的方法。

122
00:08:07,940 --> 00:08:11,540
the accuracy and build more guarantees.
的准确性，建立更多的保证。

123
00:08:11,580 --> 00:08:17,020
There's never full guarantees with LMS, but build a higher level of guarantee around the quality of
LMS 永远不会提供全面的保证，但会围绕产品的质量建立更高水平的保证

124
00:08:17,060 --> 00:08:18,300
the final output.
最终输出。

125
00:08:18,300 --> 00:08:21,260
So this is a really effective pattern.
所以这是一个非常有效的模式。

126
00:08:21,300 --> 00:08:26,860
I use it all the time, and of course we'll have plenty of examples on the course, and you should be
我一直在使用它，当然我们的课程中会有很多例子，你应该

127
00:08:26,860 --> 00:08:31,620
able to think about how you could apply this to LM solutions in your day jobs right away.
能够立即思考如何将其应用到日常工作中的 LM 解决方案中。
