Active Hackathon

Bonsai Brain – A low code platform to build AI agents

The Bonsai Brain is a low code AI component that is integrated with Automation systems. The Bonsai Brain focuses on adding value to various Autonomous and AI systems.
Listen to this story

Bonsai Brain is one of the ongoing projects of Microsoft, which aims to develop a low code AI-based component that is integrated with Automation systems. The Bonsai brain is simulated and trained in a manner to handle situations and to be fault tolerant even during unexpected or unseen circumstances. Bonsai’s brain focuses on adding value to various autonomous systems, processes, and equipment but also focuses on growing customer trust by ensuring continuous operations. In this article, let us try to understand the Bonsai Brain with respect to this context.

Table of Contents

  1. Introduction to Bonsai Brain
  2. Components of the Bonsai Platform
  3. Advantages of Bonsai brain
  4. Simulating a Bonsai Brain
  5. Summary

Introduction to Bonsai Brain

Bonsai Brain is an ongoing research project of Microsoft that focuses on simulating and developing a low code-based AI component that can be used for various Autonomous tasks and applications. Bonsai’s brain is simulated and trained in a manner to handle unexpected and unseen circumstances and to ensure continuous operations. Downtime is greatly reduced by using the Bonsai brain along with an increase in production efficiency.


Sign up for your weekly dose of what's up in emerging technology.

Are you looking for a complete repository of Python libraries used in data science, check out here.

Automation tasks basically involve larger neural networks to be designed, but Bonsai’s brain operates without any neural networks itself simulated or trained. The interface of the Bonsai brain lets users create their custom AI models and put them into operation accordingly without the requirement of additional resources. The below image shows the Bonsai brain platform and the operating cycle of the Bonsai Brain. Let us try to understand the Bonsai Brain with respect to that context.

The Bonsai brain platform basically uses deep reinforcement learning principles to simulate and train the Bonsai brain. The Bonsai brain platform ensures to simulate and train the Brain for all possible or unseen circumstances and ensures smarter Autonomous systems are produced. The entire Bonsai brain platform operates on three standard operating principles. Let us look into it and try to understand the importance of these in the Bonsai brain platform.

i) Integrate component in the platform is responsible for integrating training simulations to the Bonsai brain with real-world scenarios and providing feedback accordingly to the training process. The Bonsai brain in this stage is aimed to be simulated for all known possible circumstances and real-world circumstances so that the simulated Bonsai brain remains robust for unseen changes.

ii) Train component in the platform is responsible for training and simulating the brain according to the feedback received from the Integrate component. The Bonsai brain is trained for real-time learning objectives and is an iterative process that learns and gets simulated according to the learning objectives formed by the Simulator in the Integrate component.

iii) Export component in the platform consists of a completely trained and simulated Bonsai Brain that will be available as a Linux container that can be deployed in the Azure environment or in the premises.

The Bonsai brain is simulated and trained to ensure the replication of real-world systems. This makes the Bonsai brain get trained in real-world or authentic training environments. The Bonsai brain basically uses simulations and Deep Reinforcement learning principles to Train the Brain in the platform. But there are two check conditions that have to be fulfilled to train the Bonsai brain in the platform. They are as follows.

i) The precision for each of the actions that are simulated to the Bonsai Brain has to be accurate to ensure that the Bonsai brain is robust and is operating as expected.

ii) Probability of recovering from a wrong action performed by the brain has to be fast or high to ensure continuous operations as the Brain would be integrated into major autonomous systems. This also ensures the Brain is simulated and trained to remain robust even for uncertain actions that the brain would take up in the real-world environment.

As we have got an introduction to the Bonsai Brain, let us try to understand the critical components of the Bonsai Brain in the next section of the article.

Components of the Bonsai Platform

The entire Bonsai brain operates on 5 critical components. In this section let us look into the critical components of the Bonsai brain and try to understand the functionality of each of the components in the Bonsai brain.

i) Brain is the agent in the Bonsai platform. The Brain in the platform will be simulated and trained to meet the desired goals set. In the Bonsai platform, the Brain as an agent will be available in the form of a text (txt) file named Inkling file.

ii) Simulator in the Bonsai platform is the component responsible for simulating the brain to learn from different instances. The input to the simulator will be observations and the output of the simulator will be the different sets of actions that will be performed by the Bonsai Brain in the Bonsai platform.

iii) Workspace is one of the components of the Bonsai platform that holds all the Brains and the simulators created in the platform. So the workspace is the component of the Bonsai platform with huge collections of Bonsai brains. Brains from this component can be pulled to be the simulator component and can be trained accordingly. The Workspace platform can also be used to monitor the training of the Brain in the platform.

iv) Iteration is one of the components of the Bonsai platform where for each set of simulations the brain is trained to produce certain action. So each action by the brain in the platform is termed an iteration. The Iteration in the platform is entirely dependent on the training instances and the observations it is simulated for. For complicated systems, the iterations in the Bonsai platform may be very huge.

v) Episode is one of the components of the Bonsai platform that is used to set a threshold for the iterations in the Bonsai platform. The episode in the Bonsai platform will operate based on a built-in Episode Iteration Limit and when the mentioned episode in the platform is reached, the simulator will be reset in the Bonsai platform.

Advantages of Bonsai brain

