Menu

1 / 2

"Return JSON only" doesn't force JSON. Here's what actually forces it.

DEV Community·Natnael Alemseged·6 months ago
#uvncYvmk
#llm#ai#python#json#output
Reading 0:00
15s threshold

You have a judge LLM in your pipeline. You've told it:

"Return JSON only. No preamble, no explanation. Just the JSON object."

It works great in testing. It works great in staging. Then in production it returns:

Sure! Here's my evaluation of the response:

{ "score" : 4 , "reason" : "The answer is mostly correct but..." }

Enter fullscreen mode

Exit fullscreen mode

Your json.loads() throws. Your pipeline catches nothing. Downstream code receives None and keeps running. Your evaluation scores are silently wrong for the next 200 requests before anyone notices.

Was this the model misbehaving? No. Was there ever a way to actually force JSON output? Yes — but it's not the prompt.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.