https://www.boundaryml.com logo
🟡 Can BAML handle multiple query output in LLM?
# questions
a
Hi, we have a use cases where we need to thru in a list of ~20 queries into same LLM call at a time, and require the LLM to output a list of binary classification label. We are able to get it to output the specific format using output schema, but we cannot get it to consistently output a list of N Labels to match the N queries. I haven't tried BAML yet, I am using LangGraph+dspy, which has no mechanism to reinforce the output schema field length to match the length of input list. Then I did some googling and come across BAML. Just wondering would BAML be able to solve my problem? ps. Gemini 2.5f can consistently match the length, but Gemini 2.5 Flash lite cannot. But due to the latency requirement of the app, we had to use the flash lite model.
i
Seems like LLM responses are getting lost. Not sure if this is the BAML related problem but I recommend you try it out. Doesn't take more than 5 mins to setup. It does parse consistantly all the time. Be aware of max_tokens tho, otherwise not even BAML can save.
a
Thanks Akash, how do I specify the schema in BAML so that it matches the length of labels to length of input? Can you show me an example of schema definition with list length so I can quickly set it up.
i
I don't have examples right now, But you can use assert to checkout if the response list matches the required numbers. BAML is a great parse but it doesn't guarantee the output of LLM. If the LLM is returning 8 items and you're required 10. BAML will just parse 10.
a
sorry did you mean BAML will parse 8 (instead of 10)?
Also just trying to understand a little bit more about how the BAML parsing gurantee the structure output as it's said in the youtube video. Just some research (chatting with chatgpt mostly), it seems that BAML is doing it's parsing on the final output provided from LLM, it doesn't involve in the decoding phase which makes sense as we cannot intervenue the decoding phase of non-open weight LLM. Then I don't know how it can gurantee the structure output if the LLM fails to provide the information required like you said? Does it just raise an error if LLM doesn't provide the required info?
by youtube video I mean the
ai that works
series run by
vaibhav
i
I am confused about the question at this point. Can you share some screenshots? Or better yet https://www.promptfiddle.com/ try out here directly and see if it's working for you.
a
oh nice, you got a sandbox, thanks for sharing, will poke around over the weekend and see if BAML helps to resolve the problem I face, thanks for your help!!
i
This is BAML’s official sandbox. Play around share your thoughts