Fine tuning models to generate JSON response

hey everyone! I am trying to fine tune a model where prompt will be string and completion will be a stringified JSON. I tried creating this model but the api reponse is always a string rather than a JSON. I am expecting it to return a strigified JSON with the structure similar to what i provided in completion?
What should I do to get the prompt and completion right and which model will be best for this?
P.S: The JSON i am passing in completion can get complicated with different use case.

The model has trouble with JSON.
I’ve found more success using Markdown where possible, or if not, yaml.
Markdown with a template as prompt data, and then asking the model to fill it in, works pretty well!
I can then parse the markdown and turn it back into JSON in my API caller.

1 Like

Thanks for the response. But in my case, i have JSON object with multiple levels.

key1 : {
 key2 : {
   key3 : [jajsnasas],
   key4 : ...

Something like this. Anyways I can fine tune my model which can return this deeply nested objects as well?

In almost every case I see where a fine-tuned model was created, it wasn’t necessary. Can you share the reason you chose this approach instead of the many other pathways to generate JSON?

Sorry I dont know any of the other ways. Can you share some material where I can find it?

Okay, no. There are many pathways to AI success, but no single pathway should be suggested without at least a general idea of the objective. Share your goal and I’ll be happy to provide some ideas.