GPT-4o加钱能变快!新功能7秒完成原先23秒的任务

金磊 发自 凹非寺
量子位 | 公众号 QbitAI

OpenAI出了个新功能,直接让ChatGPT输出的速度原地起飞!

这个功能叫做“预测输出”(Predicted Outputs),在它的加持之下,GPT-4o可以比原先快至多5倍

以编程为例,来感受一下这个feel:

11d9e2e25c80cd7d06075584ec99a2ff.gif

为啥会这么快?用一句话来总结就是:

跳过已知内容,不用从头开始重新生成。

因此,“预测输出”就特别适合下面这些任务:

  • 在文档中更新博客文章

  • 迭代先前的响应

  • 重写现有文件中的代码

而且与OpenAI合作开发这个功能的FactoryAI,也亮出了他们在编程任务上的数据:

b2ba55de6b8b331b024862895541f420.png

从实验结果来看,“预测输出”加持下的GPT-4o响应时间比之前快了2-4倍,同时保持高精度。

并且官方还表示:

原先需要70秒完成的编程任务,现在只需要20秒。

值得注意的是,目前“预测输出”功能仅支持GPT-4o和GPT-4o mini两个模型,且是以API的形式。

对于开发者而言,这可以说是个利好消息了。

网友们在线实测

消息一出,众多网友也是坐不住了,反手就是实测一波。

例如Firecrawl创始人Eric Ciarla就用“预测输出”体验了一把将博客文章转为SEO(搜索引擎优化)的内容,然后他表示:

速度真的超级快。

它就像在API调用中添加一个预测参数一样简单。

另一位网友则是在已有的代码之上,“喂”了一句Prompt:

change the details to be random pieces of text.
将详细信息更改为随机文本片段。

来感受一下这个速度:

57a62e3b305613c82aba436e7336aaab.gif

也有网友晒出了自己实测的数据:

1bed226fccc3c0ff4011c0f889a9f725.png

总而言之,快,是真的快。

怎么做到的?

对于“预测输出”的技术细节,OpenAI在官方文档中也有所介绍。

042354ed38b3753cb4e8eebca2dde699.png

OpenAI认为,在某些情况下,LLM的大部分输出都是提前知道的。

如果你要求模型仅对某些文本或代码进行细微修改,就可以通过“预测输出”,将现有内容作为预测输入,让延迟明显降低。

例如,假设你想重构一段 C# 代码,将 Username 属性更改为 Email :

/// <summary>
/// Represents a user with a first name, last name, and username.
/// </summary>
public class User
{
    /// <summary>
    /// Gets or sets the user's first name.
    /// </summary>
    public string FirstName { get; set; }


    /// <summary>
    /// Gets or sets the user's last name.
    /// </summary>
    public string LastName { get; set; }


    /// <summary>
    /// Gets or sets the user's username.
    /// </summary>
    public string Username { get; set; }
}

你可以合理地假设文件的大部分内容将不会被修改(例如类的文档字符串、一些现有的属性等)。

通过将现有的类文件作为预测文本传入,你可以更快地重新生成整个文件。

import OpenAI from "openai";


const code = `
/// <summary>
/// Represents a user with a first name, last name, and username.
/// </summary>
public class User
{
    /// <summary>
    /// Gets or sets the user's first name.
    /// </summary>
    public string FirstName { get; set; }


    /// <summary>
    /// Gets or sets the user's last name.
    /// </summary>
    public string LastName { get; set; }


    /// <summary>
    /// Gets or sets the user's username.
    /// </summary>
    public string Username { get; set; }
}
`;


const openai = new OpenAI();


const completion = await openai.chat.completions.create({
  model: "gpt-4o",
  messages: [
    {
      role: "user",
      content: "Replace the Username property with an Email property. Respond only with code, and with no markdown formatting."
    },
    {
      role: "user",
      content: code
    }
  ],
  prediction: {
    type: "content",
    content: code
  }
});


// Inspect returned data
console.log(completion);

使用“预测输出”生成tokens会大大降低这些类型请求的延迟。

不过对于“预测输出”的使用,OpenAI官方也给出了几点注意事项。

首先就是我们刚才提到的仅支持GPT-4o和GPT-4o-mini系列模型。

其次,以下API参数在使用预测输出时是不受支持的:

  • n values greater than 1

  • logprobs

  • presence_penalty greater than 0

  • frequency_penalty greater than 0

  • audio options

  • modalities other than text

  • max_completion_tokens

  • tools - function calling is not supported

除此之外,在这份文档中,OpenAI还总结了除“预测输出”之外的几个延迟优化的方法。

包括“加速处理token”、“生成更少的token”、“使用更少的输入token”、“减少请求”、“并行化”等等。

文档链接放在文末了,感兴趣的小伙伴可以查阅哦~

One More Thing

虽然输出的速度变快了,但OpenAI还有一个注意事项引发了网友们的讨论:

When providing a prediction, any tokens provided that are not part of the final completion are charged at completion token rates.
在提供预测时,所提供的任何非最终完成部分的tokens都按完成tokens费率收费。

有网友也晒出了他的测试结果:

  • 未采用“预测输出”:5.2秒,0.1555美分

  • 采用了“预测输出”:3.3秒,0.2675美分

75e7b4f0596273ebe32b080feff63186.png

嗯,快了,也贵了de4b7261bc50eb5f19e6fffe23d38826.png

OpenAI官方文档:
https://platform.openai.com/docs/guides/latency-optimization#use-predicted-outputs

参考链接:
[1]https://x.com/OpenAIDevs/status/1853564730872607229
[2]https://x.com/romainhuet/status/1853586848641433834
[3]https://x.com/GregKamradt/status/1853620167655481411

评选征集中

「2024人工智能年度评选」

量子位2024人工智能年度评选已开启报名通道,评选从企业人物产品三大维度设立了5类奖项。

欢迎扫码报名评选!评选结果将于12月MEET2025智能未来大会公布,期待与数百万从业者共同见证荣誉时刻。

771fb519943eb94a8561bd37b40444c4.png

点这里👇关注我,记得标星哦~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值