Posted in

OpenAI 的 ChatGPT 现在针对开发者查询格式化输出_AI阅读总结 — 包阅AI

包阅导读总结

1.

关键词:OpenAI、ChatGPT、Structured Outputs、开发者、JSON 格式

2.

总结:OpenAI 的 ChatGPT 推出新工具 Structured Outputs,可按开发者指定格式返回查询结果。这是开发者最需要的功能,能提高准确性,通过新参数实现,虽有一定限制,但有多种可能用途。

3.

主要内容:

– OpenAI 的 ChatGPT 服务受欢迎,被众多开发者使用

– 此前存在结果交付格式问题,开发者更希望得到结构化数据

– 新工具 Structured Outputs 发布

– 满足开发者对结果格式的需求

– 解决了之前的限制,提高了准确性

– 结构化输出的工作原理

– 通过约束采样或解码,只提供符合模式的有效信息

– 如何实现结构化输出

– 开发者提交请求时提供 JSON 模式

– 有安全要求和一些限制

– 可能的用途

– 格式化数据以便数据库分析

– 即时创建用户界面等

思维导图:

文章地址:https://thenewstack.io/openais-chatgpt-now-formats-output-to-developer-queries/

文章来源:thenewstack.io

作者:Joab Jackson

发布时间:2024/8/7 18:24

语言:英文

总字数:630字

预计阅读时间:3分钟

评分:88分

标签:OpenAI,ChatGPT,结构化输出,JSON 模式,开发者工具


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

OpenAI, the company behind the popular ChatGPT Large Language Model Generative AI service, has released a tool that will return query results in the exact format specified by users.

This has been the most-asked for request among developers using the AI technology, according to the OpenAI CEO Sam Altman.

Since its debut in November 2022, the ChatGPT service has been harnessed by countless application developers for agent-driven and other apps. But while ChatGPT uses troves of unstructured data to deliver its results (via API-driven function calling), application developers would far prefer to have these results delivered as structured data, so they can be better parsed by their respective apps.

Last year, OpenAI expanded its API to include results delivered in JSON. This week, the company goes one step farther, revealing a new API feature called Structured Outputs, which will deliver the results in whatever JSON schema the developer specifies in the query.

“Developers have long been working around the limitations of LLMs […] via open source tooling, prompting, and retrying requests repeatedly to ensure that model outputs match the formats needed to interoperate with their systems,” wrote Michelle Pokrass, OpenAI technical staff member, in a blog item posted Tuesday.

“Structured Outputs solves this problem by constraining OpenAI models to match developer-supplied schemas and by training our models to better understand complicated schemas.”

How Structured Outputs Improves LLM Quality

Structured outputs differ from those generated by plain user prompts in that they are constrained as to what information they can provide, a technique known as “constrained sampling” or “constrained decoding.”

“In order to force valid outputs, we constrain our models to only tokens that would be valid according to the supplied schema, rather than all available tokens,” Pokrass explained.

For ChatGPT, this additional step of filling in the schema improves its accuracy.

The OpenAI developers found in tests that ChgatGPT was able to fill a pre-defined schema correctly 100% of the time, but would only provide the correct responses 85% of the time through plain prompts.

OpenAI chart comparing the reliability of ChatGPT responses generated for JSON schemas versus those generated from the command prompt.

OpenAI chart comparing the reliability of ChatGPT responses generated for JSON schemas versus those generated from the command prompt.

How to Produce Structured Outputs

Now, when their apps submit a request, developers supply a JSON schema, via json_schema, which is a new option for the response_format parameter. The strict value must be set as “true” within the function definition. The model’s output would then best match its answers to the schema (this works both for AI tools and for direct user inquiries).

The responses will still abide by OpenAI’s safety requirements — which blocks potentially harmful content — and will return a refusal string value to questions it won’t answer. And there are other limitations as well: It supports only a subset of the JSON schema. It won’t prevent mistakes in model definition, and there is an additional latency in the first response, as the ChatGPT sorts out the developer’s schema.

Both the Node.js and Python software development kits from OpenAI have been updated with the new response_format parameter.

The biggest possible use case is, of course, formatting unstructured data into structured data, so it can be ingested and analyzed by a relational database system. which has long been a challenge for organizations with lots of information stashed away in office documents.

But Pokrass elaborates on some possible advanced uses of the technology, including creating user interfaces on the fly based on user input and providing a single answer without the supporting material.

This is a “great feature and much needed,” machine learning researcher Elvis Saravia noted on X. Saravia worked up a tutorial for YouTube on how to use Structured Outputs:

VIDEO

YOUTUBE.COM/THENEWSTACK

Tech moves fast, don’t miss an episode. Subscribe to our YouTubechannel to stream all our podcasts, interviews, demos, and more.

GroupCreated with Sketch.