读见

别再用生成式 LLM 处理每一道选择题:Glean 的决策模型实践

原题Stop Paying LLM Prices for Yes-or-No Answers — Chinmay Goyal, Glean

约 11 分钟原文英文已翻译

视频由 YouTube 提供

推荐理由做企业搜索的团队可借 Glean 的分类与排序例子,盘点系统里哪些步骤已有稳定标签,适合独立设定可测目标。

看前速览

3 个要点

Glean 工程师 Chinmay Goyal 介绍团队如何用决策模型处理查询分类、专家路由、建议排序和引用检查。

  1. 先验证工作流,再扩大使用范围

    Glean 用黄金评估集、内部试用反馈和客户 A/B 测试来防止回归。

  2. 结构化决策有助于降低延迟

    团队称,专家路由延迟降到原来的约八分之一,后续问题建议的按时返回率达 99.2%。

  3. 能列出输出选项时,考虑决策模型

    这类模型可用于排序、可复现的引用检查和强调召回率的首轮安全筛查。标签经常变动,也会让反复微调失去吸引力。

完整摘要

只要能提前列出输出选项,产品流程中的不少环节就可以交给决策模型。Glean 先用黄金评估集检查回归,再在内部试用,最后做客户 A/B 测试。按团队公布的数据,专家路由延迟降到原来的约八分之一,后续问题建议的按时返回率从约 90% 升到 99.2%。引用检查更容易复现,安全分类首轮召回率也从 31.5% 升到 90.2%。

章节

文字稿

查看原文

简要说明Brief Description

别再为“是/否”答案支付大语言模型的价格——Chinmay Goyal,GleanStop Paying LLM Prices for Yes-or-No Answers — Chinmay Goyal, Glean

目录Table of Contents

  • 大多数 AI 步骤都是有界决策。
    Most AI steps are bounded decisions
  • 大语言模型、开放模型、微调还是 Jev
    LLMs, open models, fine-tuning or Jev
  • Glean 如何评估变更
    How Glean evaluates changes
  • 查询分类
    Query classification
  • 专家路由,延迟降至原来的八分之一
    Expert routing at 8x lower latency
  • 对后续建议进行排序
    Ranking follow-up suggestions
  • 无效输出为零
    Zero invalid outputs
  • 自整定阈值
    Self-tuning thresholds
  • 一致的 LLM 引用评判标准
    Consistent LLM-as-judge for citations
  • 安全召回率从 31.5% 提升至 90.2%
    Security recall from 31.5% to 90.2%
  • 何时使用决策模型
    When to use a decision model

大多数 AI 步骤都是受限决策。Most AI steps are bounded decisions

大家好,我叫 Chinmay,是 Glean 的一名软件工程师,负责 Glean Assistant 的产品工程。今天我想分享一下 Glean 如何使用 Jev。这次演讲的标题是《超越生成:Jev 如何助力 Glean 实现快速、结构化的 AI 决策》。仔细想想,AI 产品中的大多数步骤都是受约束的决策,而不是生成问题。举几个例子:对用户查询进行意图分类;由排序器从 n 个选项中挑选一条建议;检查引用是否有效;将请求路由到合适的模型或专家,等等。Hi everyone. My name is Chinmay and I am a software engineer at Glean. I work on the product engineering side of Glean Assistant. Today I'm going to give a talk on how Glean uses Jev. The title of the talk is Beyond Generation. Fast and structured AI decisions with Jev at Glean. If you look at it, most AI product steps are bounded decisions and not generation problems. So to give a couple of examples, user query intent classification, a ranker picking a suggestion out of n options, checking whether a citation is valid or not, routing to the correct model or expert, and so on.

大语言模型、开放模型、微调或 JevLLMs, open models, fine-tuning or Jev

