章鱼总结
00:00 / 18:10

Prompt Engineering · 18:10

说话人 0

Google just released Gemini Decision One, which is their take on decision models that we have been seeing since TypeSafe released JEV in September. But this model has some really neat extra capabilities. Decision models are a new class of classification model that doesn't generate any text. You give it your input, a fixed set of options, and it picks one and tells you how confident it is. and a lot of applications need exactly that, which is a decision that your code can act on based on your business logic and rules. so in this video, i want to show you what this new model can actually do, what are the new capabilities, some best practices for using it, and the mistakes that i personally made along the way, including one where it was 92% confident in an answer that was completely wrong. so make sure to watch this video if you want to use it properly. but before we talk about how it works, let me show you a couple of quick demos. so here's a browser agent on a checkout page. it takes a screenshot at every step and asks the decision model a few yes or no questions about it. and then my code picks the next action from the answers. For example, it dismisses the cookie banner, fills the email, enters the card number and places the order. Now the second one is an expense claims auditor, where a single call checks the photo of a receipt against what the employees claimed. So it approves the claims that match and the one where the total does not match goes to a person. Both of these are going to be in the collab that you can run yourself, but to build them, you first need to understand how a decision model actually works.

谷歌刚刚发布了 Gemini Decision One,这是他们对决策模型的一次探索,自 TypeSafe 在九月发布 JEV 以来,我们就一直在关注这类模型。 但这个模型有一些非常巧妙的额外能力。 决策模型是一类新的分类模型,它不生成任何文本。 你给它输入和一组固定的选项,它会选出一个,并告诉你它有多大把握。 很多应用正需要这样的功能:一个决策,让你的代码可以根据业务逻辑和规则据此采取行动。 所以在这个视频里,我想向你展示这个新模型实际能做什么、有哪些新能力、一些使用的最佳实践,以及我自己在过程中犯过的错误,其中包括一次它以 92% 的置信度给出了完全错误的答案。 所以如果你想正确地使用它,一定要看完这个视频。 但在讨论它如何工作之前,让我先展示几个简短的演示。 这是一个在结账页面上运行的浏览器智能体。 它在每一步都会截一张屏幕截图,并就此向决策模型提出几个是或否的问题。 然后我的代码会根据这些答案选择下一步操作。 例如,它会关闭 Cookie 横幅、填写邮箱、输入卡号,然后下单。 第二个演示是一个报销审核员,只需一次调用,它就能将员工报销的票据照片与其申报的金额进行核对。 因此,它会批准金额相符的报销,而总额不符的那一笔则会交给人工处理。 这两个例子都会放在你可以自己运行的 Colab 中,但要构建它们,你首先需要了解决策模型究竟是如何工作的。

So let's talk about how this is different from a regular large language model. When you ask an LLM a yes or no question, it generates the answer one token at a time. And a lot of the newer models also think before they answer. So you pay for the thinking tokens and the output tokens. and you also have to wait for them to be generated. and then as an additional step, your code has to parse the text that comes back out of the llm. but the thing is, you don't need all of this to make a yes or no decision. a decision model skips all of that. according to google, it scores every option in one pass, which means the model reads your input and your question once. does not write anything at all. instead, it gives you a probability for each option. so the number of output token is always zero. every answer also comes with a confidence score. the easiest way to think about a decision model is a smart if statement that tells you how confident or sure it is, which also means that you can set a cutoff in your code. so everything about that cutoff runs automatically. and anything below that cutoff or threshold can go to a human if you want a human in the loop or a bigger model. and if you think about it, a lot of business logic is essentially these small decisions. so decision models are perfect for workflows.

那么,我们来谈谈它与普通大语言模型有何不同。 当你向大语言模型提出是或否的问题时,它会逐个 token 地生成答案。 而且许多较新的模型在回答之前还会进行思考。 所以你既要为思考用的 token 付费,也要为输出的 token 付费。 而且你还必须等待这些内容生成完毕。 然后作为额外的一步,你的代码还必须解析从大模型返回的文本。 但问题在于,要做出一个是或否的决定,你并不需要这一切。 决策模型则跳过了所有这些步骤。 据谷歌介绍,它只需一次遍历就能为每个选项打分,这意味着模型只读取一次你的输入和问题。 它完全不写任何东西。 相反,它会为每个选项给出一个概率。 因此,输出的token数量始终为零。 每个答案还附带一个置信度分数。 理解决策模型最简单的方式,就是把它看作一个聪明的if语句,它会告诉你它有多大把握或多确定,这也意味着你可以在代码中设置一个截断值。 因此,关于这个截断值的所有处理都会自动运行。 低于该截断值或阈值的内容,如果你希望有人参与其中,可以交给人工处理,或者交给更大的模型处理。 仔细想想,很多业务逻辑本质上就是这些小决策。 因此,决策模型非常适合用于工作流。

