#How to handle json mode/structured output when fine-tuning?
1 messages · Page 1 of 1 (latest)
Hi @timber tulip. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
When fine-tuning the gpt-4o-mini model and you want the response in a structured output, you should use the Structured Outputs feature. This feature is an evolution of the JSON mode and ensures both valid JSON production and schema adherence.
To enable Structured Outputs, you need to set the response_format to {type: "json_schema", json_schema: {"strict": true, "schema": ...} }. This will ensure that the output adheres to a specific schema. You can see the supported schemas here (https://platform.openai.com/docs/guides/structured-outputs/supported-schemas).
However, please note that Structured Outputs with response_format: {type: "json_schema", ...} is only supported with the gpt-4o-mini, gpt-4o-mini-2024-07-18, and gpt-4o-2024-08-06 model snapshots and later.
If you want to use JSON mode, you can set the response_format to { type: "json_object" }. This will ensure that the output is a valid JSON, but it won't adhere to a specific schema.
Here's a comparison between Structured Outputs and JSON mode:
| Structured Outputs | JSON Mode | |
|---|---|---|
| Outputs valid JSON | Yes | Yes |
| Adheres to schema | Yes | No |
| Compatible models | gpt-4o-mini, gpt-4o-2024-08-06, and later |
gpt-3.5-turbo, gpt-4-* and gpt-4o-* models |
| Enabling | response_format: { type: "json_schema", json_schema: {"strict": true, "schema": ...} } |
response_format: { type: "json_object" } |
You can find more information about this in the OpenAI documentation (https://platform.openai.com/docs/guides/structured-outputs/structured-outputs-vs-json-mode).
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@timber tulip kapa.ai is still learning and improving, please let us know how it did by reacting below