https://www.boundaryml.com logo
🟡 String Processing Feature in Schema
# questions
i
Feature request (if not already exists) --- Would be good to have something like basic string processors like trim, case-change, etc which can be directly attached in schema so that when model output is processed BAML further processes those strings and return those as outputs. Something like...
Copy code
class PersonalInfo {
  first_name string? @description("Candidate's first name.") @string.trim
  last_name string? @description("Candidate's last name.") @string.to_upper_case
  full_name string @description("Candidate's full name.")
g
Interesting 🙂 We have considered something like this in the past. Can I ask, are you seeing responses from your models where the outputs don't conform to the format you want? (I mean, if you put "No whitespace" in the description, of
first_name
and "Respond in uppercase" in the description of
last_name
, does the model not do that processing for you at inference-time?
When we debated this feature several months ago, the central question was: are
@string.trim
and
@string.to_upper_case
appropriate additions to the
class
definition itself, or are they more properly part of a post-processing function that you would write? In client code, you have a lot more power to post-process the
PersonalInfo
however you like, whereas in BAML we would only be able to support a limited number of
@
functions, or let you specify the post-processing in jinja syntax, which hasn't provided a great user experience in the other attributes where we use it (checks and asserts).
i
Great to know about this. And no, the model is not considering Automtic string processing everytime unless maybe I explicitely mention that (haven't tried). But problems with that would include - add extra tokens in instruction - Inconsistencies You're right about that it's more of a part of post-processing and that's exactly what will happen here too. So for example, if I want basic transformation I can just write this in schema and it will make output more consistent every time even tho model outputs diffently. The good part about this is I don't need to write one more method to do this, and simple tag like syntax would solve this basic problems. This is nice to have, not must. So just my sugggestion...
g
Thanks for the suggestion! In a little bit, we'll have a lot more language facilities for doing similar processing within BAML.
i
That would be facinating. Thank you!