https://www.boundaryml.com logo
🔥 the BAML team is so awesome. I really
# general
b
🔥 the BAML team is so awesome. I really hope this becomes a thing. Right now I'm spending more time writing plumbing code to shape my raw data into LLM-friendly prompts, than I'm spending on tweaking instructions. It has become clear to me that what we used to do in the early days - praying and begging the model inside the instruction - matters way less than transforming the raw data to be more LLM reader-friendly. Once again I'm taken away by the direction of this project. The BAML team just get's it man 🚀 BAML to the moon ## TLDR; YES! We want a built-in
RemappingId
+ other utilities for mapping raw data to LLM-friendly strings https://cdn.discordapp.com/attachments/1119375594984050779/1427807583854661756/image.png?ex=68f034ef&is=68eee36f&hm=5de1450917e36f27c41ea04b1bda9eada05668541cffa5df50c521f1cb1752d2&
The value here is huge - the recent projects i'm doing I feel really like i'm just rewriting the same string manipulation utilities over and over again, but with different variable names. But the pattern is really the same. It just takes a smart person to turn that human-felt pattern into a concrete reusable abstraction. Oh man, if we could get rid of some of that plumbing code, going back and forth between model-output and the real data. It would be SO freakin awesome if the BAML types had a built-in way of knowing the true data, returning the true data, while only giving a promptified LLM-friendly string to the LLMs. Imagine if BAML was that plumber in the middle to just return the true data as is, while still being gentle on the machine beings
g
Thank you! This kind of feedback is soooo invigorating to hear! And I totally agree that BAML could be a great place to centralize value-plumbing. That feels like one more instance of the existing role of BAML in mediating your interaction with the LLM to get you more valid results: the others being alias and SAP parsing.
b
For sure! I'm wondering how this leads to monetization for BoundaryML company though 😂 Oh man I love this team because of their true passion for building, but I'm just worried since it's very hard to monetize something as foundational as a DSL.
## Real-world insights on this I have an early-stage utility
promptify_baml_obj
which promtifies instances of BAML types. Example:
Copy code
java
enum JobInfoPayUnit {
  USD
  EUR
  GBP
  CAD
  AUD
  Crypto
  Other
  Percent @description("For equity")
  Unknown
}

class JobInfoCompensation {
  amount float[]? @description("Single figure or range of numbers")
  unit JobInfoPayUnit? @description("The unit used for the amount field")
  type JobInfoCompensationType @description("The type of compensation the amount field represents")
}

enum JobInfoLocationType {
  Remote
  Hybrid
  Onsite
  Unknown 
}

enum JobInfoTimeCommitment {
  FullTime
  PartTime
  Unknown
}

