跳到正文
Together AI Blog·· 1 天前精选AI 评分60

腾讯 Hy4 上线 Together AI,支持图像输入与 1M 上下文

Tencent Hy4 is live on Together AI

AI 导读

腾讯旗舰模型 Hy4 已在 Together AI 上线,可通过 serverless 和专用端点调用,模型字符串为 tencent/Hy4,是 Hy 系列首个支持图像与文本输入、返回文本的模型。

推荐理由

原文用图表解析和单提示词写游戏两个实测,展示 Hy4 的视觉输入与代码生成表现,并给出可直接运行的调用代码。

正文 · AI 翻译

从今天起,你可以通过无服务器和专用端点,在 Together AI 上运行腾讯 Hy4。Hy4 是腾讯的旗舰模型,也是 Hy 系列中首个支持图像与文本输入的模型。

我们给它布置了两个小任务,看看它在实践中表现如何:从我们的一张图表中提取数据,并用 HTML 重建该图表;然后根据单条提示词编写一个浏览器游戏。以下是返回的结果,以及让你自己发起图表请求的代码。

它读取了我们的图表,然后重建了它

我们从视觉能力入手,因为这是 Hy4 新增的能力。我们从 Together Storage Accelerator 文章中取来这张图表,把它的截图交给 Hy4,并要求以 JSON 返回其内容。

The chart we gave Tencent Hy4: a bar chart from the Together Storage Accelerator post with three bars, labeled TSA warm read at 3.18 GB/s, R2 origin, direct at 0.16 GB/s, and TSA cold read at 0.14 GB/s.

响应返回了标题和全部三个数值,与图表中显示的完全一致:

{
  "title": "A warm TSA read is 3.2 GB/s: 20x the R2 origin",
  "bars": [
    {
      "label": "TSA warm read",
      "value": 3.18
    },
    {
      "label": "R2 origin, direct",
      "value": 0.16
    },
    {
      "label": "TSA cold read",
      "value": 0.14
    }
  ]
}

接下来,我们要求它使用同一张截图,将图表复现为一个单独的 HTML 文件。这一次,输出不仅需要保留数字,还需要保留视觉布局。上方是原始版本,下方是 Hy4 的版本。

Two versions of the same bar chart, stacked. The top one is the original from the Together Storage Accelerator post. The bottom one is the version Tencent Hy4 rebuilt from a screenshot, with the same layout, labels, values and colors.

Hy4 复现了布局、标签、数值、颜色、虚线天花板线和脚注。我们要求它使用通用字体,因此字体有所不同。

它编写了一个游戏

在第二个测试中,我们给 Hy4 的是一条文本提示词而非图像,要求它在一个 HTML 文件中编写一个浏览器游戏,不使用任何库或外部资源:

在一个 HTML 文件中制作一个小巧、原创的浏览器游戏,不使用任何库,也不使用外部资源。键盘控制、分数、失败方式和重新开始。它应该能让人开心地玩两分钟。只回复 HTML。

Hy4 返回了一个名为 Polarity 的游戏。我们将响应保存为 HTML 文件,并在未修改代码的情况下在浏览器中打开。

方块从屏幕顶部落下。你接住与自己颜色匹配的方块,按空格键切换颜色。黄色危险物如果碰到你,游戏就会结束。Hy4 还添加了一个解释规则的标题屏幕,以及一个可跨轮次保留的最高分,这两者我们都没有要求。

Three screens from Polarity, the browser game Tencent Hy4 wrote: the title screen with its three rules, a round in play with falling blocks, and the game-over screen showing a new record.

我们玩了一轮,到达游戏结束屏幕,并成功重新开始。

在 Together AI 上运行它

Hy4 现已可用,模型字符串为 tencent/Hy4,通过 Together 的聊天补全 API 调用。下面的示例是本文前面的图表请求。要运行它,请安装 Together Python SDK(pip install together),设置 TOGETHER_API_KEY,并将我们使用的图表保存为 chart.png。

import base64

from together import Together

client = Together()

with open("chart.png", "rb") as f:
    image = base64.b64encode(f.read()).decode()

response = client.chat.completions.create(
    model="tencent/Hy4",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "Read this chart. Return a JSON object with a title "
                    "and a list of bars, each with a label and a value.",
                },
                {
                    "type": "image_url",
                    "image_url": {"url": f"data:image/png;base64,{image}"},
                },
            ],
        }
    ],
    response_format={"type": "json_object"},
)

print(response.choices[0].message.content)

如果你想在编写任何代码之前试用 Hy4,可以在游乐场中打开它,模型页面有完整详情。关于更广泛的发布,包括 Hy4 新的计算机使用能力,请参阅腾讯的公告。

常见问题

腾讯 Hy4 在 Together AI 上的价格是多少?

腾讯 Hy4 在 Together AI 上的价格为每 100 万输入 token 0.83 美元,每 100 万输出 token 2.50 美元,每 100 万缓存输入 token 0.042 美元。

腾讯 Hy4 在 Together AI 上的上下文窗口是多少?

腾讯 Hy4 在 Together AI 上具有 100 万 token 的上下文窗口,使用模型字符串 tencent/Hy4 调用。

腾讯 Hy4 接受图像吗?

是的,腾讯 Hy4 在 Together AI 上接受文本和图像输入并返回文本,它是腾讯 Hy 系列中首个具备视觉能力的模型。你将每张图像作为消息内容中的 image_url 块发送,如上面的示例所示。

腾讯 Hy4 支持 JSON 输出和工具调用吗?

是的,腾讯 Hy4 在 Together AI 上两者都支持。将 response_format 设置为 {"type": "json_object"} 即可获得 JSON 输出,通过在标准 tools 参数中传入函数即可启用工具调用。

我可以在专用端点(dedicated endpoint)上运行 Tencent Hy4 吗?

可以,Tencent Hy4 已在 Together AI 上提供,既支持无服务器(serverless)基础设施,也支持专用基础设施,因此你可以先从无服务器开始,在需要预留容量时再迁移到专用端点。

来源:Together AI Blog · together.ai