到目前为止,为了回答所有这些有界问题,我们一直在承担完整的 LLM 成本和延迟。Glean 的 Jev 填补了通用 LLM 与微调分类器之间的空白。分类本身并不是一个新问题,人们很早以前就一直在尝试解决它。我们可以通过多种方式来解决。有些尝试包括使用通用 LLM、使用开放模型(例如 LLaMA)、微调这种开放模型,或者使用 Jev。所有这些方法各有利弊。使用通用 LLM 会产生很高的成本和延迟,而使用 Jev 之类的方法则无法生成文本输出。我们发现 Jev 的另一个优势是,随着决策空间的分类体系发生变化,我们不必一次又一次地重新微调这些模型。Till now we have been paying the full LLM cost and latency to get an answer to all these bounded problems. Jev at Glean fills the gap between general LLMs and fine-tuned classifiers. Classification itself isn't a new problem. Like people have been trying to solve it since forever. We can have multiple ways to solve it. Some of the things that we have tried out include using a general purpose LLM, using an open model, something like LLaMA, fine-tuning that open model, or using Jev. Now all these approaches and all these different ways have their pros and cons. With a general purpose LLM, we incur a lot of cost and latency, while with something like Jev, we get no generated text output. Another advantage that we have been seeing with Jev is that as the taxonomy of the decision space changes, we don't have to fine-tune these models again and again.

我们只需稍微调整一下提示词,嘭,它就能开箱即用。接下来,我会带你了解我们在 Glean 如何使用 Jev 来解决这些分类问题陈述。我会详细讲解其中的一些问题。在逐一讨论这些问题之前,我想先谈谈我们如何评估这些改动。We can just change our prompt a bit and boom, it works out of the box. Now I'll walk you through how we used Jev at Glean to solve these classification problem statements. I'll go into some of these problems in great detail. Before we go into these individual problems, I wanted to touch upon how we evaluate these changes.

Glean 如何评估变更How Glean evaluates changes

我们的客户群体非常庞大,拥有数百万用户,因此我们不希望任何改动导致产品出现退步。对于每项改动,我们都会采用分阶段的推进方式。我们为几乎所有可能的场景都准备了黄金评测集。凡是用到生成式 AI 或任何形式智能能力的地方,我们都会为其准备黄金评测集。所有这些改动都会先在内部使用场景中经过一段时间的充分验证。目前 Glean 大约有 1500 名员工。我们会在自己的 Glean 实例中对这些改动进行数周的充分验证,并积极收集反馈。内部用户的反馈机制非常活跃,我们会据此不断改进,然后再面向客户进行 A/B 测试。We have a huge customer base having millions of users, so we don't want any of the change that we make to regress our product. We have a multi-phase approach, a rollout approach to any change that we are making. This includes having a golden eval set for almost every possible thing. Like any place where we have generative AI, any place where we have any form of intelligence involved, we have a golden eval set for that space. We soak all of these changes for a significant amount of time for our internal use case. Like we have around 1500 people at Glean right now. We soak all of these changes within our Glean instance for like couple of weeks. We get active feedback. We have a very active feedback loop from our internal users. We work upon that and then we run an A/B test with our customers.

查询分类Query classification

我们用决策模型尝试解决的第一个问题是查询分类。查询分类就是了解用户查询的性质。这有助于我们了解人们会用 Glean 来处理什么类型的工作?什么类型的……例如,如果人们更多地用它来处理销售类查询,我们就会更侧重这方面。如果人们更多地用它来处理工程类用例,我们就会更侧重这方面。我们在这里尝试了三种不同的方法,这些数据来自我们的测试环境。我们使用了一个开源 Llama 模型。然后我们尝试了 Jev,接着又利用自己的计算资源对 Llama 模型进行了微调。在我们看来,Jev 是最好的免训练方案。它的输出质量几乎是基础版 Llama 模型的两倍,并且能够达到微调版 Llama 质量的 90%。使用 Jev,我们不必经历非常繁琐的数据收集和数据清理过程,也不必承担训练模型等计算成本;随着分类体系发生变化,我们也不必一次又一次地重新微调模型,同时还不用担心模型托管或推理成本。The first problem that we tried out with a decision model was query classification. Query classification is when we want to know the nature of user queries. This helps us realize what kind of what kind of jobs are people using Glean for? What kind of Say for example, if people are using more for sales like queries, we focus more on that. If we people are using more for engineering type use cases, we focus more on that. We tried out three different approaches over here and this is data from our test bed. We used an open source Llama model. Then we tried out Jev and then we fine-tuned the Llama model on our own compute resources. Jev is the best no training option in our opinion. It nearly doubles the output quality of a base Llama model and is able to achieve 90% of the quality of a fine-tuned Llama. With Jev we don't have to go through the very tedious process of data collection, data cleaning, incurring the cost for compute like training the model, fine tuning the model again and again as the taxonomy changes and at the same time we don't have to worry about hosting the model or incurring the inference cost.

