Hi,
I’ve read somewhere in the threads that a refactoring of the codebase is being considered.
As a new person getting into the project, I’d like to offer my perspective and ideas.
I know it will take months if the refactoring is even done. So my hope is just to start a discussion, and brainstorm some ideas beforehand.
So as someone new getting started with Monty, here is how I would have liked the API to be:
# Create a new untrained AI model
ai = AI(num_learning_modules=10)
# Or load one that is saved on file
ai = AI().load('/pretrained/my_pretrained_ai.monty')
# Then we can add agents to the AI (and we can add different agents to the same trained model, depending on what we want to do)
eye = EyeAgent()
eye.add_vision_sensor(num_patches=10, patch_resolution=0.5)
finger = FingerAgent()
finger.add_touch_sensor(num_patches=20, patch_area=0.05, pressure_threshold=0.1)
finger.add_actuator(MotorAgent())
ear = EarAgent()
ear.add_sound_sensor(num_patches=15, frequency_range=(20, 20000), sensitivity=0.8)
# Add the agents to the AI
ai.add_agents(eye, finger, ear)
# Set up the environment (in meters)
env = Environment(width=10, height=10, depth=10)
env.add_AI(ai, xyz = [5, 5, 0])
env.add_object("cup", xyz = [6, 5, 0])
env.add_object("chair", xyz = [3, 4, 0])
# This can show the actual 3D habitat on our screen
insights = Insights()
insights.show_environment(env)
insights.show_benchmarks(ai)
# Continuous interaction loop (or with a limited number of steps).
while True:
# Runs all the new input from the sensor modules throught he learning modules, and generates the motor output instructions.
ai.observe_environment()
# Actually have the motor agents follow the motor instructions, and interact with the environment.
ai.act()
# Once done, save the new learning modules data to file.
ai.save('/pretrained/my_pretrained_ai_v2.monty')
And the users can build their custom version of these classes, extending the base classes, and specifying all their configuration in the custom classes. So the main code would be more like this:
ai = MyAI() # Loads model, and agents
env = MyEnvironment(ai)
while True:
# Observes and acts at the same time,
# so it's one "tick" in the system.
ai.tick()
ai.save() # Save the fined tuned model
So the principles I hope will be considered are:
-
The separation of business logic with the implementation details. (I believe having the code show both business logic and implementation details in the same methods is a distraction and wastes mental energy.)
-
The modules are separated from a conceptual point of view. The AI class doesn’t know about the Environment class. The Insights class or Benchmarks (plotting the environment on our screens) should be separated from the SDK as well.
-
Don’t have the system run in “epochs” at a higher level. Why? Because ideally I would have Monty run all the time, non stop (once we figure out the kinks).
Use case: I would want to just start Monty and let it run on its own. In that time, I can go for a walk, go shopping, wash the dishes, etc. (lol) Then when I’m back I can press a key to stop Monty, and save the new data in the learning modules to a file.
I think this is in line with how Monty will actually be used in the future in real production application. For example, I imagine a house robot running Monty. And the robot will run on a loop. It’s not like the robot will be doing a task, like sweeping the floor and then just “stop” with the broom in hand - because the epochs loop has finished. lol
Anyway, I don’t have a strong preference for any of this. I only want to start a discussion and maybe plant the seeds for things to consider in the future.