Next, I'm going to show you the three types of questions that you can ask, and then three places where it is worth using, including a single call with 1,000 questions in it. Also, I have a quick ask, because a lot of you watching are new here and are not subscribed. I would highly recommend subscribing to the channel if you find this content useful. Also turn on the notifications. This helps a lot. Gemini decision. One is an extremely powerful model. It can process text images, audio video and pdf files. There are three different type of questions or primitives that you can use or ask. The first one is yes or no questions and you get back the probability that the answer is yes. The second one is a choice where you provide a list of options and you get the winner plus a probability of every option. And the last one is a score where you provide an ordered rubric and you get back a number on that scale. Now, if you have used Jev from TypeSafe, this structure is going to look very familiar. After the initial release of Jev, there were a lot of different. decision models, including the ones from OpenAI that has a decisions api. this whole area of decision model is extremely hot and actually useful. and that's why we have a model from google as well. let's talk about why would you use this. a classifying support tickets is the example that everybody uses. and i don't think this is where most of the value is. here are three different places where i think it makes a real difference.

接下来,我会向你展示可以提出的三种问题类型,以及三个值得使用它的场景,其中包括一次调用处理1000个问题的做法。 另外,我有一个简单的请求,因为很多正在观看的人是新来的,还没有订阅。 如果你觉得这些内容有用,我强烈建议你订阅频道。 也请开启通知。 这会有很大帮助。 Gemini 决策。 其中一个是非常强大的模型。 它可以处理文本、图像、音频、视频和 PDF 文件。 你可以使用或提出三种不同类型的问题或原语。 第一种是是非题,你会得到答案为“是”的概率。 第二种是选择题,你提供一个选项列表,会得到获胜选项以及每个选项的概率。 最后一种是评分题,你提供一个有序的评分标准,会得到该量表上的一个数字。 如果你用过 TypeSafe 的 Jev,这种结构会让你觉得非常熟悉。 Jev 最初发布之后,出现了许多不同的…… 决策模型,包括 OpenAI 的模型,它提供了一个决策 API。 整个决策模型领域非常火热,而且确实很有用。 这也是为什么 Google 也有一个模型。 我们来谈谈为什么要使用它。 对支持工单进行分类,是大家都会举的例子。 而我不认为大部分价值在这里。 以下是我认为真正能带来改变的三个场景。

The first one is the small decision inside an agent loop, which is things like which tool to call and whether the task is done. Today, the big models make each of these with thinking tokens. For example, I created a small benchmark where it had to pick a tool from 24 different tools, and it picked the right tool on every request in my test. Now the second one is a cheap gate in front of an expensive call. If your app searches documents before it answers, you can score the chunk of text that the search returned and only send the useful ones to the LLM. For example, here I give it 10 chunks for one question in a single call, and the three relevant chunks came out on top. This is essentially re-ranking mechanism that people have been using, but now we can do it with a decision model. and the last one is checks that you use to sample and can now run on almost everything. for example, screening every tool call output for prompt injection. this used to be pretty expensive, but now you can easily do it with a decision model. to see how far this goes, i sent 1,000 yes or no questions about a single input, and the call cost only half a cent. So decision models are not only great at making decisions, they are really cheap to run. And they're much faster compared to normal llm calls. Okay, let's talk about what this costs because the results was not what i was kind of expecting. The price is 10 cents per million input tokens on the paid tier and there is also a free tier. Now I compared this with Gemini 3.8 Flash on the same job using structured output, which is where one forced the model to answer in a fixed format. To give you a sense of how the cost difference could look like, I ran a few experiments. For example, for routing one message to one of the four queues, the decision call cost about $10 per million calls. for reference, the flash call cost about $170 per million calls in my test because it also produces thinking tokens, output tokens. so the cost difference is pretty drastic. now, the interesting thing is that the savings does not come from sending fewer tokens. the decision call sends more input tokens because every question adds about 50 tokens of its own. the savings come from the lower price per token and from the zero output and thinking tokens. in the rest of the video, i'll show you how to build with this new gemini decision api.