专家路由,延迟降低 8 倍Expert routing at 8x lower latency

接下来我们讨论的问题是专家路由。这是目前业界很常见的一类问题:用户查询进来时,我们应该把它路由给哪位专家?我们该如何确保给用户的回复质量尽可能高?The next problem we went to is expert routing. This is a pretty common problem statement in the industry right now like hey when the user query comes in what expert do we route it to like how do we ensure that the response to the user is of the best possible quality.

Glean 接收用户查询后,会判断由哪位专家来回答该查询最合适。到目前为止,我们一直使用通用 LLM 将查询路由给正确的专家。我们为 Jev 搭建了一个包含 N 位专家的测试平台,并在实验中发现,使用 Jev 时准确率显著提高,同时延迟几乎降低了 8 倍。要将 Jev 集成到产品的这一特定环节,我们不得不大幅调整实现方式或基础设施,但延迟的降低足以证明系统中这种固有复杂性是值得的。Glean 一直致力于以尽可能简单的方式构建系统。这是少数几个我们认为复杂性值得付出的地方之一。Glean receives the user query and then decides what's the best expert to answer the query. Till now we have been using a general purpose LLM to route to the correct expert. We set up a test bed for Jev with N experts and in our experiments found a significantly high precision when using Jev and that too at an almost 8x reduction in latency. We had to change our implementation or our infrastructure significantly to integrate Jev into this specific stage of our product but the reduction in latency justifies that inherent complexity in the system. We at Glean have been trying to build systems in the most in the simplest possible manners. This is one of the rare pieces where we believe complexity is worth it.

后续建议排序Ranking follow-up suggestions

接下来我会带你了解我之前提到的排序器问题陈述。收到用户查询时,我们还希望为用户生成最佳的后续建议,这有助于提升我们产品的可发现性,也能确保用户获得尽可能好的体验。我们还希望推荐,或者说预判用户接下来可能会提出什么查询。这是整个行业一直在努力解决的一个相当常见的问题陈述。在内部,我们把这个系统称为 Q,字面上的字母 Q。它的工作方式是:我们有 10 到 15 个来源,各自独立生成建议。Next I'll walk you through the ranker problem statement that I talked about. When we receive a user query we also want to generate the best follow up suggestions for the user like this helps us in getting discoverability for our product. This helps us in ensuring that the user has the best possible experience. We also want to recommend or say preempt what the next user query might be. Again, a pretty common problem statement that the entire industry has been trying to solve for. Internally, we call this system Q like Q as in the literal Q. The way this works, we have 10 to 15 sources that are generating suggestions independently of each other.

这些建议由自然语言 LLM 生成,而且每条都是自然语言查询。生成这些建议后,我们会进行排序。排序器会接收所有这些建议、用户最初的查询、Glean 给出的输出,以及这些建议在该上下文中的信息。然后,我们会让排序器判断:你有这些建议,觉得哪一条最好?这里一个相当有意思的瓶颈是,我们希望响应足够迅速。不能先把文本回复给用户,然后再等 5 秒才生成后续建议。我们必须快速响应。这就是为什么我们会为这些建议设置时间限制。目前,这一步的时间限制是 1.5 到 2 秒。These suggestions are generated by natural language LLMs and each is a natural language query. Once these suggestions are in, we have a ranking step. So the ranker takes in all these suggestions, takes in the first user query, takes in the output that Glean gave, and then all these suggestions in that context. The ranker is then asked to decide like, hey, you have these suggestions, what do you think is the best one? A pretty interesting bottleneck that we had over here is we want the response to be snappy. We cannot have a state where we give the textual response to the user and then wait 5 seconds for generating the follow-up suggestion. We have to be snappy. That's why we have time limits on these suggestions. So right now this step had a time limit of 1.5 to 2 seconds.

