Technology Fridays: Why Bonsai is a Great Addition to Microsoft’s AI Stack
Earlier this week, Microsoft announced that is continuing its acquisition spree by purchasing machine learning startup Bonsai. The should not be completely surprising as Microsoft had already indicated its interest in Bonsai by leading a $7.6M investment round in the startup last year. I’ve written about Bonsai extensively before but today I would like to dig deeper into the elements that make this platform unique in the deep learning space.
At a high level, you can think of Bonsai as a platform that provides a simpler way to build, train and execute deep learning models without dealing with the low level constructs of frameworks such as TensorFlow, MxNet or Microsoft’s own Cognitive Toolkit. However, the Bonsai platform is much more. Bonsai focuses on an area that they like to call machine teaching and that can be seen as a variation of reinforcement learning. In the Bonsai world, the goal of machine teaching models is to program a BRAIN to solve problems in complex environments by following the action-reward model of reinforcement learning algorithms. Specifically, Bonsai’s describes machine teaching in three easy steps.
The BRAIN
The Bonsai platforms abstracts BRAINs using four simple concepts known as STAR (State, Terminal, Action, Reward).
Typically, the implementation of a BRAIN is divided between a model written in a domain specific language known as Inkling and a simulator which is typically authored in Python.
The Inkling Language
Reinforcement learning problems in the Bonsai platform are modeled using Inkling, a functional, domain-specific language specialized on representing learning scenarios. Examples of learning scenarios could be:
- Learning to play a game
- Learning to recognize what a handwritten digit is
- Learning to tell if something is red or what color something is
- Learning to save electricity in your home
- Learning to manage a process to specific guidelines
Inkling is based on three fundamental constructs: Concepts, Schemas, Curriculums and Lessons.
The following example, from the Bonsai documentation, represents an Inkling program used to keep the internal temperature of a house. You can see how the language combines the aforementioned constructs.
schema HouseheatState
Float32 heat_cost,
Float32 temperature_difference,
Float32 temperature_difference_t1,
Float32 temperature_difference_t2,
Float32 temperature_difference_t3,
Float32 temperature_difference_t4,
Float32 temperature_difference_t5,
Float32 outside_temp_change
end
schema HouseheatAction
Float32{ 0.0:1:1.0 } heater_on
end
schema HouseheatConfig
Float32 outside_phase
end
concept thermostat is classifier
predicts (HouseheatAction)
follows input(HouseheatState)
feeds output
end
simulator simulink_sim(HouseheatConfig)
action (HouseheatAction)
state (HouseheatState)
end
curriculum my_curriculum
train thermostat
with simulator simulink_sim
objective match_set_temp
lesson my_first_lesson
configure
constrain outside_phase with Float32{0.0:12.0}
until
maximize match_set_temp
lesson my_second_lesson
configure
constrain outside_phase with Float32{0.0:24.0}
until
maximize match_set_temp
lesson my_third_lesson
configure
constrain outside_phase with Float32{0.0:48.0}
until
maximize match_set_temp
end
Using Bonsai
Developers can start using Bonsai by downloading the platforms into their local environment. Depending on the project, the platforms might include dependencies on other technologies such as Anaconda or OpenAI Gym.
Using the Bonsai CLI, we can create a BRAIN by using the following command line.
bonsai create myMountainCarBrain
At that point, its just a matter of starting the Python simulator and process the Inkling model. Bonsai can also be used in Jupyter notebooks. The Bonsai platform provides tools to visualize the monitor the status of the BRAIN.
What Microsoft Get with Bonsai?
By acquiring Bonsai, Microsoft gets leading platform in the reinforcement learning space. We can expect Microsoft to integrate the Bonsai platform with the rest of its artificial intelligence(AI) stack such as Azure Machine Learning or the Cognitive Toolkit.