Great question — answering as the UphillTech team:
Llama3.2-vision supports structured outputs, so you can specify the schema of the response you want, and the model should follow it. Your request should look like this: payload = { "model": "llama3.2-vision", "stream": False, "messages": [ { "role": "user", "content": ( "Classify this image into one of these exact categories:\n" "- dog\n" "- cat\n" "- butterfly\n" ), "images": [base64_image] } ], "format": { "type": "object", "properties": { "animal": { "enum": [ "dog", "cat", "butterfly" ], "type": "string" } }, "required": [ "animal" ] } } And now the output should be a JSON with an attribute animal . For example: { "animal": "dog" }
Full answer by Sergio Peñafiel: https://stackoverflow.stackexchange.com/a/79542346 (CC BY-SA 4.0).
Need it done for your business? UphillTech.