The Bonsai brain finds its major advantages in AI use cases. Let us summarize the major advantages of using the Bonsai brain for AI applications.

  • Ability to simulate and train the Brain with respect to the industry requirements and domain expertise which ensures the Brain simulated remains robust.
  • Ability to provide improved control methods and improved automation systems as they will be simulated for the right set of actions in the Bonsai platform.
  • The Bonsai brain can be simulated to quickly adapt to immediate production changeovers if any as per requirements.
  • In the Workspace, Brains can be developed that will remain robust for unseen circumstances and pulled accordingly to simulate it. This ensures continuous operations of Brains integrated or deployed on the premise or in the cloud.

Now let us look at how to simulate a Bonsai brain for an AI task.

Simulating a Bonsai Brain

As mentioned in this article Bonsai’s brain basically uses Deep Reinforcement Learning principles to simulate Bonsai’s brain in the Bonsai platform. The Bonsai platform ensures the brain is simulated and trained for all random or unexpected circumstances. Let us understand through a case study how to simulate and train a Bonsai brain to balance a pole with AI.

The main task in this case study is to balance a pole that is standing on a moving base. But remember to understand this case study better we need to have a Microsoft Azure account. In this article, the steps to be followed will be listed in detail that can be implemented to use this case study in the Microsoft Azure platform.

Step-1:  Selecting the simulator from Workspace

Bonsai brain is one of the projects by Microsoft which is still in the development stage. So for balancing the pole task we have to select the cartpole simulator from the Workspace. The cartpole has to be selected by first signing into the Bonsai User Interface. After selecting the cartpole from the list of brains from the Bonsai Workspace we will have to give a random name to the cartpole brain selected. After naming the cartpole brain we should click on create Brain to load the brain and the simulator in the Bonsai platform.

In the Bonsai brain user interface the cartpole brain would appear as shown in the above image. 

Step-2: Validating prebuilt training code

Once the cartpole is selected a prebuilt training code will be available in a text file known as Inkling. Two panels can be accessed where in one panel we can see the code for the cartpole and in the other panel we can see a graph-based panel for the cartpole. In the graph panel, there are three main nodes named State node, Concept node, and Action node. So if the nodes are selected in the graph panel the respective code in the Inkling file gets highlighted.

Step-3: Training the Bonsai brain

In the Bonsai User interface, we will have to navigate to the “Train” tab and click on the green button to start the brain training process on the Bonsai platform. Once the training process is instantiated in the Bonsai platform the user interface will replace the coding panel with a graph showing the training process of the Bonsai brain in the platform.

A data panel will appear in the user interface where a graph will be generated for the different training iterations and the action or the goal achieved in percentage. So for each iteration, a performance score is obtained and the bonsai brain training process can be reported using the Goal Satisfaction plot.

Step-4: Visualizing the actions in the platform

Once the training process of the Bonsai brain in the Bonsai platform is completed, the brain can be visualized in the Bonsai platform for its performance in balancing the pole. Here a 3D simulator is visualized that would show how a pole in real time would be balanced on a cartpole for the instances it is trained upon. The cart would move in left and right directions and the pole would be balanced according to the learning simulated to it according to the deep reinforcement learning principles.

Step-5: Terminate the training process

Bonsai brain has the ability to automatically terminate the training process if the overall goal satisfaction factor reaches 100%. So if 100% goal satisfaction is obtained it means that the brain is simulated in the Bonsai platform for all random and uncertain circumstances and the brain would remain robust when taken up for deployment in AI interfaces.

The training process can also be interrupted in the Bonsai user interface by clicking on the Stop training button and the actions of the brain can also be visualized accordingly for the trained number of instances.


Bonsai Brain is one of Microsoft’s projects which aims to reduce redundant and huge codes and deploy efficient and robust AI models. Bonsai’s brain basically uses deep reinforcement learning principles to build effective AI models, and by using the Bonsai platform robust AI models can be simulated and developed by following a few steps. We also saw that we could develop a pole balancing AI model with a few steps using the Bonsai brain platform. Bonsai’s brain, if developed, would be a vital part of various automation systems and would be found integrated into various AI models as well.


More Great AIM Stories

Darshan M
Darshan is a Master's degree holder in Data Science and Machine Learning and an everyday learner of the latest trends in Data Science and Machine Learning. He is always interested to learn new things with keen interest and implementing the same and curating rich content for Data Science, Machine Learning,NLP and AI

Our Upcoming Events

Conference, Virtual
Genpact Analytics Career Day
3rd Sep

Conference, in-person (Bangalore)
Cypher 2022
21-23rd Sep

Conference, in-person (Bangalore)
Machine Learning Developers Summit (MLDS) 2023
19-20th Jan

Conference, in-person (Bangalore)
Data Engineering Summit (DES) 2023
21st Apr, 2023

3 Ways to Join our Community

Discord Server

Stay Connected with a larger ecosystem of data science and ML Professionals

Telegram Channel

Discover special offers, top stories, upcoming events, and more.

Subscribe to our newsletter

Get the latest updates from AIM

The curious case of Google Cloud revenue

Porat had earlier said that Google Cloud was putting in money to make more money, but even with the bucket-loads of money that it was making, profitability was still elusive.

Global Parliaments can do much more with Artificial Intelligence

The world is using AI to enhance the performance of its policymakers. India, too, has launched its own machine learning system NeVA, which at the moment is not fully implemented across the nation. How can we learn and adopt from the advancement in the Parliaments around the world? 

Why IISc wins?

IISc was selected as the world’s top research university, trumping some of the top Ivy League colleges in the QS World University Rankings 2022