Okay, so back to calling our favorite evaluate script with the ensemble function right here. 好的，回到这里使用 ensemble 函数调用我们最喜欢的评估脚本。
And with our test data set I will kick it off. 我将通过我们的测试数据集开始它。
And this time it will take longer. 而这一次需要的时间会更长。
Particularly the first one is going to take the whole 30s while while modal kicks into gear. 特别是第一个将花费整个 30 秒的时间，同时模态启动。
But once it's got through the first the first one, it will then speed up. 但一旦通过了第一个，它就会加速。
So I'm going to let this do its thing, and hopefully you will do the same because you're going to want 所以我会让它发挥作用，希望你也会这样做，因为你会想要
to try this yourself. 自己尝试一下。
But I will say if for some of you that you might get technical problems running the deep neural network 但我想说的是，对于你们中的一些人来说，运行深度神经网络可能会遇到技术问题
because it's quite, quite a hefty piece of machinery, if you want, you don't need to run this and 因为它是一个非常非常庞大的机器，如果你愿意的话，你不需要运行它
are very easy. 都很容易。
I mentioned before that there are some easy shortcuts. 我之前提到过有一些简单的捷径。
If you have any problems running the ensemble model, you can just replace the ensemble model by something 如果运行集成模型时遇到任何问题，您可以将集成模型替换为其他模型
that just makes simply the call to the specialist model only. 这只是简单地调用专家模型。
There's no need to do this if you don't want. 如果您不愿意，则无​​需这样做。
Anyway, it's off and running and I'm going to let it go through. 不管怎样，它已经开始运行了，我会让它继续下去。
You can see once it's once modal has woken up, it's then pretty quick to call modal repeatedly. 您可以看到，一旦模态被唤醒，就可以很快地重复调用模态。
So just in case it's not clear to you what we're doing, every time we come up with a price, we are 因此，以防万一您不清楚我们在做什么，每次我们提出价格时，我们都会
calling the specialist model in modal. 在模态中调用专家模型。
In the cloud, we're calling the we're calling our rag frontier model looking up in chroma, making 在云中，我们调用我们的抹布边界模型在色度中查找，使得
that prompt to GPT five one. 提示 GPT 五一。
And then we are also calling a deep neural network and having it estimate as well. 然后我们也调用深度神经网络并对其进行估计。
And we're more than halfway through. 我们已经完成一半多了。
And I will see you in a second when it completes. 当它完成时我会看到你。
And I should have said it's of course, of those three prices, it's taking 80% times the frontier, 我应该说，当然，在这三个价格中，它占据了边界的 80% 倍，
one plus 10% plus 10% that's being combined to this number. 一加 10% 再加上 10% 就得到了这个数字。
Let's reveal. 让我们来揭晓吧。
Here you have it. 在这里你有它。
We got a two handle. 我们有两个手柄。
We only made a slight improvement on the frontier number. 我们只在边界数字上做了轻微的改进。
But we're down to 29.9. 但我们已经降至 29.9。
And here the R-squared is now at 87%. 这里 R 平方现在为 87%。
This visual looks beautiful. 这个视觉效果看起来很漂亮。
Absolutely beautiful. 绝对美丽。
Look how close everything is this now? 看看现在一切有多接近？
We really are. 我们确实是。
We're done with pricing. 我们已经完成了定价。
If you're fed up with these charts, this is the final, final one. 如果您厌倦了这些图表，这是最后一张。
I was so determined to get a two handle and I got there in the end. 我下定决心要获得两个手柄，最终我做到了。
Write this down please. 请写下来。
Your final 129 .90. 您的最终成绩为 129 .90。
That's that is success. 这就是成功。
Now I also I'm keenly aware of what you probably already thought, which is that these do all have a 现在我也敏锐地意识到你可能已经想到的，那就是这些确实都有一个
plus and minus. 加号和减号。
So overly fixating on the fact that it's 29 is perhaps silly because there is, of course, an error 因此，过分关注 29 这个事实可能是愚蠢的，因为这当然是一个错误
bar around it. 周围有酒吧。
But it feels good. 但感觉很好。
You know, it feels nice to have got 29.9. 你知道，得到 29.9 的感觉很好。
But the thing is, this is just based on a quick, broad setting of these weights. 但问题是，这只是基于对这些权重的快速、广泛的设置。
If you have the time to build a proper ensemble model, you can do a lot better. 如果您有时间构建适当的集成模型，您可以做得更好。
And by the way, you can throw in more models in here. 顺便说一句，您可以在此处添加更多模型。
You could throw in other frontier models. 你可以加入其他前沿模型。
You could put in the whole gamut of the different models that we came up with. 您可以将我们提出的所有不同模型放入其中。
Throw back in XGBoost, throw back in the random forest. 回到 XGBoost，回到随机森林。
I think I did the random forest last year instead of the neural network. 我想我去年做了随机森林而不是神经网络。
So put in. 所以放进去。
The more that you put in, the better. 你投入的越多越好。
The thing about using linear regression for your ensemble is that linear regression is smart, and if 在集成中使用线性回归的好处是线性回归很聪明，并且如果
something doesn't add any signal, it's not going to it's not going to include it. 有些东西不会添加任何信号，它不会包含它。
It just won't get counted. 只是不会被计算在内。
So you can put in as many models as you want. 因此您可以添加任意数量的模型。
And linear regression will figure out how can I take some combination of these different models to give 线性回归将找出我如何将这些不同模型的组合给出
you the best final outcome? 你最后最好的结局是什么？
So you should be able to beat me with this 29 and that of course, is the challenge for you. 所以你应该能够用这个 29 击败我，这当然是对你的挑战。
Use all of the techniques. 使用所有的技术。
Use everything we've done here to get even better. 利用我们在这里所做的一切来变得更好。
Get it, get it down into the 20s. 得到它，把它降到20多岁。
Let's see what you could do. 让我们看看你能做什么。
Last year, the best score that I got was 46 or something like that. 去年，我得到的最好成绩是46分左右。
It might have been 47. 可能是47。
Uh, so this I mean, honestly, my, my, I'm blown away by this result. 呃，所以我的意思是，老实说，我的，我的，我对这个结果感到震惊。
I'm so happy. 我太高兴了。
I wanted to get to a three handle. 我想要一个三手柄。
That was that was my dream. 那就是我的梦想。
And I got to a two handle 29.9 uh, really, really cool. 我得到了两个手柄 29.9 呃，真的，真的很酷。
Uh, so, uh, yeah, please take a moment to to to celebrate this success, wallow in the glory of 呃，所以，呃，是的，请花一点时间来庆祝这一成功，沉浸在
our $29.9 error. 我们的错误为 29.9 美元。
And of course, it wouldn't be real if we weren't able to visualize that. 当然，如果我们无法想象这一点，它就不会是真实的。
So I have to do this. 所以我必须这样做。
Here we go. 开始了。
Put it put it into this chart. 把它放进这个图表里。
And here is the final result, the prediction error from each model. 这是最终结果，即每个模型的预测误差。
Uh, we've got, uh, the original, the original, uh, machine learning stuff, the, the disastrous 呃，我们有，呃，原始的，原始的，呃，机器学习的东西，灾难性的
ad performance right here with 87.6. 广告效果为 87.6。
Crazy. 疯狂的。
Uh, this was the first, uh, neural network we did that was at 63. 呃，这是我们做的第一个神经网络，当时是 63。
These were all the frontier models. 这些都是前沿型号。
The best was GPT five one at 44.74. 最好的是 GPT 五一，为 44.74。
Then that was the disappointing fine tuning results. 然后就是令人失望的微调结果。
This was our better deep neural network at 46, uh, and 46.49. 这是我们更好的深度神经网络，为 46，呃，46.49。
Then that was the baseline, the worst of everything, all the way down to the fine tuned 39.85, which 然后这是基线，所有事情中最差的，一直到微调的 39.85，这
was our winner. 是我们的赢家。
Up until today. 直到今天。
Now in comes GPT five one rag beating everything at 30.19, and then just coming in a hair lower is 现在，GPT 5 1 rag 以 30.19 击败了所有对手，然后只低了一点点
our ensemble at 29.9. 我们的乐团在29.9。
Combining this plus this one plus this one. 结合这个加上这个加上这个。
And as I say, there's definitely more mileage here. 正如我所说，这里肯定有更多的里程。
There's more juice and I, I can't wait to hear how you do it. 还有更多的果汁，我迫不及待地想听听你是怎么做的。
And you must send me screenshots, post screenshots of that chart showing what what performance you're 你必须向我发送屏幕截图，发布该图表的屏幕截图，显示你的表现
able to achieve. 能够实现。
But for now, I'm going to be very, very happy with the 29.9. 但现在，我对 29.9 感到非常非常满意。
Okay. 好的。
Uh, but then just to make me really happy, we have to put this into an agent. 呃，但是为了让我真正高兴，我们必须将其放入代理中。
Uh, and, uh, so we're going to have a first of all, we're going to try a frontier agent, which 呃，呃，所以我们首先要尝试一名边境特工，
is one that that is basically going to call this whole rag flow. 这基本上就是所谓的整个抹布流。
Um, so let's just check it out again. 嗯，那我们再检查一下吧。
It's in the agents directory. 它位于代理目录中。
There is frontier Agent. 有边境代理。
Where are you? 你在哪里？
Um, there it is. 嗯，就在那里。
And the frontier agent is It's just exactly the same now as we as we look to to turn notebooks into, 前沿代理是，它与我们现在希望将笔记本变成的完全相同，
uh, Python modules. 呃，Python 模块。
And I always do recommend you start with a notebook, because it's just a great way to be in the experimental 我总是建议您从笔记本开始，因为这是进行实验的好方法
mindset and iterating on things. 心态和对事物的迭代。
But there comes a point when it's time to put things into Python modules. 但到了某个时刻，就需要将东西放入 Python 模块中了。
And this is how I'm trying to show you. 这就是我试图向您展示的方式。
Like production ready code. 就像生产就绪的代码一样。
It means that it has things like, you know, docstrings. 这意味着它有诸如文档字符串之类的东西。
So we've got, uh, good comments here. 所以我们在这里得到了，嗯，很好的评论。
And I'm also using type hints. 我还使用类型提示。
So I'm doing all the better practices that the data scientists in me has perhaps not, not been as careful 所以我正在做所有更好的实践，而我的数据科学家可能没有，没有那么小心
with. 和。
But now we're into more of the engineering side of being an AI engineer. 但现在我们更多地关注人工智能工程师的工程方面。
We're looking to be a bit more careful with this. 我们希望对此更加小心。
You can see that the frontier agent is just following exactly the same code, though. 不过，您可以看到边境代理只是遵循完全相同的代码。
Now we've experimented on it and perfected it, we can turn it into a nice module, a nice class frontier 现在我们已经对它进行了实验并完善了它，我们可以将它变成一个很好的模块，一个很好的类前沿
agent. 代理人。
It has the same thing making the contacts, getting the messages for finding similars. 它具有相同的功能，即建立联系、获取寻找相似信息的消息。
And then this is when it actually calls the price. 然后这就是它实际定价的时候。
And so with that background, we can now simply use this. 有了这个背景，我们现在就可以简单地使用它了。
We can call the Quadcast HyperX condenser Mic and find out how much it costs. 我们可以致电 Quadcast HyperX 电容麦克风并了解其价格。
And it predicts that it costs $140. 预计售价为 140 美元。
And I think I mentioned before that it actually costs me $130. 我想我之前提到过它实际上花了我 130 美元。
Uh, so this is a really very, very good pricing. 呃，所以这是一个非常非常好的定价。
And our specialist model got 90, which wasn't as good. 我们的专业模型得到了 90 分，这不是那么好。
Uh, so, uh, yeah. 呃，所以，呃，是的。
There there you have it. 就在那里，你就有了。
Now, uh, one, one thing that, uh, that. 现在，呃，一件事，呃，那个。
Oh, yeah. 哦，是的。
Let's try this as well. 我们也试试这个。
Let's try it. 我们来试试吧。
Pricing a Shure Mv7 plus. 舒尔 Mv7 plus 的定价。
Uh, now you might ask what that is. 呃，现在你可能会问那是什么。
That is the microphone that I'm speaking to you on right now. 这就是我现在正在用的麦克风。
Uh, that that is my current microphone, and that costs me 2.99. 呃，那是我现在的麦克风，花了我 2.99 美元。
Uh, so, uh, yeah, it's very close. 呃，所以，呃，是的，非常接近。
Again, it's, uh, obviously really knows this stuff. 再说一次，呃，它显然真的知道这些东西。
Um, and we can also then, uh, have a neural network agent and this shows in purple. 嗯，然后我们也可以，呃，有一个神经网络代理，它显示为紫色。
And so let's have a look at the neural network agent. 让我们看一下神经网络代理。
Here it is. 这里是。
It's very short and simple. 它非常简短。
It just calls inference on our neural network. 它只是调用我们的神经网络的推理。
Uh, and after after loading it in and setting it up. 呃，在加载并设置之后。
So if we come back here, we can also do the same thing. 所以如果我们回到这里，我们也可以做同样的事情。
And it doesn't do as well. 但效果并不好。
It says 162. 上面写着162。
Um, but it's still in the general ballpark. 嗯，但它仍然在一般范围内。
And then finally we can start creating an ensemble agent to be using all three and combining them. 最后，我们可以开始创建一个集成代理来使用所有三个并将它们组合起来。
So let's go ahead and have a look at the specialists, the ensemble agent right now. 现在让我们来看看专家、乐团经纪人。
It's it's here in ensemble agent right there. 它就在乐团特工那里。
So it's nice and short again. 所以它又好又短。
But there is one thing about this that maybe you were expecting. 但有一件事可能是你所期待的。
If you, if you spotted this, this thing that I, that I almost didn't mention. 如果你，如果你发现了这个，我几乎没有提到的这件事。
So what does this do? 那么这有什么作用呢？
It creates a specialist agent, a frontier agent, and a neural network agent in its init method. 它在其 init 方法中创建了一个专家代理、一个前沿代理和一个神经网络代理。
It creates those three agents that it's delegating to, but it does also create the preprocessor. 它创建了它所委托的三个代理，但它也创建了预处理器。
Remember, we still have to. 请记住，我们仍然必须这样做。
If we're taking in some text from the internet, we still have to pre-process that to rewrite that in 如果我们从互联网上获取一些文本，我们仍然需要对其进行预处理以将其重写为
the same format that is going to be most suitable for our agents. 最适合我们代理商的相同格式。
So it's then going to take the, the, the, the, the text that comes in in this price function, take 因此，它将采用此价格函数中出现的文本，采用
the text and first use the preprocessor to rewrite it. 文本并首先使用预处理器重写它。
Then it will call the specialist. 然后它会呼叫专家。
The frontier and the neural network are three prices those three agents to the right. 边界和神经网络是右边这三个代理的三个价格。
And it combines them by combining by multiplying the frontier by 0.8, the specialist by 0.1, and the 它通过将前沿乘以 0.8、将专家乘以 0.1 以及将
neural network by 0.1. 神经网络 0.1。
And that is what it returns, and it logs that as well. 这就是它返回的内容，并记录下来。
If you're going to come in and improve the ensemble, this is where to do it. 如果你想加入并改进合奏，这里就是你应该做的地方。
Of course, this is where you could use real weights that we come up with by looking at the data. 当然，您可以使用我们通过查看数据得出的实际权重。
Look at the val, the validation data set perhaps to come up with the best way to weight it. 看看val，验证数据集也许能想出最好的加权方法。
Also, if you have technical problems getting the neural network to work, or getting one of either 另外，如果您在使神经网络正常工作或获取其中之一方面遇到技术问题
the specialist or the frontier to work. 专家或前沿工作。
This is a shortcut you can take. 这是您可以采取的捷径。
You can come into this ensemble agent, and you can just comment out whichever ones give you trouble. 你可以进入这个集成代理，你可以直接注释掉那些给你带来麻烦的人。
Just comment them out here, comment them out here and then down here. 只需在这里注释掉它们，在这里注释掉它们，然后在这里注释掉。
Comment them out and just return the number that you actually want. 将它们注释掉并返回您真正想要的数字。
Let me uncomment it up so that that would allow you to simplify the ensemble agent to do whatever it 让我取消注释，这样您就可以简化集成代理来执行任何操作
is that you want. 就是你想要的。
This is one place to go to, to really pare down what's happening. 这是一个可以去的地方，可以真正减少正在发生的事情。
If you want to, to run a minimal version of this. 如果你愿意，可以运行它的最小版本。
Um, but but we'll, we'll have the maximum version of this. 嗯，但是我们会，我们会拥有这个的最大版本。
We'll, we'll, we'll be using this combined weighting. 我们将、我们将、我们将使用这种组合权重。
And you'll notice this is an example of really an agent workflow that we're just using Python code to 您会注意到，这是一个真正的代理工作流程示例，我们只是使用 Python 代码来实现
orchestrate the three calls to three different agents. 将三个呼叫协调到三个不同的代理。
It's not like there's any autonomy at this point. 目前看来还没有任何自主权。
It's just a fixed calling for three sub agents in order to combine those numbers and come up with the 这只是对三个子代理的固定调用，以便将这些数字组合起来并得出
total estimated price of this item. 该商品的预估总价。