Rational OpenCog Controlled Agent, or ROCCA, is a project aiming at creating an opencog agent that acts rationally in OpenAI Gym environments (including Minecraft via minerl).
At its core it relies on PLN (Probabilistic Logic Networks) for both learning and planning. In practice most of the learning is however handled by the pattern miner, which can be seen as a specialized form of PLN reasoning. Planning, the discovery of cognitive schematics, is handled by PLN and its temporal reasoning rule base. Decision is currently a hardwired module, heavily inspired by OpenPsi with a more rational sampling procedure (Thompson Sampling for better exploitation vs exploration tradeoff).
For now learning is only able to abstract temporal patterns based on directly observable events. That is the agent is able to notice that particular action sequences in certain contexts tend to be followed by rewards, however it is not, as of right now, able to reason about action sequences that it has never observed. This requires Temporal Deduction, currently under development.
Once Temporal Deduction is complete we still have a lot of things to add such as
- More sophisticated temporal and then spatial inference rules.
- ECAN, for Attention Allocation, to dynamically restrict the atomspace to subsets of items to process/pay-attention-to.
- Record attention spreading to learn/improve Hebbian links.
- Concept creation and schematization (crystallized attention allocation).
- Record internal processes, not just attention spreading, as percepta to enable deeper forms of instrospective reasoning.
- Plan internal actions, not just external, to enable self-growth.
OpenCog tools
- cogutil
- atomspace
- ure
- spacetime
- pln
- miner
- [optional] cogserver
- [optional] attention
- [optional] opencog
Third party tools
- Python 3
- python-orderedmultidict https://pypi.org/project/orderedmultidict/
- fastcore https://fastcore.fast.ai
- OpenAI Gym https://gym.openai.com/
- MineRL https://minerl.io
- nbdev https://nbdev.fast.ai
In the root folder enter the following command:
pip install -e .
For the tools used for development:
pip install -r requirements-dev.txt
A gym agent defined under the rocca/agents
folder is provided that
can used to implement agents for given environments. See the examples
under the examples
folder.
There are Jupyter notebooks provided for experimentation as well.
If you write code in notebooks that is exported (has the #export
comment on top of the cell), remember to invoke nbdev_build_lib
to update the library. Remember to use black
for formatting, you can invoke black .
from the project root to format everything.
You can also use the Makefile for your convenience, invoking make rocca
will do both of the above in sequence.
The .devcontainer
folder has configuration for VS Code devcontainer functionality. You can use it to setup a development environment very quickly and regardless of the OS you use.
Using type annotations is highly encouraged. One can type check the entire Python ROCCA code by calling
tests/mypy.sh
from the root folder.
To only type check some subfolder, you may call mypy.sh
from that
subfolder. For instance to type check the examples
subfolder
cd examples
../tests/mypy.sh
Simply run pytest
in the root folder.
There is no ROCCA paper per se yet. In the meantime here is a list of related references
- An Inferential Approach to Mining Surprising Patterns in Hypergraphs, Nil Geisweiller et Ben Goertzel
- Partial Operator Induction with Beta Distributions, Nil Geisweiller
- Thompson Sampling is Asymptotically Optimal in General Environments, Jan Leike et al
- Draft about temporal reasoning in PLN, Nil Geisweiller
- References about OpenCog including PLN