A framework for integrated Artificial Intelligence & Artificial General Intelligence (AGI)
Scheme C++ Python C CMake Perl Other
Latest commit 9bb2e84 Apr 28, 2017 @leungmanhin leungmanhin committed on GitHub Merge pull request #2709 from leungmanhin/chatlang-ui
Initial work on the chatlang UI



Build status: Build Status

OpenCog is a framework for developing AI systems, especially appropriate for integrative multi-algorithm systems, and artificial general intelligence systems. Though much work remains to be done, it currently contains a functional core framework, and a number of cognitive agents at varying levels of completion, some already displaying interesting and useful functionalities alone and in combination.

The main project site is at http://opencog.org


OpenCog consists of multiple components. At its core is a (hyper-)graph database, the AtomSpace, which is used for representing knowledge and algorithms, providing a surface on which learning and reasoning algorithms are implemented. The AtomSpace consists of an in-RAM database, a "query language" aka "pattern matcher", a (ProLog-like) rule system, including forward and backward chainers, and an evaluator for the internal "programming langauge", Atomese. This language is not really meant to be used by humans (although, defacto, it is) but rather, it is a language for representing knowledge and algorithms, on which (automated) reasoning and learning can be performed. The AtomSpace also provides Scheme (guile) and Python bindings. The AtomSpace is maintained in a separate git repo: http://github.com/opencog/atomspace

This git repository contains assorted projects that are central to the OpenCog project, but are not yet mature or stable, and are subject to active development and experimentation. These include:

  • An assortment of natural language processing subsystems, including: -- Natural language generation (for expressiong thoughts as sentences). -- Natural language input (for reading and hearing). -- Assorted chatbots, some of which are embodied.
  • PLN, a probabilistic reasoning and inference system.
  • Attention Allocation, for managing combinatoric explosion during reasoning and language generation.
  • Space-time servers, for managing spatial and time data (grounding common-sense natural language concepts such as "next-to", "nearby", and "soon".)
  • An embodiment subsystem, attaching language to visual and auditory senses. This is primarily located in the ROS Behavior Scripting repository.
  • OpenPsi, a model of psychological states. Its currently a mashup of two unrelated ideas: a generic rule-class selection and plannning system, and a model of human psychological states. An open to-do item is to untangle these two.
  • An unsupervised learning system or "pattern miner", for extracting "surprising" patterns.
  • A supervised learning system, MOSES, for extracting patterns from tabular data. This is located in a seprate repository, MOSES.
  • The CogServer, a network server providing shell access and a REST API.
  • Several (obsolete!?) data visualization subsystems.

With the exception of MOSES and the CogServer, all of the above are in active development, are half-baked, poorly documented, mis-designed, subject to experimentation, and generally in need of love an attention. This is where experimentation and integration are taking place, and, like any laboratory, things are a bit fluid and chaotic.

Building and Running

For platform dependent instruction on dependencies and building the code, as well as other options for setting up development environments, more details are found on the Building Opencog wiki.

There is no single "demo" or system that can be "run"; rather, the various subsystems can be run individually, or together. The single most-fully-integrated, complete demo would be the embodied Hanson Robotics chat subsystem. This can be run without having an actual robot; a virtual Blender animation may be used instead; a webcam and microphones are required for sensory input. Portions of this system can be found in the nlp directory, in this repo, as well as the ROS Behavior Scripting repo. The full setup is located in the Hanson Robotics HEAD repo, and ready-to-run Docker images can be found in the OpenCog Docker repo.


To build and run OpenCog, the packages listed below are required. With a few exceptions, most Linux distributions will provide these packages. Users of Ubuntu 14.04 "Trusty Tahr" may use the dependency installer at /scripts/octool. Users of any version of Linux may use the Dockerfile to quickly build a container in which OpenCog will be built and run.


Common OpenCog C++ utilities http://github.com/opencog/cogutils It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.


OpenCog Atomspace database and reasoning engine http://github.com/opencog/atomspace It uses exactly the same build procedure as this package. Be sure to sudo make install at the end.

Optional Prerequisites

The following packages are optional. If they are not installed, some optional parts of OpenCog will not be built. The CMake command, during the build, will be more precise as to which parts will not be built.

Link Grammar

Natural Language Parser for English, Russian, other languages. Required for natural language generation, and the chatbot. http://www.abisource.com/projects/link-grammar/


MOSES Machine Learning http://github.com/opencog/moses It uses exactly the same build proceedure as this package. Be sure to sudo make install at the end.


Open Graphics Library Used by opencog/spatial/MapTool (which is now deprecated/obsolete !?) http://www.opengl.org Commonly provided with your video card driver


Simple DirectMedia Layer Used by opencog/spatial/MapTool (which is now deprecated/obsolete !?) http://www.libsdl.org | libsdl1.2-dev


Simple DirectMedia Layer extension Used by opencog/spatial/MapTool (which is now deprecated/obsolete !?) http://www.ferzkopp.net/joomla/content/view/19/14/ | libsdl-gfx1.2-dev


C++ HTTP RESTful interfaces Used by the Pattern miner for distributed processing (this will be replaced by gearman in future releases). wget https://github.com/Microsoft/cpprestsdk/archive/v2.9.0.tar.gz

Threading Building Blocks

C++ template library for parallel programming Used to implement the optional REST API. (TODO: the REST API should be refactored to not use TBB) https://www.threadingbuildingblocks.org/download | libtbb-dev

ZeroMQ (version 3.2.4 or higher)

Asynchronous messaging library Used by the event publisher library ... which is currently broken, anyway, and not used anywhere ... http://zeromq.org/intro:get-the-software | libzmq3-dev

Building OpenCog

Perform the following steps at the shell prompt:

    cd to project root dir
    mkdir build
    cd build
    cmake ..

Libraries will be built into subdirectories within build, mirroring the structure of the source directory root.

Unit tests

To build and run the unit tests, from the ./build directory enter (after building opencog as above):

    make test

CMake notes

Some useful CMake's web sites/pages:

The main CMakeLists.txt currently sets -DNDEBUG. This disables Boost matrix/vector debugging code and safety checks, with the benefit of making it much faster. Boost sparse matrixes and (dense) vectors are currently used by ECAN's ImportanceDiffusionAgent. If you use Boost ublas in other code, it may be a good idea to at least temporarily unset NDEBUG. Also if the Boost assert.h is used it will be necessary to unset NDEBUG. Boost ublas is intended to respond to a specific BOOST_UBLAS_NDEBUG, however this is not available as of the current Ubuntu standard version (1.34).

-Wno-deprecated is currently enabled by default to avoid a number of warnings regarding hash_map being deprecated (because the alternative is still experimental!)