Jev 的质量更好,延迟也远低于我们之前使用通用 LLM 时的水平;其中有两点尤为突出。首先,我们能够在规定的时间范围内提供建议的情况占 99.2%。而使用通用 LLM 时,这一比例接近 90%。因此,我们确保了用户参与度,并且现在收到的用户查询也多得多。Jev gave us better quality and far better latency than what we had with a general purpose LLM, but two things stood out over there. First, we were able to give a suggestion within our time bounds in 99.2% cases. With the general purpose LLM, this was almost 90%. So this ensures that we have user engagement and far more user queries now.

零个无效输出Zero invalid outputs

第二点是,在 Glean,我们每次使用这些 LLM 时都会设置护栏。这里所说的护栏,是指 LLM 可能不擅长生成回复,或者可能会犯某些特定类型的错误。因此,对于我们能预见到的所有这些错误,我们都设置了检查和平衡机制。我们会记录下来,比如说,随时记录所有触发过的这些检查。使用通用 LLM 时,我们在近 90% 的情况下都能生成有效建议。不过仍有一些情况,LLM 生成的回复使用了另一种语言,或者输出不符合我们通过程序编写的一些其他标准。The second thing is at Glean, whenever we use these LLMs, we have guard rails. Guard rails in the sense that here LLM might not be good at generating a response or LLM might be making some specific kind of mistakes. So we have checks and balances for all those possible mistakes that we see. We keep a log of like we keep a log of all these checks that are incurred at any point of time. With a general purpose LLM, we were able to generate a valid suggestion in almost 90% of cases. We still had some places where LLM was either generating a generating a response in a different language. The output did not meet certain other criteria that we had that we had written programmatically.

使用 Jev 时,我们发现输出无效时为零种情况。现在自然会有人问:嘿,但你们用的提示词不是不一样吗?是的,提示词确实有所不同,但我们尽可能让这两种情况下的提示词保持一致,以免出现偏差。再说一次,我们 Glean 希望尽可能让系统保持简单。With Jev, we found zero cases to be there when the output was invalid. Now a natural question is like, hey, but you would have used a different prompt. Yes, the prompt was somewhat different, but we tried to mimic the prompt in the two cases to the largest extent possible so that we don't have a divergence. Like again, we at Glean want to keep the system as simple as possible.

自调优阈值Self-tuning thresholds

使用决策模型的另一个优势是,我们可以控制阈值。在这个排序器的问题设定中,我们会得到每个输出对应的具体概率,而不受限于“是”或“否”这样的二元回答。比如,模型会告诉我们:“这是五个选项,它们各自的概率分别是多少。”这样,我们就能根据部署情况微调阈值。我们还引入了自学习系统,它会根据客户的部署环境和具体使用方式,自动微调阈值。Another benefit we see with using a decision model is how we can control the thresholds because in this ranker problem statement, we are getting specific probabilities of each output. We are not restricted to a binary yes or no response. We get like, hey, these were the five options and these are the probabilities of these five options. With this, we are able to fine-tune the thresholds based on the deployment. We have put in self-learning systems which based on the customer deployment and the nature of usage that the specific customer has fine-tunes the thresholds by itself.

这确保了每一位客户都能根据自己使用 Glean 的方式获得尽可能好的体验,而不是采用一种适合所有人的通用解决方案。好,这是个有意思的话题。接下来,我们不再讨论如何改善终端用户的生活或体验,而是来谈谈我们如何尝试在开发流程中使用 Jev 和其他部分。This ensures that the experience in each and every customer out there is the best possible based on how they use Glean, not a general purpose solution that fits all. Okay, this is an interesting one. Now moving on from how we have been making the lives or the experience of our end users better, we also tried using Jev and other parts of our development pipeline.

用于引文评估的一致性 LLM-as-judgeConsistent LLM-as-judge for citations

