google-deepmind / concordia

A library for generative social simulation
Apache License 2.0
497 stars 96 forks source link

Saving and restoring the state of the world #48

Open anatoleg opened 5 months ago

anatoleg commented 5 months ago

What is the best way to save and restore the state of the world to avoid initializing all agents and the game master every time?

jzleibo commented 5 months ago

The memories are all pure text so it should be relatively easy to save them however you like to save text files. Then you can just add them back into the memory. You would lose the embeddings this way, but that might not be too big of a deal. If your embedder is deterministic you would get the same embeddings of the same memories again anyway.

@vezhnick @jagapiou anything else to think about for this?

I'm realizing that we should probably provide a convenience function to save and load agents and game masters. We'll probably go ahead and do that soon.

anatoleg commented 4 months ago

One potential problem is that although all components have standardized method names, the attributes are different (e.g., Conversation vs. Observation). We may need a save and a load methods for each component. Should everything be saved as JSON strings?

jagapiou commented 4 months ago

Not the best answer for long-term storage/sharing (and we've not tested it), but have you tried pickle?

anatoleg commented 4 months ago

pickle would probably work but I prefer JSON as it is human-readable. An agent and all its components seem to share the same AssociativeMemory instance, so I need to save it only once. Is this correct?

jzleibo commented 4 months ago

JSON would work.

Yes, all the components of a given agent share the same AssociativeMemory.

Also, all the components of the GameMaster share an associative memory. Sub "scene" game masters might or might not use a different associative memory (e.g. for a conversation).