OpenAI has introduced a new feature in the ChatCompletion API that allows users to specify the format of the returned values according to a predefined JSON Schema. This mandatory command ensures that responses align with the specified JSON Schema, applicable to all Chat Completion models. However, models tested by OpenAI that achieve a perfect 100% match are exemplified by gpt-4o-2024-08-06, freshly released today.
In cases where a model cannot adhere to the specified JSON Schema, it will not return values as usual. Instead, it will populate the ‘refusal’ field with a message, allowing users to easily verify if the received data meets their requirements.
The process enabling GPT-4o to consistently adhere to the JSON Schema involves two steps. Firstly, additional model training, which has shown improvement but still has limitations, with a 93% accuracy in schema-specific responses. Subsequently, a new decoder is implemented, selecting tokens that align specifically with the JSON Schema requirements.
The JSON Schema utilized is a subset of standard practices, supporting up to 100 properties and the creation of objects up to 5 layers deep. Furthermore, the gpt-4o-2024-08-06 model has reduced input token costs by 50%, now priced at $2.5 per million tokens, and output token costs decreased by 33% to $10 per million tokens.
TLDR: OpenAI has upgraded ChatCompletion API to enable customization of returned values in alignment with a specified JSON Schema, with the latest model gpt-4o-2024-08-06 showcasing a perfect match and improved token costs.
Leave a Comment