Langchain is one of the most popular frameworks for building LLM applications. It provides abstractions for chains, agents, memory, and more.
Let’s dive into how Langchain handles structured extraction and where it falls short.
Langchain makes structured extraction look simple at first:
That’s pretty neat! But now let’s add an Education model to make it more realistic:
Still works… but what’s actually happening under the hood? What prompt is being sent? How many tokens are we using?
Let’s dig deeper. Say you want to see what’s actually being sent to the model:
But even with debug mode, you still can’t easily:
Here’s where it gets tricky. Your PM asks: “Can we classify these resumes by seniority level?”
But now you realize you need to give the LLM context about what each level means:
Your clean code is starting to look messy. But wait, there’s more!
Your company wants to use Claude for some tasks (better reasoning) and GPT-4-mini for others (cost savings). With Langchain:
Now you want to test your extraction logic without burning through API credits:
With BAML, testing is visual and instant:
Test your prompts instantly without API calls or mocking
Your CFO asks: “Why is our OpenAI bill so high?” You investigate:
But you still don’t know WHY it’s using so many tokens. Is it the schema format? The prompt template? The retry logic?
BAML was built specifically for these LLM challenges. Here’s the same resume extraction:
Now look what you get:
client GPT4 to client ClaudeUse it in Python:
Langchain is great for building complex LLM applications with chains, agents, and memory. But for structured extraction, you’re fighting against abstractions that hide important details.
BAML gives you what Langchain can’t:
Why this matters for production:
We built BAML because we were tired of wrestling with framework abstractions when all we wanted was reliable structured extraction with full developer control.
BAML does have some limitations we are continuously working on:
If you need complex chains and agents, use Langchain. If you want the best structured extraction experience with full control, try BAML.