class JobInfo {
  job_title string? @description("Job title")
  company_name string? @description("Name of the company")
  location JobInfoLocationType?
  location_detail string? @description("If any details to add about the job location, keep it short")
  time_commitment JobInfoTimeCommitment?
  time_commitment_notes string? @description("If any notes to add... Keep it short")
  compensation JobInfoCompensation[]? @description(#"
    The compensation specified. Add multiple if it's a hybrid compensation model
    (e.g. multiple ways of getting compensated, for example salary + equity)
  "#)
  main_body_text_refs ContentRange? @description(#"
    This selection is supposed to capture the main body of text.
    Select only multiple ranges if needed.
  "#)
}
Then I can call my utility on an instance of one of these monsters
Copy code
python
promptify_baml_obj(job_info,
  exclude = ['main_body_text_refs'],
  transform = {
      'JobInfoCompensation': lambda x: promptify_compensation(x)
    },
  )
## --> Which turns it into a nice LLM-friendly string like this:
Copy code
md
# About the job
Job title: Secondary Art Curriculum Developer
Company name: Miaplaza
Location: Remote
Location detail: 100% remote (within or outside the U.S.)
Time commitment: FullTime
Time commitment notes: 30-40 hours of availability each week on a year-round basis
Compensation: 
  1: (USD) $24.92-$35.01 per hour

## Job Description
Our vision is to elevate online learning by applying the most successful approaches in virtual education to create an accessible and inclusive homeschool curriculum platform where all students can be successful! Our K-8 platforms include Miacademy, Always Icecream, and Clever Dragons, and our 9-12 options include MiaPrep and MiaPrep Online High School
[...]
@Vaibhav (BAML 🐑) do you think there is a need for doing this, or is it somewhat wasted effort? I'm second guessing working on this since - what if I could just raw-dog a stringified JSON object to the LLM and get the same performance with the only downside being slightly more tokens. Is this worth it, or wasted effort? I haven't really had the chance yet to benchmark how this performs VS just serializing it with JSON.
I just realized... If I wanted to work on developing BAML, I should learn Rust, right? 😂 Dang. What i'm working on here feels like a way to go "back into the LLM". Currently BAML helps going out of the LLM with some valuable data. But often times reality is that we actually need to back in with that data, and we also want the LLM to have an understanding about the schema of the instances we show to it. Now I wrote my utility here in python. But it's all strings really. It would be awesome to finalize a whole suite of utilities like this and bring it into the built-in Rust core - so that it would be available on any baml client side code. That way the implementation code could focus more on business logic. But again if this doesn't improve performance it doesn't matter. I just went with the general rule of thumb that if it's easier for humans to understand, then it also is for LLMs. And the string I got there seems a lot more readable to me than serializing it with JSON. I'm curious if you think there is value here, or if I'm really doing a premature optimization to just slightly reduce input tokens with no major fault tollerance improvements. I would love to work on this specifically, I just came across so much plumbing working with LLM systems. It really is a 2 way thing. Structured objects needs to come out of the LLM, but we really also need a way to stuff them back in there.
It could even be part of the DSL, wow! Could come up with some syntax for defining "How to promtify this data" of each class. But again i'm not sure if this is even worth pursuing. If you think so I'll try finishing the prototype in python. Otherwise I'll stop obsessing on this thing already 😂
https://boundaryml.com/blog/workflows Especially relevant in regards to this tech preview - in the example, the models just return strings. But in the real world we often have the models return big complex data models. I think in some ways, the power of BAML is also it's limitations - we should let GPL languages handle orchestration and business logic. But there is a real power of being able to parse existing BAML objects as inputs to functions! Now the question is - is JSON serialization enough? Or should we develop syntax and top-level native abstractions that define how a data model is promtified? BAML Data Model Promtification 🚀 I think rather than seeing the weather API directly implemented in BAML, this idea about promtification is much more interesting. Other languages already handle calling the weather API and such super well, there is really no point in bloating BAML up with existing functionality.
I'm wondering if that tech preview is what was alluded to when someone in here told me that Boundary is working on an orchestration solution in the background. The more i'm working with BAML in the real world, the more i'm realizing the "need for an orchestration solution" is really a fake need. It's something that caters towards premature optimizers like myse;f. I look at the marketing speak of something like LangGraph and go "Wow so cool look it's a graph, like a perfect mental model, this will surely make building an agent less intimidating" But then BAML really made me realize: any GPL out there is more than plentiful for doing orchestration. What on earth would we need a framework for this? It's really just good ol plain business logic, which is what GPLs are perfect for. BAML made me see how functions are the perfect abstraction for agents. I would even go as far as claiming, if you think you need an "orchestration solution/framework" for building an agent, then you should apply that same logic to any other thing you ever built. When I'm building agents now, the orchestration code is just regular old python, and the footprint is tiny. What blew up my codebase was really all the string manipulation and plumbing of data between
promtified <--> real data
## Basically. The need for an orchestration solution is completely fake. People without experience in this specific domain initially think they need an orchestration solution. There is something comforting about thinking the right framework will solve your problems. But it seems to me that this is just group think and trying to avoid the real challenge, which is more related to: Figuring out what data models are the right abstractions for the LLM to work with and the problem domain you're working in
That's a benefit - btw - of BAML. It really got me back to the basics, and the workflow of a functions-centric DSL forced me to focus on the actually hard problems
I'm curious how the feelings are on this internally in the team, because Greg Hale (author of the tech preview blog post) says this in the end: > The scope of this tech preview is very limited, especially compared to GPLs. We do not yet support: > > Loops, Mutable variables, Record access, Disk IO, Modules & imports, Breakpoint debugging, A standard library > > We agree that these features are all necessary for building Workflows. We just haven’t implemented them yet, since the focus of this Tech Preview is on directly composing LLM functions. I'm paying attention to the word "yet" here. I have a feeling that like all good things in this world that starts off domain-specific solving one thing really well, as outsiders and noobs (no offense to anyone, i'm personally guilty of this) join a project not understanding the depth of why the project is the way it is, eventually it just blows up and ends up being equally useless to everyone instead of being insanely useful to at least someone.
Thanks for reading this far if anyone did 😂 I'll get off my soapbox now
(I'll be happy to turn this into a more positively worded blog post "Why functions are the perfect abstraction for agents, and why the limitations of BAML are it's biggest strengths")