Function calling with latex

Hi there,

Has anyone tried function calling but when the arguments of the function call contain complex string (e.g. one containing latex)? The problem I’m having is that sometimes, GPT-4 doesn’t escape special characters in latex correctly, which makes the JSON string it returns (via function call) not parsable. I understand that due to the statistical nature, GPT will generate incorrect latex sometimes, but I’m wondering if anyone has had reasonable success in bringing down the error rate.

Thanks!

One suggestion that repeatedly pops up when looking for solutions to any kind of JSON specific issues is using XML.

Assuming you have a single line to communicate the extra effort could be minimal and you can control the data processing into JSON in your backend before passing on the message. Actually, in this case you don’t need any specific structured data format at all, as long as it properly separates the LaTex string from the rest of the message.

Otherwise I suppose you tried giving examples in the prompt, sending the first response with the JSON to a second agent for validation, using a fine-tuned model, or you could share your prompt and then we can have a look.

Hope this helps!