https://www.boundaryml.com logo
🟑 Automatically label JSON output with BAML class
# questions
r
How can I automatically label my JSON output with the BAML class? I want a type field or class field so I can handle the record accordingly.
v
can you explain what you mean?
r
Copy code
class Company {
  name string
  type string
}
Copy code
{
  "name": "Graphlet AI",
  "type": "Company"
}
Except I don't want to set the value to
Company
, I want to use the settinf for that.
v
oh, sadly we don't expose branded interfaces yet!
that is something we are going to look into when we do branded unions
which will automatically inject some attribute to descrimate types
r
Ok thx
@Vaibhav (BAML πŸ‘) can you provide a recommendation for how to prompt the LLM to assign each and every object a unique
id integer
field? Sometimes they are unique for the entire output, sometimes by type of record. It isn't consistent.
Also, how low can you turn temperature down on Gemini before it kills performance?
v
honestly i find temp 0 generally works best
unique id per object is gonna be hard, its just gonna be trial and error by providing a better and better description
e
For unique IDs I typically add those via post processing as getting an LLM to generate stuff like that is not the most trivial
r
I got unique integer ids today! You just have to ask nicely. Saves you most of your output tokens since Gemini will happily use ids rather than a million repeats of records. That about BAML I don’t get. You hoist schemas but not data? Anyway, you can.
The problem is not having IDs makes everything downstream much harder. Like ETL, entity resolution or anything where you reference records.
I use a PySpark UDF to swap in UUIDs
You really want function calling for this
I did have to play with the prompt and integer id field descriptions a bit to make it reliable.
It increments by big amounts for each entity type - isn’t that cool? Without being asked.
But from papers I read, temp 0 reduces quality significantly. That’s not true?
v
interesting, i read differently!
if you have some papers to point me to woudl love to read them