第一个是智能体循环中的小决策,比如调用哪个工具以及任务是否已完成。 如今,大型模型会借助思考 token 来做出这些决策。 例如,我做了一个小型基准测试,要求它从 24 个不同的工具中选择一个工具,在我的测试中,每次请求它都选对了工具。 第二个是在昂贵调用前面设置的低成本过滤器。 如果你的应用在回答之前会搜索文档,你可以对搜索返回的文本块进行评分,只把有用的文本块发送给大语言模型。 例如,这里我在一次调用中为一个问题提供了 10 个文本块,结果三个相关文本块排在了最前面。 这本质上是人们一直在使用的重排序机制,只不过现在我们可以用决策模型来完成。 最后一个是你用来抽样检查的手段,现在几乎可以对所有内容运行。 例如,对每一条工具调用的输出进行提示注入筛查。 过去这样做成本相当高,但现在你可以轻松地用决策模型来完成。 为了看看这能做到什么程度,我对同一个输入发送了1,000个是非题,而这次调用的成本只有半美分。 所以决策模型不仅擅长做决策,而且运行成本非常低。 而且与普通的LLM调用相比,它们的速度也快得多。 好,我们来谈谈这要花多少钱,因为结果和我原本的预期有些不同。 付费版的价格是每百万输入token 10美分,同时还有免费版。 现在,我在同样的任务上将它与Gemini 3.8 Flash做了比较,使用的是结构化输出,也就是强制模型按照固定格式作答。 为了让你大致了解成本差异可能是什么样子,我做了几组实验。 例如,在将一条消息路由到四个队列之一的任务中,决策调用每百万次大约花费10美元。 作为对照,在我的测试中,Flash调用每百万次大约花费170美元,因为它还会产生思考token和输出token。 所以成本差距相当悬殊。 现在,有意思的是,节省的成本并不是来自于发送更少的token。 决策调用发送的输入token反而更多,因为每个问题本身大约会增加50个token。 节省来自于更低的单token价格,以及几乎没有输出token和思考token。 在视频的其余部分,我会向你展示如何使用这个全新的Gemini决策API进行构建。

and in the process, i want to show you how to actually think about using this model because there are certain mistakes that you would make if you treat this as a llm. everything is in the code lab. And the link is going to be in the video description. To get started, you need an API key from Google AI Studio. The free tier is enough for everything that we're going to be doing. Now, with the API, there are three different parts to think about. First is the model, second is the input, and then your questions.

在这个过程中,我还想向你展示应该如何真正地思考使用这个模型,因为如果你把它当作LLM来对待,就会犯某些错误。 所有内容都在代码实验室(code lab)里。 链接会放在视频简介里。 开始之前,你需要一个来自 Google AI Studio 的 API 密钥。 免费套餐足以完成我们要做的所有事情。 现在,使用 API 时需要考虑三个不同的部分。 第一是模型,第二是输入,然后是你的问题。

说话人 1

so let's write the first call. you create a client, then you call the decisions create on those three parts. the model is gemini decision one. the input is a customer message that says that the mug arrived cracked and the question is whether the item arrived damaged. Now every question has a type and some instructions and the instructions are just the question in plain English. When I run it, I get a probability of 99% that the answer is yes, along with a confidence score. The usage also shows that the number of output tokens is zero. Now you're not limited to one question in the same call. I can add a choice question. which picks a support queue from a list and a score question which rates how frustrated the customer sounds. now the documentation recommends to give every option a short description. this is usually helpful both for agents and for humans. so a single call returns all three answers and the message itself is only billed once. which is pretty good. now, here's the best part.

那我们来编写第一个调用。 你先创建一个客户端,然后对这三个部分调用 decisions create。 模型是 gemini decision one。 输入是一条客户消息,内容是马克杯到货时破裂了,问题是该商品是否在运输中受损。 现在每个问题都有一个类型和一些说明,而说明就是用简单英语写的问题本身。 运行时,我得到答案为“是”的概率为 99%,同时还有一个置信度分数。 用量信息还显示输出 token 数为零。 而且,同一次调用中并不限于一个问题。 我可以再添加一个选择题。 它会从列表中选择一个支持队列,还有一个评分题,用来评估客户听起来有多沮丧。 文档建议为每个选项提供一段简短的描述。 这通常对智能体和人类都有帮助。 因此一次调用就能返回所有三个答案,而且消息本身只计费一次。 这相当不错。 现在,最精彩的部分来了。