其中一个就是我们如何将 LLM 用作评判者。我们大家已经使用 LLM 作为评判者相当长一段时间了。我们有一个输入、一个输出,然后用 LLM 来评判输出的质量。当然,每当我们使用 LLM 作为评判者时,都会多次重复实验,以应对回复中的变化。在 Glean,我们在评估流程中的一个特定环节使用了 Jev。和其他 AI 产品一样,Glean 的回复也会附带引用。人们正是通过这些引用来信任 Glean 给出的答案,确认答案正确且有相应文档作为依据。我们对这些引用的要求非常严格,并且在评估流程中设有一个专门环节,用来检查被引用的文档是否确实支持答案中的说法。One of them was how we use LLM as judges. Like all of us have been using LLM as judges for quite some time now. There's an input, there's an output, and we use an LLM to judge how the quality of the output is. Now naturally, whenever we use LLM as a judge, we repeat the experiment multiple times because to account for the variability in the response. At Glean, we used Jev for a very specific part of our evaluation pipeline. Like other AI products, Glean responses have citations. This is how people trust that Glean's answer was correct and it is grounded in the correct document. We hold these citations to a very high bar and we have a specific part in our evaluation pipeline where we check whether the cited document really supports the claim made in the answer or not.

这又似乎是一个相当简单的“是或否”问题,比如说,这项主张是否有依据。使用 Jev 时,我们的延迟和成本都低得多,正如这张幻灯片所示。我们在这里注意到一个有趣的现象:与其他模型相比,Jev 的结果非常一致,也很容易复现。在我们测试的 28 或 30 个用例中,只有一次运行的回复出现了差异。除此之外,结果都很一致。对我们这些工程师,也就是 Glean 的开发者来说,这意味着两件事。我们不再只是提升产品质量,也不再只是以线性方式改进 Glean。开发流程中任何达到这种程度的改进,都会让我们改进产品的能力呈指数级增长。This again seems to be a pretty simple yes or no question like hey whether the claim is supported or not. With Jev we had a far better latency and cost like visible in the slide over here. The interesting thing we noticed over here is how consistent and reproducible Jev results were in comparison to other models. In the 28 or 30 use cases that we had, like only one run had like a difference in response. Apart from that, everything was consistent. This means two things for us as engineers or us as developers at Glean. We are not only improving the quality of our product or we are not only improving Glean in a linear fashion anymore. Any improvement of this extent in the development pipeline leads to an exponential increase in how we can improve the product.

如果我作为开发者能够以快 5 倍的速度交付功能,这就意味着延迟大幅降低。比如,如果我在成千上万条目上运行这个实验,就能节省大量时间。再说,我不必对同一组输入和输出重复运行多次,因为 Jev 的结果相当一致。所以,如果我能把自己的效率提高到原来的 5 倍或 6 倍,就能向客户交付 6 倍的功能;而这类提升能惠及 Glean 的数百名工程师。因此,一个优秀决策模型带来的影响不再是线性的,而是指数级的,能让我们大幅改进产品。If I as a developer am able to ship things like 5x faster, like this is a significant reduction in latency. Like if I run this experiment across thousands and thousands of entries, this is a lot of time. And again, I don't have to run the same input-output pair multiple times because the results from Jev are quite consistent. So if I'm able to increase my own productivity by like 5x or 6x, I can ship 6x times the features to our customers and these gains apply across hundreds of engineers at Glean. So the impact of a good decision model is no longer linear, it is exponential on how we can improve the product.

安全召回率从31.5%提升至90.2%Security recall from 31.5% to 90.2%

从产品以及让 LLM 充当评审者,转到我们如何处理客户数据,安全是一个重要考量。安全也是所有客户对我们的期待。比如,我们会对工具的所有输入和输出,以及 LLM 的所有输入和输出进行制衡检查。到目前为止,Glean 采用的是多阶段方案,分为两个阶段:第一阶段侧重于高召回,第二阶段是最终的 LLM 检查。所有这些调用都会与实际的工具输入和输出调用并行进行。到目前为止,我们一直在所有客户的环境中使用 T4 GPU 托管一个价值观分类器。Turning from product and LLMs as judges to how we handle customer data, security is a major consideration. Like security is something that all our customers expect from us. So for example, we have checks and balances on all the inputs and outputs coming from a tool, all the inputs and outputs from an LLM. Till now we at Glean have like a multi phase approach. There is like there are two phases to this. The first one is like recall heavy phase and the second one is the final LLM check. All these calls are made in parallel to like the actual tool input output calls. Till now we used to host a virtue classifier using T4 GPUs across all our customers.

