箱庭 (Hakoniwa) 
"Hakoniwa" which is a miniature garden in Japanese is a simulation framework letting LLM based entities play around inside. This framework aims to provide the way to experiment how the LLM behaves in the specific domain defined as a simple state machine which has states and actions respectively. The framework is designed to be able to be used for the following purposes:
- To experiment how the LLM behaves in the specific enviroment.
- To collect the behavior data resembling the human behavior in the real world.
Usage
Define the state machine
First of all, we can define the state machine where each agent play around inside. The state machine is defined as a YAML file. The following is the example of the state machine definition.
states:
state0:
name: In the house
choices:
- action: Go outside
next: state1
- action: Stay inside
next: state0
state1:
name: Outside
choices:
- action: Go to the supermarket
next: state2
- action: Go back home
next: state0
state2:
name: In the supermarket
choices:
- action: Go back home
next: state0
entities:
- name: A living thing
type: openai
initial_state: state0
The state machine consists of the following two parts.
states: The list of states in the state machine.choicesis the list of actions which the agent can take from the state.entities: The list of entities which play around inside the state machine.
The CLI script, hakoniwa is usable to run the simulation with the state machine definition.
$ poetry run hakoniwa -f env.yaml
Please make sure to set the OPENAI_APIKEY if you set the OpenAI entity in the environment.
You will see what it does in the environment.
INFO:hakoniwa.environment:A living thing,{'action': 'Stay inside', 'next': 'state0'}
INFO:hakoniwa.environment:A living thing,{'action': 'Go outside', 'next': 'state1'}
INFO:hakoniwa.environment:A living thing,{'action': 'Go to the supermarket', 'next': 'state2'}
Dependencies
Install Poetry and run the following command to install dependencies.
$ poetry install
Development
We can run the unit test with pytest.
$ make test
Metadata
Release files for hakoniwa 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hakoniwa-0.1.2.tar.gz | 10.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hakoniwa-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.5 kB
Release files / hakoniwa-0.1.2.tar.gz
| Download URL | hakoniwa-0.1.2.tar.gz |
|---|---|
| Size | 10.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e46e4a4d0d5ca55fc17d98eb1582d828d7299080224a29de56fd9c3be46b26e
|
|
BLAKE2b-256 checksum How to use checksums |
1030b4fc3acf3c64f1a0e4f7bc4e35f36b2ccfd582b21f939b15842144d92efe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.9.13 Darwin/23.0.0
|
Release files / hakoniwa-0.1.2-py3-none-any.whl
| Download URL | hakoniwa-0.1.2-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bc5603f49840cef9a2bb88413cef472bd1aff5a8c0f259aa645264713868113c
|
|
BLAKE2b-256 checksum How to use checksums |
c52d02ec4b8325e5cae78cc907dcc3adc3720f7c52fe37d4e9d108459374be6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.3.2 CPython/3.9.13 Darwin/23.0.0
|