to use an image, the only thing that changes is the input. so instead of a string, i pass the photo of a receipt and ask whether this is a receipt and whether there is any alcohol on it. if you look at it, the rest of the code stays exactly the same as before. now, the interesting thing is. In the alcohol answer, where the probability of yes is very low, but the confidence is high, because the model is confident that the answer is no. Audio works the same way. So here I pass a recording of a caller and ask whether they want to speak to a human. now, the best part is that you can also mix inputs in a single cell. so here i pass a claim form as a pdf together with the photo of the receipt and ask whether the two totals match. for the matching form, it says yes. and when i swap in a form with a different total, it basically says no. now, video is just one more. type of input. so i can pass a short screen recording of a checkout and i ask here whether the order was confirmed by the end. now what do you do with these numbers, right? so this is where the cutoff from earlier comes in. if the confidence is above my cutoff, my code runs and it takes the action. Otherwise, if the confidence is below the cutoff or the threshold that I have defined, you can basically escalate it to a person or a bigger model. So that is the whole pattern, essentially one input, a few questions, and an if statement.

要使用图像,唯一改变的是输入。 所以我不再传字符串,而是传入一张收据的照片,询问它是不是收据,以及上面有没有酒精类商品。 你会发现,其余代码和之前完全一样。 现在,有意思的地方来了。 在酒精那一项的回答中,“是”的概率非常低,但置信度很高,因为模型很确定答案是“否”。 音频的处理方式也一样。 所以这里我传入一段来电者的录音,询问他们是否想和人工客服通话。 现在,最精彩的部分是,你还可以在同一个单元格中混合多种输入。 这里我同时传入一份PDF格式的理赔表和一张收据照片,询问两者的总金额是否一致。 对于金额一致的表单,它回答“是”。 而当我换成总金额不同的表单时,它基本上回答“否”。 现在,视频只是另一种 输入类型。 所以我可以传入一段简短的结账屏幕录像,然后在这里询问订单最终是否被确认。 那么,这些数字你要怎么用呢? 这就是前面提到的临界值发挥作用的地方。 如果置信度高于我设定的临界值,我的代码就会运行并执行相应操作。 否则,如果置信度低于临界值,也就是我定义的阈值,你基本上可以把它升级交给人工处理或更大的模型来处理。 所以整个模式本质上就是:一个输入、几个问题,再加上一个if语句。

Now, let me talk about a few mistakes that I have seen people make with decision models. And most of them come from because they treat decision models in a very similar way as a normal LLM. which you shouldn't be doing.

接下来,我想谈谈我见过人们在使用决策模型时常犯的几个错误。 而其中大多数问题,都是因为他们把决策模型当成了普通的大语言模型来对待。 而这恰恰是你不该做的。

说话人 0

let's start with the simplest example, which is a router that sends support messages to one of the three available departments. this is probably the first example that you're going to see in any decision model. and it actually works perfectly in our test case. but here's something that a lot of people ignore when they are routing these messages. for example, when i asked what the weather is in paris, it picked technical support with 92% confidence. now, the reason is that a choice question always picks one of your options, even when none of them fits. so the confidence only tells you which of your options is the closest. and this is one of the biggest limitations of decision models. the fix is to add an option called other with a description. and with that, option it picked other so the first rule of using a decision model is to always give it a choice as a way out.

我们先从最简单的例子开始:一个路由器,把支持消息分派给三个可用部门之一。 这可能是你在任何决策模型中都会首先看到的例子。 在我们的测试用例中,它实际上运行得非常完美。 但有一点很多人在路由这些消息时都会忽视,我们来看看。 例如,当我问巴黎的天气怎么样时,它以92%的置信度把问题归入了技术支持。 原因在于,选择题总会从你提供的选项中挑出一个,即使没有一个选项真正合适。 所以置信度只能告诉你,在你的选项中哪一个最接近,而不能说明它是否正确。 这也是决策模型最大的局限之一。 解决办法是添加一个名为“其他”的选项,并附上描述。 加上这个选项后,它选择了“其他”。所以使用决策模型的第一条规则是:始终给它一个备选出口。

