How We Easily Extract Information from AI
When we first started using AI to build internal business applications at Contember, we quickly faced a tricky problem: How do we easily extract clear, useful information from the AI’s output?
Initially, we tried JSON because it’s a common format. But generating JSON with AI was slow and complicated. It required strict rules with lots of brackets, quotes, and commas. Any small mistake would break the entire output.
{
entities: [
{
name: "Author",
columns: [
{
name: "name",
type: "string"
},
{
name: "website",
type: "string",
required: true
}
]
}
]
}
When AI forgot a comma, it broke the entire output. We tried asking AI to fix its own mistakes by showing the incorrect JSON and previous context, hoping for a corrected version. But this was only successful about half the time.
{
entities: [
{
name: "Author",
columns: [
{
- name: "name"
+ name: "name",
type: "string"
},
{
name: "website",
type: "string",
required: true
}
]
}
]
}
Next, we switched to YAML. YAML was quicker and simpler, but still required a specific structure. Even with better instructions, we couldn't reliably achieve more than 70% accuracy. Any small mistake still meant regenerating the entire output.
entities:
- name: Author
columns:
- name: name
type: string
- name: website
type: string
required: true
YAML was easier to generate, but missing just one line broke everything, forcing us to ask the AI for fixes again.
entities:
- name: Author
columns:
- name: name
- type: string
- name: website
type: string
required: true
Finally, we created our own simple format inspired by SQL. It was easy for AI to generate and easy for us to read and process. If the AI made a mistake, we could easily skip that one line and continue without issues.
Here's our custom format:
create entity Author;
add column Author.name string;
add column Author.website string required;
default column Article.createdAt now;
If AI made a mistake, like missing a column name, everything else was still okay, and the fix was quick—just append a new correct line.
create entity Author;
- add column Author.name string;
add column Author.website string required;
default column Article.createdAt now;
add column Author.email string;
This simple solution dramatically improved our success rate, bringing it close to 100%.
I hope this inspires you to simplify your AI workflows too!
- ← Previous
Making Shadcn UI Components Simple with UIC