Inspiration

The project originated in the dificulty to obtain a substancial amount of reasonable realistic data for testing in a DB heavy system. The data required to test how will a UI will respond to a large list of data in a table or the amount of data needed to run a stress test on the backend required large amounts of production data anonimized or a lot of imagination and hours of work. This system creates data from prompts and distributions stored in a DB.

What it does

The system takes skills, tools, a distribution stored in a database to generate synthetic data to fill several tables in a relational database respecting foreign keys constraints, business constraints, and a given distribution for given columns in selected tables. The agent is instructed to analyze the DB structure first then follow instructions splitted in prompts and skills to generate the data using different tools. Then is asked to insert and validate the data.

How we built it

The system is written in Java 21 using google SDK and ADK. The target database is a Neon PostgreSQL to simulate an on-premise testing DB. The app was deployed via Google's Cloud Run service. It's two endpoints are protected by IAM. One endpoint is pure Java and it resets the experiment: truncates the tables and reset the sequences. The other endpoint invokes the agent and seeds the data. It takes a payload that tells the agent how many rows in each table it needs to insert, and it uses an existing table with distributions for column values.

Challenges we ran into

One of the biggest challenge was getting the agent to respect categorical values (as opposed to inventing them) and distributions. That was accomplished by a combination of skills, prompts, and system messages. Natural looking distribution of categories and foreign keys is still pending.

Accomplishments that we're proud of

Being this my first agent, the thing I am most proud of is that it works. It does insert the data, a few restrictions placed on columns are respected, foreign key restrictions are respected, distributions are respected, realistic names and descriptions are respected. In the final message, the agent summarizes what it did and reviews how well it matched the conditions I set.

What we learned

One thing I learned was that I needed to build several stages for the agent to work through the entire request. Except some very small tables, with few conditions, and few values to generate could go together in the same prompt. Tables with several business conditions, severall foreign keys, and more rows requested needed to be in their own prompt. Also, I leant that I needed to limit the number of rows total I could ask in a single prompt, which was resolved by an upper limit and a recurrent call to the same prompt handled by Java in a deterministic loop.

What's next for Synthetic Data

From the agent perspective, the most important think I want to fix is the inhability of creating the rows with random order of foreign keys and categorical columns. Any combination of prompts, system messages and skills was unsuccessful. The plan is offer the agent a few more tools were, possible Java, will recover the values and shuffle them, so the agent can call on those tools when needed.

Built With

Share this project:

Updates