因此,Glean 是一种单租户解决方案,也就是说,我们不会在不同客户之间使用或共享资源。每位客户都有自己的部署、自己的实例,并获得所有资源。假设我们有一千位客户,就得在这一千位客户的环境中分别维护 virtue 分类器;这本身就成了一个相当棘手的问题,也占用了 Glean 工程师大量时间。 从这里的结果来看,在第一阶段,我们原本使用 virtue 分类器,后来用 Jev 替换了它,整体召回率从 31.5% 提升到了 90.2%。与此同时,我们也看到成本大幅下降。这里提到的成本仅指资源成本,我们还节省了工程资源方面的成本。我们不必再投入两三名工程师全职维护这些客户环境中的 virtue 分类器或 T4 GPU。So Glean is a single tenant solution like we don't use or share resources across customers. Every customer gets its own deployment, gets its own instance and gets all the resources. So assuming we have thousand customers out there, we had to maintain like virtue classifiers across all these thousand customers, which becomes a pretty difficult problem statement in itself which takes up a lot of time from Glean engineers. So looking at the results over here, the overall recall of the first phase where we used to have a virtue classifier, we replaced that with Jev, went from 31.5% to 90.2%. At the same time, we are seeing a significant reduction in cost. Now this cost is only the resource cost mentioned over here, but we are also saving cost on the engineering resources over here. We don't have to invest like two or three engineers who are full-time maintaining those virtue classifiers or T4 GPUs across customers.

我们的改进幅度或节省成本远超 50%。这张幻灯片总结了我目前为止提到的所有成果。Jev 在 Glean 帮助提升了用户的产品体验,影响了我们开发者在 Glean 的工作方式;最重要的是,它还对我们为客户提供的安全保障产生了非常积极的影响。The improvement or the savings that we have are far more than 50%. This slide concludes all the results I have talked about till now. Jev at Glean has been able to influence the product experience of the users, has been able to uh impact how we as developers have been working at Glean and most importantly it also has a very good positive impact on the security that we provide to our customers.

何时使用决策模型When to use a decision model

我们在 Glean 使用的一条简单规则是:输出能否预先列出来?如果不能,那就是一个自由文本生成问题。回到能够生成自由文本的方案。如果可以,那就用 Jev。标签是否稳定,而且数据量是否很大?如果标签稳定(不过如今这种情况已经很少见了),我们也可以微调一个模型;但如果标签会变化(我认为如今这种情况相当常见),那就再次使用类似 Jev 的方案。显然,如果你需要动态文本,我们也可以尽管尝试更多混合方案,比如将 Jev 与自由文本 LLM 结合使用。A simple rule we use at Glean: Can the output be listed in advance? If no then it's a free-form text generation problem. Go back to something that can generate free form text. If yes then use Jev. Are labels stable and volume high? If this is the case where the labels are stable which is rarely the case anymore uh we can also fine tune a model but if the labels change which in my opinion is quite frequent these days then again use something like Jev. Obviously if you need dynamic text we can like feel free to try out more hybrid approaches like Jev along with free form text LLMs.

我的演讲到此结束。感谢大家聆听。我添加了一个博客链接,里面的博文详细介绍了完全相同的结果。如果大家还有问题,欢迎会后找我交流。谢谢。This ends my presentation. So thank you everyone for listening. I have added a blog like a link to the blog post where we have posted the exact same results in great detail. Feel free to catch me on the outside if you have more questions. Thank you.

值得记下

  1. AI 产品的多数步骤是有明确选项的决策,并不涉及内容生成。
  2. 能不能提前列出所有可能的输出?

← 回到本期 · 第 14 条