https://www.boundaryml.com logo
🟡 Schema Selection in BAML for Multiple Output Ty...
# questions
a
When hoisting multiple types in the expected output of a request. If there are multiple similar schemas in the list of output types, how does BAML select which schema to coerce the output into?
v
its a cost function. We prefer exact matches first, matches with fewer extra fields next
its a bit more nuanced cause recursive types make it hard
so hard to describe the full algorithm in a few messages. best thing to do is just try it! you can test expectactions via the modular API:
Copy code
python
res = b.parse.YourFunction("SomeString")
# res will now be the type of your function
a
Could you point me to the parts of the codebase this scoring is defined? Curious to poke around
v
engine/baml-lib/jsonish/README.md
inside our repo!