rw-book-cover

Metadata

Highlights

  • . OpenAI have offered structured outputs for a while now: you could specify "response_format": {"type": "json_object"}} to request a valid JSON object, or you could use the function calling mechanism to request responses that match a specific schema. (View Highlight)
  • Neither of these modes were guaranteed to return valid JSON! In my experience they usually did, but there was always a chance that something could go wrong and the returned code could not match the schema, or even not be valid JSON at all. (View Highlight)
  • Outside of OpenAI techniques like jsonformer and llama.cpp grammars could provide those guarantees against open weights models, by interacting directly with the next-token logic to ensure that only tokens that matched the required schema were selected. (View Highlight)
  • OpenAI credit that work in this announcement, so they’re presumably using the same trick. They’ve provided two new ways to guarantee valid outputs. The first a new "strict": true option for function definitions. The second is a new feature: a "type": "json_schema" option for the "response_format" field which lets you then pass a JSON schema (and another "strict": true flag) to specify your required output. (View Highlight)
  • I’ve been using the existing "tools" mechanism for exactly this already in my datasette-extract plugin - defining a function that I have no intention of executing just to get structured data out of the API in the shape that I want. (View Highlight)
  • The official openai-python library also added structured output support this morning, based on Pydantic and looking very similar to the Instructor library (also credited as providing inspiration in their announcement). (View Highlight)
  • By switching to the new gpt-4o-2024-08-06, developers save 50% on inputs (10.00/1M output tokens) compared to gpt-4o-2024-05-13. (View Highlight)
  • This is particularly notable because GPT-4o-mini, the much cheaper alternative to GPT-4o, prices image inputs at the same price as GPT-4o. This new model appears to cut that by half, making gpt-4o-2024-08-06 the new cheapest model from OpenAI for handling image inputs. (View Highlight)