https://www.boundaryml.com logo
meta extraction
# general
u
Hey BAMl community, I’m exploring whether BAML currently supports (or plans to support) meta‑level extraction, essentially letting BAML create the schema that BAML will later use for extraction. What I mean by “meta‑level extraction” Instead of pre‑defining the TypeBuilder classes myself, I’d like to: Ask BAML to infer a schema from a document + user prompt (e.g., “This document describes assets (vehicles) with some fields like manufacturing year, price, etc; infer the fields and types needed.”) Use that inferred schema as the TypeBuilder schema for a second extraction step. In other words: Can BAML generate its own TypeBuilder schema dynamically, based on the content, and then use that schema to extract structured values? Example Say a document contains two vehicles, each with a price and manufacturing year. I don’t want to hardcode:
Copy code
baml
class Vehicle {
    price float @description("Vehicle Price")
    year int @description("Vehicle manufacturing Year")
}

class Assets {
  assets Vehicle[] @description("List of Vehicles")
}
Instead, I want BAML to: First infer a meta‑schema describing what fields exist Then use that meta‑schema to extract the actual values This could be done in two steps (schema → extraction), or potentially in a single shot if BAML can output a finalized TypeBuilder schema directly. The core question Is there a recommended or built‑in way to let BAML generate its own extraction schema at runtime? Or is this something that needs to be orchestrated manually outside of BAML? Would love to hear how others approach this, or whether this aligns with any upcoming features. Thanks!
b
One of our product demos actually does this! I think this is it: https://github.com/BoundaryML/baml-examples/tree/hellovai/extract-anything/extract-anything
We’ve talked about this a fair bit, but nothing that we’re launching in the next few weeks
u
Thanks, looks like what I needed!
@baml-sam I was wondering about architectural decisions why in this example extract-anything you went with LLM on first step generating BAML and not JSON? The reason why I ask is that in my very preliminary tests gpt-5 mini has issues with generating correct BAML. That leads me to conclude that JSON is much more popular and present in LLM dataset while BAML is not much so. So why not using JSON, was it for some architectural reasons?
b
Things like @description, @alias etc are not straightforward to model with just JSON schema
We were also pushing the limits of what models can do, and putting BAML in json values was much worse
If using smaller models with less recent training, I can definitely see a good argument for generating in one form then translating to another
u
I was wondering is there a build-in straightforward way to export BAML to JSON?
2 Views