The StructuredOutputCompliance metric allows you to verify whether a given LLM output is valid JSON and adheres to an expected schema. You can optionally provide a Pydantic schema to validate the structure and types of the fields.
You can use the StructuredOutputCompliance metric as follows:
Asynchronous scoring is also supported with the ascore method.
StructuredOutputCompliance score is 1 if the output is compliant, and 0 if it is not.Opik uses an LLM as a Judge to evaluate the structural compliance. The default model used is gpt-4o, but this can be changed to any model supported by LiteLLM.
The prompt used by the LLM looks like this: