#structured output and finetunned models
1 messages · Page 1 of 1 (latest)
Hi @fossil hare. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Yes, you can use structured outputs with a fine-tuned gpt-4o-mini model. The gpt-4o-mini model supports structured outputs, which can be utilized in two forms: function calling and json_schema response format. This capability is available for gpt-4o-mini and its snapshots, such as gpt-4o-mini-2024-07-18.
For more information on structured outputs, you can refer to the Structured Outputs guide.
If you are interested in fine-tuning, you can follow the process outlined in the fine-tuning guide.
If you need to implement structured outputs in your application, you can use the following example code for structured data extraction:
from pydantic import BaseModel
from openai import OpenAI
client = OpenAI()
class Step(BaseModel):
explanation: str
output: str
class MathReasoning(BaseModel):
steps: list[Step]
final_answer: str
completion = client.beta.chat.completions.parse(
model="gpt-4o-2024-08-06",
messages=[
{"role": "system", "content": "You are a helpful math tutor. Guide the user through the solution step by step."},
{"role": "user", "content": "how can I solve 8x + 7 = -23"}
],
response_format=MathReasoning,
)
math_reasoning = completion.choices[0].message.parsed