now let's talk about a second mistake that a lot of people make when they are using decision models. in this case, the application is the expense claims auditor from the start of the video, where every claim has the amounts that the employee typed in and a photo of the receipt. in my first version, i sent the whole expense policy with the photo and asked whether the tip was above 20%. on one receipt, the tip was 15%, and the model said yes with a very high confidence. in this case, the math is easy. so the question was, why exactly a system like this would get it wrong? it turns out the receipt was dated after the trip. so it broke a different rule in policy, and that leaked into the tip answer. when we actually removed that policy text, the answer was right. So the second rule, which is also in Google's documentation, and this is a critical one, is to send only what the question needs and to compare numbers in code. This is important because unlike a normal LLM, you can't just dump your policies with irrelevant information to a decision model. You want to provide the proper context. So in the final version, the code checks the dates and the limits, and one decision call checks the photos. Now the beauty is that you can cascade a number of different decision points. So for example, it asks whether this is a receipt, whether it is itemized, whether there is alcohol on it, and whether the total matches the claim. For the seven sample claims, every claim got the action that I expected, and the claim where the total didn't match the receipt went to a person. So whenever you are creating these decision points, make sure that the decision model is making one decision at a time.

现在我们来谈谈很多人在使用决策模型时会犯的第二个错误。 在这个案例中,应用程序是视频开头提到的费用报销审核员,每条报销记录都包含员工填写的金额以及收据照片。 在我的第一个版本中,我把完整的费用政策连同照片一起发送给模型,并询问小费是否超过20%。 对于其中一张收据,小费比例是15%,但模型却以非常高的置信度回答“是”。 在这个情况下,计算其实很简单。 所以问题是,像这样的系统为什么会出错呢? 原来,这张收据的日期是在行程结束之后。 因此它违反了政策中的另一条规则,而这个问题影响到了关于小费的判断。 当我们真正删掉那段政策文字后,答案就对了。 所以第二条规则(同样出现在谷歌的文档中,而且非常关键)是:只发送问题所需的内容,并在代码中比较数字。 这很重要,因为与普通大模型不同,你不能把政策连同无关信息一股脑儿丢给决策模型。 你需要提供恰当的上下文。 因此在最终版本中,代码检查日期和限额,而由一次决策调用检查照片。 妙处在于,你可以把多个不同的决策点串联起来。 例如,它会询问这是不是收据、是否有逐项明细、上面是否有酒类,以及总额是否与报销金额相符。 对于七个样本报销单,每一个都得到了我预期的处理结果,而总额与收据不符的那一单转交给了人工。 所以,在设计这些决策点时,务必确保决策模型每次只做一个决定。

Now this brings us to the third biggest mistake that I have seen a lot of people make with decision models, and that is ask one big question with multiple different options that are all plausible. So for example, here's the browser agent from the start of the video. In one of its earlier iterations, I asked a question which was what should the agent do next? no, the trend that i saw was that it would usually stop at the second step. because there were multiple different options that were equally valid, and the confidence gets divided between these valid options. for example, here you can see that the cookie banner was still there and the card field was empty. two steps were both valid and the probability was split between them. And as a result, that puts the confidence below the cutoff that I have defined, and the agent is built to stop when it's not sure. So if you're using a decision model, essentially you want to replace these big questions with small questions. So in my case, I replaced that one question with five small yes or no checks, and the order is decided in code. but then it stopped again on a different step. one of those checks asks whether the card field is empty. and the field shows gray example digits. the model reads those as filled fields until i decided what empty means in the question. so the third rule is to ask small questions and to describe exactly what you mean. with those changes, the agent completes the checkout with four actions.

接下来谈第三个最大的错误,我见过很多人在使用决策模型时都会犯:提出一个大问题,却给出多个都看似合理的选项。 举个例子,这就是视频开头提到的浏览器智能体。 在它的早期版本中,我问了一个问题:智能体接下来应该做什么? 不对,我观察到的趋势是,它通常会在第二步停下来。 因为有多个同样有效的选项,置信度被分摊到这些有效选项之间。 例如,你可以看到此时 Cookie 横幅仍在,而银行卡信息栏是空的。 两个步骤都有效,概率在它们之间被分摊。 结果,置信度便低于我设定的阈值,而智能体的设计是在不确定时停止。 所以如果你在使用决策模型,本质上应该把这些大问题替换成小问题。 就我的情况而言,我把那个问题替换成了五个小的是非判断,而且顺序由代码决定。 但随后它又在另一个步骤停下了。 其中一项检查会询问银行卡字段是否为空。 而该字段会显示灰色的示例数字。 在我明确“为空”在问题中的含义之前,模型会把这些示例数字当作已填写的字段来读取。 因此第三条规则是:提出小而具体的问题,并准确描述你的意思。 做出这些调整后,智能体只用四步操作就完成了结账。

