Microsoft engineers have open-sourced a simulation environment called “TinyTroupe” that lets users spin up synthetic personas that can interact with each other – in theory, its creator said, this could help users “investigate a wide range of convincing interactions and consumer types, with highly customizable personas, under conditions of [your] choosing.”
The experimental Python library is the brainchild of Dr Paulo Salem, an LLM prompt engineering specialist and senior data scientist at Redmond. It features two key abstractions: TinyPerson, sample agents that have pre-trained "personality", receive stimuli and act upon them; and TinyWorld, the environment in which the agents exist and interact like bugs under the glass of their curious and mercantile human observers...
It makes OpenAI or Azure OpenAI API calls to power the "TinyTroupe" and features several caching mechanisms (one for the simulation state, another for the LLM calls) designed to reduce the tokens/running cost. (TinyTroupe
also provides a "clever way to obtain new agents, using LLMs to generate their specification for you, through the TinyPersonFactory
class" its creators said on its GitHub repository ReadMe this week.
Say more about the caching bit?
LLM API caching is "very straightforward: every LLM call is kept in a map from the input to the generated output; when a new call comes and is identical to a previous one, the cached value is returned" TinyTroupe's repo shows.
Caching of the simulation state meanwhile uses the module tinytroupe.control
for a range of simulation management methods designed to let users avoid having to run all 10 steps of a simulation again when just the tenth of nine needs redoing.
control.begin("<CACHE_FILE_NAME>.cache.json")
: begins recording the state changes of a simulation, to be saved to the specified file on disk.control.checkpoint()
: saves the simulation state at this point.control.end()
: terminates the simulation recording scope that had be started bycontrol.begin()
.
TinyTroupe started as an internal Microsoft hackathon project, and has been released whilst still pretty raw by its five-strong contributors, with the aim of soliciting further input and potential use-cases, Dr Salem said.
He wrote this week that “the focus is on understanding human behavior and not on directly supporting it (like, say, AI assistants do)...” posting on LinkedIn that examples of what can be done with TinyTroupe include:
- 📺 Advertisement: TinyTroupe can evaluate digital ads (e.g., Bing Ads) offline with a simulated audience before spending money on them!
- 🧑💻 Software Testing: TinyTroupe can provide test input to systems (e.g., search engines, chatbots or copilots) and then evaluate the results.
- 🤾♂️ Training and exploratory data: TinyTroupe can generate realistic synthetic data that can be later used to train models or be subject to opportunity analyses.
- 🏭 Product and project management: TinyTroupe can read project or product proposals and give feedback from the perspective of specific personas (e.g., physicians, lawyers, and knowledge workers in general).
- 🧠 Brainstorming: TinyTroupe can simulate focus groups and deliver great product feedback at a fraction of the cost!
Dr Salem added that as "each such simulated agent progresses through its life, it receives stimuli from the environment and acts upon them. The stimuli are received through the listen, see and other similar methods, and the actions are performed through the act method… Each agent contains a lot of unique details, which is the source of its realistic behavior.
"This, however, means that it takes significant effort to specify an agent manually. Hence, for convenience, TinyTroupe provide some easier ways to get started or generate new agents. To begin with, tinytroupe.examples contains some pre-defined agent builders that you can use.
"For example, tinytroupe.examples.create_lisa_the_data_scientist creates a TinyPerson that represents a data scientist called Lisa."
The project needs "all sorts of things" its creators freely admit (this is NOT shiny Microsoft product) "but we are looking mainly for new interesting use cases demonstrations, or even just domain-specific application ideas" the team said this week, admitting that improvements are needed across...
- Memory mechanisms.
- Data grounding mechanisms.
- Reasoning mechanisms.
- New environment types.
- Interfacing with the external world, etc.
Feel free to have a play around here where there are more details, but be warned, weirdos, that TinyTroupe "is not intended to simulate sensitive (e.g. violent or sexual) situations" however Tiny they might be.