Open piotrdelikat opened 1 month ago
Providing a JSON schema has benefits for cost optimisation, normalising the parameters naming convention and easier data processing, but models that support structured outputs by default are not performant enough to give error free results. Trying to add text input along with images next.
Example schema:
"name": "datasheetReadingResult",
"strict": true,
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"general": {
"type": "object",
"additionalProperties": false,
"properties": {
"partNumber": { "type": ["string", "null"] },
"manufacturer": { "type": ["string", "null"] },
"packageType": { "type": ["string", "null"] },
"technology": {
"type": ["string", "null"],
"enum": ["Si", "GaN", "SiC", null]
}
},
"required": ["partNumber", "manufacturer", "packageType", "technology"]
},
"electrical": {
"type": "object",
"additionalProperties": false,
"properties": {
"Vds_max": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["V", null] }
},
"required": ["value", "unit"]
},
"Rds_on": {
"type": "object",
"additionalProperties": false,
"properties": {
"min": { "type": ["number", "null"] },
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["Ω", "mΩ", null] }
},
"required": ["min", "typ", "max", "unit"]
},
"Vgs_th": {
"type": "object",
"additionalProperties": false,
"properties": {
"min": { "type": ["number", "null"] },
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["V", null] }
},
"required": ["min", "typ", "max", "unit"]
},
"Vgs_max": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["V", null] }
},
"required": ["value", "unit"]
},
"Id_max": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["A", null] }
},
"required": ["value", "unit"]
}
},
"required": ["Vds_max", "Rds_on", "Vgs_th", "Vgs_max", "Id_max"]
},
"capacitances": {
"type": "object",
"additionalProperties": false,
"properties": {
"Ciss": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["pF", null] }
},
"required": ["typ", "max", "unit"]
},
"Coss": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["pF", null] }
},
"required": ["typ", "max", "unit"]
},
"Crss": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["pF", null] }
},
"required": ["typ", "max", "unit"]
}
},
"required": ["Ciss", "Coss", "Crss"]
},
"charges": {
"type": "object",
"additionalProperties": false,
"properties": {
"Qg": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["nC", null] }
},
"required": ["typ", "max", "unit"]
},
"Qgs": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["nC", null] }
},
"required": ["typ", "unit"]
},
"Qgd": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["nC", null] }
},
"required": ["typ", "unit"]
},
"Qrr": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["nC", null] }
},
"required": ["typ", "unit"]
},
"Qoss": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["nC", null] }
},
"required": ["typ", "unit"]
}
},
"required": ["Qg", "Qgs", "Qgd", "Qrr", "Qoss"]
},
"switching": {
"type": "object",
"additionalProperties": false,
"properties": {
"td_on": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["ns", null] }
},
"required": ["typ", "unit"]
},
"tr": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["ns", null] }
},
"required": ["typ", "unit"]
},
"td_off": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["ns", null] }
},
"required": ["typ", "unit"]
},
"tf": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["ns", null] }
},
"required": ["typ", "unit"]
}
},
"required": ["td_on", "tr", "td_off", "tf"]
},
"bodyDiode": {
"type": "object",
"additionalProperties": false,
"properties": {
"Vsd": {
"type": "object",
"additionalProperties": false,
"properties": {
"min": { "type": ["number", "null"] },
"typ": { "type": ["number", "null"] },
"max": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["V", null] }
},
"required": ["typ", "max", "unit"]
},
"trr": {
"type": "object",
"additionalProperties": false,
"properties": {
"typ": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["ns", null] }
},
"required": ["typ", "unit"]
}
},
"required": ["Vsd", "trr"]
},
"thermal": {
"type": "object",
"additionalProperties": false,
"properties": {
"Rth_jc": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["°C/W", null] }
},
"required": ["value", "unit"]
},
"Rth_ja": {
"type": "object",
"additionalProperties": false,
"properties": {
"value": { "type": ["number", "null"] },
"unit": { "type": ["string", "null"], "enum": ["°C/W", null] }
},
"required": ["value", "unit"]
}
},
"required": ["Rth_jc", "Rth_ja"]
}
},
"required": [
"general",
"electrical",
"capacitances",
"charges",
"switching",
"bodyDiode",
"thermal"
]
}
}
Clearly defining the output with json schema should give more predictable results than asking to extract everything. Should unify the symbols used by different manufacturers and make it easy to parse the output. Also less output tokens = lower cost and no 'exhaustion' at the end of the file. intro to structured outputs