i also ran the same loop on a live demo site that was not built for it and it still finished on the first try. so it's a very powerful model. you just need to make sure you use it properly. okay, so the last application that i'm going to showcase is a voice agent. so i send the caller's audio directly without transcribing it first because this model can process audio directly, which is. pretty neat. now, the questions here are whether the caller has finished speaking, whether they want a human agent, and how frustrated they sound. so for the caller who asks for a real person, it hands off. and for the caller who is looking for an order number, it will simply keep listening to them. now, one thing which i noticed was that i was testing this on synthetic voices, so it worked. but when i added my own voice to the mix, it flagged the clip where i stumbled and restart a sentence, which is useful when you did things. now, one really critical limitation to keep in mind is that a decision model cannot explain an answer because it doesn't generate text. so you need to be careful if your decisions need explanation. then you still probably want to use a conventional large language model. so when does a decision model make sense instead of an llm?

我还在一个并非为此设计的线上演示网站上运行了同样的循环,它第一次尝试就完成了任务。 所以这是一个非常强大的模型。 你只需要确保正确地使用它。 好,接下来我要展示的最后一个应用是语音智能体。 所以我不先转录,而是直接发送来电者的音频,因为这个模型可以直接处理音频,这一点很…… 相当酷。 现在,这里要判断的问题是:来电者是否说完了,是否想转接人工客服,以及他们听起来有多沮丧。 因此,对于要求转接真人的来电者,它会进行转接。 而对于询问订单号的来电者,它只会继续倾听。 我注意到的一点是,我一直在用合成语音进行测试,所以效果很好。 但当我加入自己的声音后,它标记出了我说话磕绊、重新开始一句话的那段音频,这在你需要复盘说话内容时很有用。 还有一个非常关键的局限需要牢记:决策模型无法解释其答案,因为它不生成文本。 所以如果你的决策需要解释,就要格外小心。 那么你可能仍然需要使用传统的大型语言模型。 那么,决策模型在什么情况下比大语言模型更合适呢?

the answer is any decision with a fixed set of answers that happens many times and has to happen fast. for those, i would use a decision model with a confidence cutoff and i would keep the llm for anything that needs generated text or multi-step reasoning. So if you build with it, I would highly recommend old rules from my own observations, which are giving every choice a way out, sending only what the decision needs, asking small questions, and testing your own data, not on just synthetic data. If you have come up with other places where the decision model fits, please do share them in the comment section below. Links are going to be in the video description. I'm putting together a video on using a decision model inside an agent loop, so if you are interested in that, make sure to subscribe to the channel. now, if you want to learn more about decision models, watch this video. anyways, i hope you find this video useful. thanks for watching and as always, see you in the next one.

答案是任何具有固定答案集、会频繁发生且必须快速完成的决策。 对于这类决策,我会使用带有置信度阈值的决策模型,而对于需要生成文本或多步推理的任务,我会保留使用大语言模型。 所以如果你要用它来构建系统,我强烈推荐我自己总结的一些经验:为每个选择提供退路,只发送决策所需的内容,提出简短的问题,并且用你自己的数据测试,而不只是用合成数据。 如果你还想到了决策模型适用的其他场景,欢迎在下方评论区分享。 相关链接会放在视频简介中。 我正在制作一期关于在智能体循环中使用决策模型的视频,如果你对此感兴趣,请记得订阅频道。 现在,如果你想更深入地了解决策模型,可以观看这个视频。 总之,希望你觉得这个视频有用。 感谢观看,我们下期再见。

摘要

视频介绍 Google 的 Gemini Decision 1 决策模型。它与生成文本的 LLM 不同,对文本、图片、音频、PDF 和视频输入,按固定选项给出概率和置信度,不输出任何文本,因此速度快、成本低。视频依次演示了 Decisions API 的调用方式、是非、选择、评分三种问题类型、多模态输入,并与 Gemini Flash 做了成本对比。随后作者总结了三个实际踩过的坑:选择题未设置 Other 选项、发送了无关上下文、问题过大且定义模糊,并给出对应修正方法。视频最后指出,决策模型无法解释原因,适合高频、快速、选项固定的决策场景,而需要生成文本或多步推理时仍应使用 LLM。

章节

00:00 决策模型概念与演示

Gemini Decision 1 是 Google 推出的决策模型,属于一类不生成文本的分类模型。使用者提供输入和一组固定选项,模型选出结果并给出置信度,代码可据此执行业务规则。视频开头展示了两个演示:一个在结账页面上运行的浏览器代理,每一步截图后用若干是非题判断下一步动作,如关闭 Cookie 横幅、填写邮箱、输入卡号并下单;一个报销审计应用,用一次调用对照收据照片与员工申报金额,金额一致的予以通过,不一致的转交人工处理。

Gemini Decision One 产品发布画面
新模型额外能力的概览画面
决策模型定义与无文本输出的说明画面
模型输出选项及置信度的展示画面
代码可据此执行的决策结果画面

01:44 决策模型与 LLM 的区别

LLM 回答是非题时需要逐个 token 生成答案,许多新模型还会先思考,因此既要支付思考和输出 token 的费用,也要等待生成,最后代码还需解析文本。决策模型跳过这些步骤:它在一次前向计算中为每个选项打分,读取一次输入和问题,不写任何文字,输出 token 始终为零,并附带置信度。可将其理解为一个会给出置信度的智能 if 判断,代码可设置阈值,低于阈值的结果转给人工或更大的模型处理。作者认为很多业务逻辑本质上就是这类小决策,因此决策模型适合用于工作流。

决策模型输出每个选项的概率结果,属于直观的输出证据

03:12 三种问题类型与典型应用

决策模型支持三种问题:是非题返回回答为是的概率;选择题提供选项列表,返回胜出项及每个选项的概率;评分题提供有序评分标准,返回对应刻度上的数值。作者指出,支持文本、图片、音频、视频和 PDF 输入,并且与 TypeSafe 的 JEV 等决策模型结构相似,OpenAI 也推出了 Decisions API。视频认为,常见的工单分类示例并非这类模型最有价值的用途,更有价值的场景包括在 Agent 循环中做工具选择与任务完成判断、对检索结果做低成本重排,以及对几乎所有输出进行抽检,例如筛查提示注入。

三种问题类型总览画面
Gemini decision 模型界面或标题
是/否问题及概率输出示例
选项列表与各选项概率示例
有序评分量表与分数输出示例

04:50 应用场景与成本对比

作者的基准测试中,决策模型从 24 个工具中选择工具,每次都选对。在文档检索场景中,对 10 个文本块做一次调用,三个相关块排在最前。作者还用单个输入发送 1000 个是非题,调用成本仅约半美分,速度也明显快于普通 LLM 调用。成本方面,Decision 1 在付费层的输入价格为每百万 token 10 美分,并有免费层。作者用结构化输出的 Gemini Flash 作对比:一条消息路由到四个队列的任务,决策调用每百万次约 10 美元,Flash 约 170 美元,差距主要来自输出和思考 token 的消除及更低的单价。决策调用的输入 token 反而更多,因为每个问题自带约 50 个 token。

十个文本块的重排结果,三个相关块排在最前
定价信息:每百万输入 token 的价格
路由决策调用的每百万次成本
Flash 调用的每百万次成本对比

07:29 Decisions API 基础调用

调用前需要 Google AI Studio 的 API Key,免费层已足够本教程。Decisions API 由三部分组成:模型、输入和问题。示例中模型为 Gemini Decision 1,输入是一条说杯子破裂到货的客户消息,问题是商品是否损坏。问题由类型和用简单英语写的说明构成,运行后返回“是”的概率为 99% 并附带置信度,输出 token 为零。同一调用还可加入选择题(从支持队列中选择)和评分题(评估客户的挫败感),文档建议为每个选项提供简短描述,单次调用即可返回全部结果,且消息本身只计费一次。切换为图片输入时,只需把输入从字符串换成收据照片,其余代码不变。

运行返回结果中显示回答为是的概率99%及置信度
用量信息中输出 token 数为零

09:12 多模态输入与阈值判断

图片输入中,收据照片可用于判断是否为收据以及是否含酒精。其中酒精问题的“是”概率很低但置信度很高,说明模型较确定答案为否。音频输入同样只需替换输入,例如判断来电者是否要求转人工。不同输入可在同一调用中混合,如 PDF 申报表加收据照片,判断两者金额是否一致,金额一致时返回“是”,换成不同总额的表单则返回否定结果。视频输入也是同样的做法,可判断结账录屏中订单是否最终确认。作者的做法是:置信度高于阈值时代码执行动作,否则升级给人工或更大的模型,整个模式就是一个输入、若干问题和一个 if 判断。

图像输入示意
收据照片输入
代码保持不变的讲解
引入关键观察前的过渡画面
低概率与高置信度的数值结果

10:59 错误一:选择题缺少 Other 选项

作者用一个将支持消息分配到三个部门的路由器说明问题。测试中,询问巴黎天气时,模型以 92% 的置信度选择了技术支持。原因在于选择题总是从给定选项中挑一个,即便没有合适选项,置信度也只表示哪个选项最接近。解决办法是增加一个带描述的 Other 选项,加入后模型正确选择了 Other。因此使用决策模型的第一条规则是:始终给选择题提供一个出口。

天气问题被路由到技术支持,并显示92%置信度
添加名为 Other 的选项及描述
选择 Other 选项后的路由结果

12:15 错误二:发送了无关上下文

在报销审计应用的第一版中,作者把完整的费用政策与收据照片一起发送,询问小费是否超过 20%。一张收据的小费为 15%,模型却以很高的置信度回答是。原因是收据日期晚于出差日期,违反了政策中的另一条规则,这一判断影响了小费的回答。删除无关政策文本后,结果正确。因此第二条规则是只发送问题所需的内容,并在代码中比较数字。最终版本由代码检查日期与限额,决策调用只负责检查照片,并把多个判断串联起来,每次只做一个决定。七份示例报销单的结果都符合预期,总额不符的那张被转交给人工。

收据小费率为15%,模型却回答超过20%
收据日期晚于出差日期,违反其他政策规则
移除无关政策文本后,判断结果恢复正确
七个样例报销单的处理结果汇总

14:10 错误三:问题过大且定义模糊

浏览器代理的早期版本只问一个“下一步应该做什么”的大问题,多个同样合理的动作会分摊置信度,导致代理通常在第二步就停下,因为置信度低于阈值,而代理设计为不确定时就停止。作者把这个问题替换为五个小的是非检查,动作顺序由代码决定。但随后又出现了问题:卡号栏显示灰色示例数字,模型把它当作已填写,直到问题中明确定义“为空”的含义。因此第三条规则是提出小问题,并准确描述意图。修改后,代理用四步完成了结账,并在一个并未为其设计的现场演示网站上一次成功。

浏览器代理页面中cookie横幅仍在、银行卡字段为空的状态
卡号字段显示灰色示例数字,易被模型误读为已填写

15:48 语音代理与模型局限

语音代理直接发送来电音频,不先转写,并提出三个问题:来电者是否说完、是否要求人工坐席、语气有多挫败。要求转人工的来电者会被转接,正在查询订单号的来电者则继续等待。作者最初使用合成语音测试效果良好,加入自己的声音后,模型还能标记出说话结磕、重说一句的片段。局限在于,决策模型不生成文本,因此无法解释答案,如果决策需要解释,仍需使用常规的大语言模型。

同一循环在未专门构建的实时演示站点上一次完成
语音代理应用演示开始
遇到真人请求时代理转接的结果
自有语音片段被标记为口误重说的结果
决策模型无法解释答案的限制(无明确画面,代表性锚点)

17:11 适用场景与使用建议

作者认为,当决策具有固定的答案集合、会大量重复发生并且需要快速完成时,应选择决策模型,并配合置信度阈值使用。需要生成文本或多步推理的任务,仍应交给 LLM。作者总结的使用建议包括:为每个选择题提供出口选项,只发送决策所需内容,把问题拆成小问题,并使用真实数据而非仅合成数据进行测试。

决策适用场景的核心定义
决策模型与置信度阈值的建议
使用建议的核心规则
邀请观众分享其他适用场景
视频简介中的相关链接

结论

02:19 Gemini Decision 1 不生成文本,而是为固定选项给出概率和置信度,输出 token 始终为零。

02:39 决策模型的置信度可作为代码阈值,低于阈值的结果可转交人工或更大的模型处理。

06:51 在本视频的成本测试中,决策调用每百万次约 10 美元,而 Gemini Flash 约为 170 美元,主要差距来自输出和思考 token。

12:05 选择题总会从给定选项中挑选一个,因此应始终提供带描述的 Other 选项作为出口。

13:08 决策模型应只接收问题所需的内容,数字比较等规则检查应放在代码中完成。

15:07 大而含糊的问题会分摊置信度,应拆分为小的是非题,并明确定义每个术语的含义。

17:00 决策模型无法解释答案,需要解释的决策仍应使用常规大语言模型。

Gemini Decision 1:你不需要 LLM 也能做决策 · 视频总结 · OctSum