<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Alexey Potapov on Medium]]></title>
        <description><![CDATA[Stories by Alexey Potapov on Medium]]></description>
        <link>https://medium.com/@alexey_67767?source=rss-c6e960c4fe5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LEMNe9qxf6A7sLqLccwTdA.jpeg</url>
            <title>Stories by Alexey Potapov on Medium</title>
            <link>https://medium.com/@alexey_67767?source=rss-c6e960c4fe5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 13:12:15 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alexey_67767/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[SingularityNET’s Progress Towards Beneficial General Intelligence (BGI)]]></title>
            <link>https://medium.com/singularitynet/singularitynets-progress-towards-beneficial-general-intelligence-bgi-66a266c87f8c?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/66a266c87f8c</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[knowledge-graph]]></category>
            <category><![CDATA[decentralization]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 17:44:00 GMT</pubDate>
            <atom:updated>2024-02-27T17:49:08.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*GqJjms4UQ5dihpoJ" /></figure><p>We bring you our 2023 progress toward the Beneficial General Intelligence (BGI) report, highlighting the extraordinary body of work carried out by the SingularityNET core AGI team in collaboration with our spin-offs TrueAGI and Zarqa, our partners, and the wider OpenCog community.</p><p>We specifically focus on the technical advancements of the OpenCog Hyperon AGI framework. Key achievements include advancing Hyperon’s cognitive components, the extension of AI-DSL into the MeTTa SDK, and advancements in experiential learning through projects like ROCCA and NARS.</p><p>We also outline a roadmap for future development, focusing on Hyperon Alpha, real-world applications, expansions of Hyperon components, interoperability with the SingularityNET platform, and implementation of the PRIMUS cognitive model.</p><p>While our commitment to achieving BGI is nothing new, what is different today is our transition from conceptualization to active implementation, translating our AGI R&amp;D ideas into advanced systems ready to deal with real-world use cases. In parallel and with clear synergies, we are energetically progressing our <a href="https://blog.singularitynet.io/singularitynet-ai-platform-2024-strategy-and-roadmap-ccc580bbcbaf">decentralized AI Platform development</a>, aimed at leveraging Hyperon to realize our broad vision of an intelligent, self-organizing, generally-intelligent global brain.</p><p>This report also serves as an open invitation to AGI researchers and the wider AI community to contribute to our open cognitive-level approach and help drive the development of true AGI.</p><p>Table of Contents:</p><p>· <a href="#157c">OpenCog Hyperon: A Framework for AGI at the Human Level and Beyond</a><br>· <a href="#5d57"><strong>What is OpenCog Hyperon?</strong></a><br><em>· </em><a href="#14b0"><em>MeTTa Language</em></a><em><br>· </em><a href="#bb6a"><em>Distributed Atomspace</em></a><em><br>· </em><a href="#c0c4"><em>Cognitive Algorithms</em></a><br>· <a href="#19b1"><strong>Hyperon in 2023</strong></a><br>· <a href="#2a30"><em>OpenCog Hyperon R&amp;D in 2023: Core Components</em></a><em><br>· </em><a href="#b566"><em>AI-DSL in 2023</em></a><em><br>· </em><a href="#3af8"><em>F1R3FLY Update</em></a><br><strong>· </strong><a href="#47dd"><strong>From Core Tech Development to AGI R&amp;D and Applications</strong></a><br>· <a href="#6ea3"><em>Incorporating LLMs into OpenCog Hyperon</em></a><em><br>· </em><a href="#a8b4"><em>LLMs and AGI</em></a><em><br>· </em><a href="#5c6e"><em>Beyond LLMs</em></a><em><br>· </em><a href="#d992"><em>Neural-Symbolic Synergy</em></a><em><br>· </em><a href="#8b75"><em>Experiential learning — ROCCA, NARS, Causal Reasoning, AIRIS</em></a><br><strong>· </strong><a href="#a0e8"><strong>The Road to AGI: Hyperon Roadmap</strong></a><br>·<em> </em><a href="#78d6"><em>OpenCog Hyperon</em></a><em><br>· </em><a href="#d440"><em>The PRIMUS Cognitive Model</em></a><em><br>· </em><a href="#66ba"><em>SingularityNET Platform Integration</em></a><br>· <a href="#7a0b"><strong>Towards Beneficial AGI</strong></a></p><h3>OpenCog Hyperon: A Framework for AGI at the Human Level and Beyond</h3><h3>What is OpenCog Hyperon?</h3><p>OpenCog is an integrative cognitive architecture and AI system design with the breadth and complexity to achieve Artificial General Intelligence (AGI) at the human level and beyond via a combination of autonomous learning and human education and supervision.</p><p>The core of the infrastructure is a distributed metagraph called the Atomspace, a highly complex and nuanced form of Knowledge Graph. The Atomspace consists of nodes and (hyper)links containing various information — interrelationships, types, and probabilities. This symbolic space of knowledge allows the system to learn, store, and update knowledge and facts in a reliable (and non-hallucinatory) way and reason logically from this knowledge.</p><p>Multiple AI algorithms from different paradigms (logical reasoning, probabilistic programming, neural networks, evolutionary learning) can be integrated into a common framework, allowing them to leverage the Atomspace for internal representation and to interoperate and work cooperatively on it.</p><p>An associated cognitive systems theory explains how this approach can encompass all the central aspects of human intelligence, focusing on the “cognitive synergy” among different algorithms and modes of memory organization.</p><p>Since circa 2020, the SingularityNET Foundation, together with its ecosystem partner TrueAGI and members of the OpenCog community, has been developing a new, scalable, and more powerful version of the system called<a href="https://arxiv.org/abs/2310.18318"> OpenCog Hyperon</a>.</p><p>The decision to create a new version of the OpenCog Classic codebase was motivated by scalability and usability considerations and the need to leverage novel tools and methods from math branches such as dependent type theory, intuitionistic and paraconsistent logic, and meta-computations at deeper levels in the system design.</p><p>As with the original OpenCog framework, Hyperon is designed to provide modular support for diverse cognitive architectures. We discuss the design and evolution of one such architecture, PRIMUS, in the Road to AGI section below.</p><h3>MeTTa Language</h3><p>OpenCog Hyperon introduced a new core component alongside the Atomspace, a purpose built language for cognitive computations <a href="https://github.com/trueagi-io/hyperon-experimental/">MeTTa</a> (Meta Type Talk), which provides an interoperability and communication layer to the architecture. MeTTa has been designed to be decentralized, self-modifying, and self-organizing.</p><p>The basic idea behind MeTTa is that queries in logic languages, probabilistic programming languages, and database engines, as well as pattern matching in functional languages, have the same form and can be united. Chaining such queries is enough to build a programming language that unifies logic inference over knowledge with probabilistic and functional programming, making the implementation of AI algorithms in MeTTa very natural.</p><p>Moreover, programs written in MeTTa are represented as subgraphs in the Atomspace in the same way as knowledge, allowing interlinked algorithms to cooperate by sharing information and intermediate state. In addition to this, the AI algorithms can, in turn, become the input for other agents which can, therefore, change and evolve such algorithms in a process fully coordinated inside the Atomspace.</p><h3>Distributed Atomspace</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VYJd41zpAgtOpWHq" /></figure><p>Another important improvement presented in OpenCog Hyperon is the Distributed Atomspace (DAS), an extension of the Atomspace into a more independent component designed to support multiple simultaneous connections with different AI algorithms, providing a flexible query interface to distributed knowledge bases.</p><p>DAS is the hypergraph OpenCog Hyperon uses to represent and store knowledge, being the source of knowledge for AI agents and the container of any computational result that might be created or achieved during their execution. It can be used as a component or as a stand-alone server to store essentially arbitrarily large knowledge bases and provide means for the agents to traverse regions of the hypergraphs and perform global queries involving properties, connectivity, subgraph topology, etc.</p><h3>Cognitive Algorithms</h3><p>The OpenCog design supposes implementing a variety of cognitive algorithms on top of its core components to perform knowledge-based reasoning and problem-solving in a synergistic manner.</p><p>Of special importance is <a href="https://link.springer.com/chapter/10.1007/978-3-031-33469-6_9">PLN</a> (Probabilistic Logic Network), a logic designed to emulate human-like common sense reasoning. This logic excels at dealing with uncertainty, both empirical and abstract knowledge, and the relationships between them. While closely resembling NAL (Non-Axiomatic Logic), PLN remains firmly grounded in probability theory. For instance, the notion of uncertainty is captured by using second-order probability distributions. Such logic provides a common language and contributes to realizing the cognitive synergy in question.</p><h3>Hyperon in 2023</h3><p>In 2023, the development of core components of OpenCog Hyperon advanced remarkably, meeting our targets and incorporating emerging technologies. We have been focusing on delivering the Alpha version of the OpenCog Hyperon AGI framework — foundational components being the MeTTa interpreter and DAS. Concurrently, our core AGI team has transitioned into prototyping in MeTTa of higher-level Hyperon components, including PLN and Pattern Miner. Hyperon has already shown its utility as an AGI R&amp;D platform by demonstrating the possibility of conveniently porting implementations of other reasoning frameworks like the Non-Axiomatic Reasoning System (NARS) into MeTTa.</p><p>We have also been actively exploring and implementing scalability improvements at all computational levels, from base hardware to high-level algorithms and distributed computational platforms, all with an eye toward creating the tech stack required to speed up Hyperon’s metagraph-based algorithms. The hardware level includes the design of specialized computer chips to accelerate DAS pattern-matching queries. Backend optimization besides DAS includes compilation to Rholang, Warren Abstract Machine, and Hypervector representation. The possibility of deployment of Hyperon nodes on HyperCycle and NuNet is also under discussion. Higher-level optimizations include preliminary work on inference control, and attention and resource allocation.</p><p>In early 2023, Minecraft AI mod, <a href="https://www.curseforge.com/minecraft/mc-mods/vereya">Vereya</a>, was developed, extended, and published, with our AI agents keeping up-to-date with new Minecraft versions and working on different platforms. This allowed us to compare <a href="https://medium.com/singularitynet/toward-general-purpose-minecraft-agents-part-2-limitations-of-imperative-algorithms-d60926ba878d">our AI agents</a> to the <a href="https://medium.com/trueagi/voyager-for-minecraft-under-the-hood-3e6cc7e3cb25">GPT4-based Voyager agent</a>. And now, Hyperon is ready to deal with other real-world use cases, including bio-AI and dialog systems, which will accompany Alpha Release.</p><p>Let’s recap the results of 2023.</p><h3>OpenCog Hyperon R&amp;D in 2023: Core Components</h3><p>In the first half of 2023, our MeTTa interpreter became ready for internal testing and experimentation, with improvements related to variable bindings, type checking, expression indexing, and other features. A Space API was implemented and improved, and examples of an SQL space and a “Neural Space” with its own pattern matching via LLM (Large Language Model) calls were provided, opening possibilities for further integration with other types of spaces. Further improvements of MeTTa included an advanced REPL and enriched standard library.</p><p>Though still in the early development stage, the second half of 2023 saw a burst of AI algorithms and Hyperon components prototyping in MeTTa, including PLN PoC, Non-Axiomatic Reasoning System (NARS) implementation in MeTTa, SingularityNET dialog system port to MeTTa, experiments with Pattern Mining, and others.</p><p>In the last quarter of 2023, the first version of the Distributed AtomSpace (DAS) integration to MeTTa using Space API was completed. This important milestone was accompanied by considerable progress in the DAS development, including its caching and indexing components, APIs, and its application to Bio-Atomspace for longevity research. The following milestones were especially important:</p><ul><li><strong>A MeTTa module for LLMs integration</strong> has been prototyped as a basis for future replacement of the SingularityNET dialog system, and the first version of the SingularityNET Platform and Marketplace Assistant has been implemented within it and run as a telegram bot for testing;</li><li><strong>A Minimal MeTTa core </strong>component has been developed, which allowed rewriting the Rust implementation of MeTTa interpreter using the minimal set of core operations, making MeTTa even more flexible and amenable to metacomputations and inference control;</li><li><strong>A Backward Chainer</strong> has been implemented in pure MeTTa. The code is only 5 lines long, yet it is universal enough to generate PLN proof trees, discover frequent patterns, compose AI services, and more. While currently inefficient, ongoing experiments to bring inference control to this implementation are already yielding promising results.</li></ul><h3>AI-DSL in 2023</h3><p>The AI-DSL project roadmap underwent considerable change over the course of the year due to the advent of new technologies and tools. During Q1, we built prototype tools in Idris to crawl the SingularityNET marketplace and retrieve relevant Protobuf information about the SingularityNET services while verifying their types and subtypes.</p><p>Due to rapid MeTTa development, we quickly switched in Q2 from working with Idris to our original goal of developing MeTTa tools for AI-DSL. Tools such as chaining, typing, and sub-typing were implemented in MeTTa in Q3. Q4 saw the build completion of Protobuf to MeTTa parser supporting nested definitions and methods and the incorporation of Protobuf to MeTTa parser into the marketplace crawler. The idea to bring service calls and AI-DSL together and make them accessible to Hyperon led to the extension of the AI-DSL project into the MeTTa SDK for the SingularityNET Platform as the main track.</p><p>With the advent of systems such as ChatGPT, and the release of HuggingGPT as a tool for discovering and connecting services, we began a thorough investigation of HuggingGPT capabilities. We found that, while HuggingGPT was an impressive system, it was quite brittle, oftentimes breaking and not working as desired. As a result, we decided to work on the SingularityNET Platform Assistant to provide an easy-to-use system for interacting with the SingularityNET platform (for instance, requesting services or combined workflows in natural language via a LLM) as an additional track.</p><h3>F1R3FLY Update</h3><p>In 2023, SingularityNET partnered with F1R3FLY to scale particular MeTTa use cases dramatically through advanced Rholang concurrency methods. Steady progress towards demonstrating MeTTa-to-Rholang compilation has been taking place. The demo is designed to show a near-linear scale-up of execution as hardware and nodes are added to the network. Towards this end, F1R3FLY has:</p><ul><li>Ensured the now completed (first iteration) of the <a href="https://github.com/F1R3FLY-io/f1r3fly">Rust implementation of RSpace</a> works well in the network;</li><li>Developed example MeTTa programs for demonstration and is reviewing MeTTa programs under development by the PLN team as candidates for the demo;</li><li>Refactored the <a href="https://github.com/F1R3FLY-io/Singularity-Scale/tree/main/HeavyMeTTaL">MeTTa to Rholang compiler</a> (HeavyMeTTaL) to support debugging and language modifications;</li><li>Developed an algorithm to compile Rholang and other programming languages into hypervectors and started working on the <a href="https://github.com/F1R3FLY-io/rhoHDC">compiler</a>;</li><li>Engaged Oracle as a channel partner to help deliver this demo by providing the cloud infrastructure to support testing, staging, and production deployment.</li></ul><p>Additionally, an extension of the Operational Semantics in Logical Form (<a href="https://github.com/leithaus/rho4u/blob/main/oslf/oslf.pdf">OSLF</a>) algorithm to account for a realizability semantics for PLN has been under development. This means that PLN formulae are interpreted as collections of MeTTa programs. This makes for a very powerful query model. Using OSLF provides algorithmic means to generate both the formulae and the semantics/query model.</p><p>In the spring of 2023, a paper on <a href="https://arxiv.org/abs/2305.17218">operational semantics for MeTTa</a> for judging the correctness of the HeavyMeTTaL compiler was published. Formally specified operational semantics can also be used in the style of <a href="https://ethereum.github.io/yellowpaper/paper.pdf">Ethereum’s yellow paper</a> in the blockchain domain. In the Fall, this approach was updated, producing four alternative calculi for MeTTa for further discussion.</p><h3>From Core Tech Development to AGI R&amp;D and Applications</h3><h3>Incorporating LLMs into OpenCog Hyperon</h3><p>The design of the OpenCog Hyperon architecture was inherently infused with tight neural-symbolic interoperability. Neural networks in the Hyperon design were envisioned as trainable skills that should solve repetitive tasks quickly and reliably. We have been using them as such in dialog systems, semantic vision, and Minecraft agents. Being an essentially integrative framework, OpenCog Hyperon is open to incorporating innovative solutions not only in knowledge representation and reasoning but in deep neural networks as well.</p><p>At SingularityNET, we have been developing and using Deep Neural Networks (DNNs) both as services on the SIngularityNET platform and as OpenCog components for solving various tasks in robotics, dialog systems, bioinformatics, and other domains. Nonetheless, recent advances in LLMs and Transformer architectures have prompted further exploration of their potential to contribute towards the goal of achieving AGI, be it through incremental augmentations or incorporation into broader AGI frameworks like Hyperon.</p><h3>LLMs and AGI</h3><p>LLMs occupy an interesting location on the landscape of narrow AI/AGI systems. They possess an incredibly broad scope in a human sense, and yet they are not AGI. They have a number of known<a href="https://arxiv.org/abs/2309.10371"> serious limitations</a>, including hallucinations (yet despite hallucinating, they struggle with creativity), absence of memory (as an internal component of LLMs themselves), inability to acquire new knowledge consistently, and inability to solve problems requiring multi-step reasoning.</p><p>The core reason for this is that LLMs directly map inputs to outputs in a fixed number of processing steps. This is similar to AlphaGo (and its more recent versions), which learned a fixed mapping to predict the best move by playing hundreds of millions of games. A vast number of combinations are enumerated and hashed during training, and novel combinations are not enumerated during playing (unless the DNNs are augmented with Monte-Carlo tree search).</p><p>That is why generative DNNs are so large — they hash answers during training and recall them with interpolation during inference. And that is why they cannot go far beyond patterns in their training data, e.g., to play with modified rules or to solve a really novel task. They operate as a trained skill, reflex, or intuition, occupying this appropriate functional and architectural position in the neural-symbolic frameworks and Hyperon design.</p><p>The same is true for LLMs. They utilize vast amounts of training data and exhibit limited generalization beyond the training examples. However, the difference from AlphaGo is that this data is not task-specific. Even by recombination, interpolation, and minor generalization of hashed information, LLMs can perform (although not on an expert level) a very broad range of tasks because their training data covers so much of what interests humans in their everyday pursuits. One may call them General Narrow AI.</p><h3>Beyond LLMs</h3><p>Limitations of LLMs do not intrinsically imply that they are not helpful toward the goal of AGI. Both shortcomings and successes of these systems are, in some ways, educational regarding what AGI is and is not.</p><p>The research community is mitigating the limitations of LLMs by integrating them with different components like knowledge graphs and databases, embeddings-based memory, and plugins for searching the web, doing math, and executing code. LLMs are put into wrapper frameworks, which chain calls to LLMs and compose prompts for them, using templates and injecting their output into the next calls to emulate reasoning and even graphs of thoughts. This adds even more utility to LLMs but does not turn them into AGI. These frameworks have their own limitations. They act as ad hoc symbolic systems but without intrinsic knowledge representation and reasoning capabilities. Additionally, their plugins and components lack compositionality, and the expressive power of the control language for chaining LLMs and interoperating them with other components is highly restricted.</p><p>Thus, while the usefulness of LLMs should not be downplayed, utilization of LLMs in further AGI R&amp;D will require a more principled solution to the limitations of LLM architectures either by deeply integrating them into advanced neural-symbolic cognitive systems or by extending them with corresponding neural components.</p><h3>Neural-Symbolic Synergy</h3><p>Native interoperability of LLMs and Hyperon requires that they should speak the same language, namely MeTTa for Hyperon. Then, LLMs could be considered as Atomspaces, which could be queried to retrieve results to be evaluated further both in the context of symbolic and neural Atomspaces, so neural and symbolic components would talk to each other and solve tasks in collaboration, compensating for the weaknesses of each other. Composing a prompt for an LLM and chaining it with other operations (which could be queries to knowledge graphs or semantic memory, to reasoning engines, to other LLMs, or the next query to the same LLM) will be represented and executed as MeTTa expressions. These can also be composed automatically by any of the above-mentioned components.</p><p>There are multiple ways in which this idea can be implemented and applied. At SingularityNET and <a href="https://zarqa.ai/">Zarqa</a>, we have explored a number of these. A Langchain or Guidance-like approach supposes that MeTTa is used for writing arbitrary custom scripts for prompt composition and LLM chaining and translating the output of LLMs back to MeTTa in a custom way, while also asking the LLMs to format the output in a defined style. Another approach is to use LLMs for translating natural language sentences into expressions in a specific knowledge representation, store them in the Atomspace, and perform symbolic reasoning within a particular reasoning system like PLN or NAL (the logic underlying NARS).</p><p>Both approaches can be implemented on top of a generic framework known as <a href="https://github.com/zarqa-ai/metta-motto">MeTTa-Motto</a>. For example, the PoC of the SingularityNET Platform and Marketplace Assistant was implemented in it as a set of task-specific prompt templates and scripts in MeTTa. NARS integration with LLMs using MeTTa-Motto, in turn, serves as an example of a generic Q&amp;A agent focused on a particular reasoning system in Hyperon rather than delegating problem-solving functions to LLMs.</p><p>Tighter integration between Hyperon and LLMs is being explored in a number of ways, including the fine-tuning of LLMs to be able to interpret MeTTa code and produce the correct code for the given prompt, and extending LLMs architecture to communicate with Atomspace not only via inputs and outputs, but also through attention mechanisms on intermediate levels of Transformers. Even the idea of putting LLMs inside Atomspace so the latter could use explicit knowledge and reasoning during inference is being considered as a potential step towards AGI.</p><h3>Experiential learning — ROCCA, NARS, Causal Reasoning, AIRIS</h3><p>The main purpose of OpenCog is for it to be the basis for developing intelligent agents, and our work on such agents has migrated to Hyperon in 2023. One important project in this direction is <a href="https://github.com/opencog/rocca">ROCCA</a> (Rational OpenCog Controlled Agent), which focuses on recreating experiential learning in OpenCog. Much effort this year was spent on porting fundamental components required by ROCCA from OpenCog classic to Hyperon.</p><p>These components include forward and backward chaining, PLN, and pattern mining. Amazingly, the new capabilities of Hyperon/MeTTa not only allowed us to nearly complete these ports in a relatively short time (a good portion of the effort was, in fact, spent testing and improving MeTTa), but also gave us the possibility to increase the quality and generality of these components vastly. As a result, we now have a universal chainer that is able to handle any logical system, classical and constructive mathematics, crisp and probabilistic logic, and more.</p><p>In addition, the renowned NARS experiential reasoning system has been successfully integrated into Hyperon, leveraging the powerful and innovative programmatic constructs of MeTTa. Thanks to MeTTa’s advanced features, such as built-in unification, non-determinism, and intrinsic handling of Atomspaces, this integration has led to a significantly reduced code base. Compared to previous NARS implementations, <a href="https://github.com/patham9/MeTTa-NARS">MeTTa-NARS</a> is modular and portable, facilitates easy experimentation with PLN and novel cutting-edge reasoning mechanisms, and it can run in a highly accelerated way with the <a href="https://github.com/trueagi-io/metta-morph/">MeTTa-Morph</a> MeTTa to Scheme to C compiler. Furthermore, initial LLM-based natural language input for the reasoner is supported via MeTTa-MoTTo, which translates sentences into MeTTa representations on which the reasoning component can reliably reason.</p><p>These endeavors are part of a broader initiative to consolidate the most effective elements of various systems, ROCCA, NARS, OpenPsi, and AIRIS, into a unified experiential learning component for Hyperon. What all of these systems have in common is the use of cognitive schematics of the form <strong>(precondition, operation) =&gt; consequence</strong>. These essentially causal pieces of knowledge allow the AI to develop a goal-independent understanding of its environment from both spontaneous and planned interactions with the environment. Concerning the latter, a recent addition has been the formulation of a curiosity model, enabling agents to efficiently explore their environment by actively seeking situations with the highest uncertainty in order to challenge their own causal knowledge.</p><p>This approach not only enhances learning efficiency considerably, but our initial results suggest it also surpasses common Reinforcement Learning techniques in terms of data efficiency by orders of magnitude. So far, this is being evaluated in diverse grid world scenarios, which may look relatively archaic, but can support very different interaction dynamics between grid cells and are hence able to represent a very diverse set of simulated worlds, some of which might more or less resemble various real-world situations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*hLEg7UM40A4Db0TI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*1cqc22ZpWS4mo7zu" /><figcaption><em>Caption: Planned intervention, the “right idea” emerging (left) / learning and exploiting knowledge (right)</em></figcaption></figure><p>One could argue that the notion of causality is not new, as it was studied by the ancient Greeks thousands of years ago. Furthermore, nowadays, it is studied in Animal Psychology as various animal species seem to be capable of reliable long-term planning and are able to acquire some kind of causal knowledge from observing the environment and sometimes their own kind. How specialized these abilities are might vary between animal species as this is a topic of active investigation, but the benefits of such abilities are obvious.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/0*BO7QRpeLnT7JKTz_" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*VJdOcRm28Xy7FUC3" /><figcaption><em>Caption: efficient learning in the insect world (left) / planning with water displacement in “mind” (right)</em></figcaption></figure><p>Nonetheless, AI systems that cannot only use but also learn causal knowledge in real-time are rare and have not yet had great success. With Hyperon and its sophisticated experiential reasoning components, this is about to change, and it will make AI not just more adaptive and general, but also more trustworthy, transparent, and ultimately more competent.</p><h3>The Road to AGI: Hyperon Roadmap</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TeMjYiUMLiUpnu4w" /></figure><h3>OpenCog Hyperon</h3><p>The most important milestone for Hyperon in H1 of 2024 will be the Alpha Release, which will include a MeTTa packages management and deployment system and useful packages and extensions themselves, tutorials, examples of Hyperon applications to practical use cases, including bio-AI and involving DAS and MeTTa-Motto, and AI libraries in MeTTa.</p><p>A significant milestone will be the achievement of real-world interoperability between Hyperon and the SingularityNET platform. This will incorporate a number of upgrades, including: a) implementation of the platform SDK in MeTTa, allowing the use of services as Hyperon components; b) implementation of AI-DSL as a part of MeTTa SDK, allowing its utilization in both services and clients with gradual development and adoption, and c) further improvement of the platform assistant and its integration with MeTTa SDK.</p><p>Post-Alpha release plans will focus heavily on AGI R&amp;D and the related expansion of Hyperon components. They will include a considerable extension of the Hyperon “firmware,” MeTTa, whose interpreter will be turned into a customizable inference engine, which will facilitate and speed up the implementation of forward and backward chaining, probabilistic sampling, and genetic programming in MeTTa, as well as knowledge-based inference control. Supercompilation techniques, which are planned to be implemented in the inference framework, will be made reusable by particular reasoning engines and other higher-level cognitive components under development.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5HUJzdkj9d8z1rH1" /></figure><h3>The PRIMUS Cognitive Model</h3><p>The Hyperon software framework can be adapted to implement a variety of cognitive architectures and AGI approaches. For instance, it can be used to create chat systems that answer questions on a one-off basis, theorem provers, or even cognitive architectures resembling the human mind. That said, there is a particular cognitive architecture has been at the center of OpenCog development since the beginning, namely PRIMUS (formerly known as <a href="https://wiki.opencog.org/w/CogPrime_Overview">CogPrime</a>).</p><p>PRIMUS is a flexibly defined cognitive architecture that has been centrally pursued throughout the history of the OpenCog project; it was put together in 2012 in the context of OpenCog Classic but still applies perfectly well in the Hyperon context.</p><p>This architecture has been called ”CogPrime” in various publications. Nevertheless, we believe it is essential to distinguish between OpenCog as a generic AGI R&amp;D framework, and any particular cognitive architectures that may be implemented within it.</p><p>OpenCog Hyperon as a framework has been designed in substantial part to meet the needs of the PRIMUS architecture, but there have also been other desiderata in mind, and Hyperon will be used to explore other architectures besides PRIMUS, and/or that PRIMUS will heavily evolve as hands-on AGI R&amp;D with PRIMUS in Hyperon proceeds.</p><p>Earlier this year, we initiated a comprehensive update and reevaluation of the PRIMUS cognitive architecture to take advantage of recent computational and conceptual advances. While the large picture dynamics, relying on an integrative hybrid neural-symbolic model incorporating Cognitive Synergy at its core, will remain the same, some of the internals are being rethought and retooled using new technologies.</p><p>PRIMUS will continue to incorporate subsystems for uncertain inference, including PLN and NARS, evolutionary methods such as MOSES, attention and resource allocation, motivation, goal generation, perception, action, concept formation, a host of support tools, and others. Driven by curiosity, PRIMUS will use a combination of active experimentation with, and exploration of, its environment, in conjunction with causal and temporal reasoning, to build its internal world model.</p><p>While the internals of the modules will be augmented by recent AI breakthroughs, such as LLMs, PRIMUS’ dynamics will continue to be guided by the principle of cognitive synergy. The resulting system will consist of components whose active interoperability will result in a truly powerful and continuously evolving system that is much more than the sum of all its constituent parts.</p><p>Our initial use cases for implementation will include the following:</p><ul><li><strong>Science QA</strong>: Scientific and mathematical question-answering;</li><li><strong>Neoterics</strong>: Control of virtual “AGI learner” agents in a virtual world;</li><li><strong>Mind Children</strong>: Control of a small humanoid robot for home and light industry;</li><li><strong>Bio-AI</strong>: Data analytics, question answering, and hypothesis generation regarding longevity genomics;</li><li><strong>TWIN</strong>: Control of “digital twins” of specific people holding natural language dialogues.</li></ul><p>Our aim is to maintain consistent focus among our internal teams on the core components of Hyperon PRIMUS while harnessing the diversity and innovation of the global SingularityNET and OSS communities to contribute and experiment, collectively pushing the bounds toward groundbreaking advancements in AGI.</p><h3>SingularityNET Platform Integration</h3><p>OpenCog was envisioned as a cognitive framework for creating meta-services orchestrating various services on the SingularityNET Platform and using them as tools for solving arbitrary tasks posed by users, thus leading toward decentralized AGI. Work on AI-DSL explored the possibility of discovering suitable services and composing them to solve the task at hand. With Hyperon approaching its Alpha Release, this initial vision will finally start materializing. The roadmap for Hyperon with Platform integration consists of the following steps:</p><ul><li>Automation of SNET SDK setup to minimize manual actions and configuration is planned (specifying the blockchain and IPFS endpoints, downloading smart contracts, compiling Protobuf descriptions of services, etc., will be hidden under the hood);</li><li>A MeTTa extension — wrapping service calls into MeTTa functions — will be implemented, so that any platform service will immediately become just a function in MeTTa and a component of Hyperon;</li><li>Protobuf service specifications have already been translated into MeTTa (and soon back) as type signatures of services as functions;</li><li>Service specifications in enriched AI-DSL format supported by MeTTa SDK will be enabled on the service provider’s side. These specifications will be translated into <a href="https://dev.singularitynet.io/docs/concepts/grpc/">gRPC</a> Protobuf or REST API for the transport-level client-service communication, but full specifications will be used via MeTTa SDK, facilitating formal verification, service communication, discovery, composition, and code generation;</li><li>AI-DSL ontology for describing and reasoning over the semantics of AI services in Hyperon will be under experiential development, ultimately leading to systems that can guide AI agent autonomous actions and interactions, providing a unique AI environment that can rapidly accelerate platform growth through creating exponential reusability for all services.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3jO3J_K5C8y_g7Wr" /></figure><p>One important immediate application of MeTTa SDK is to support the idea of the “Internet of Knowledge” (or Knowledge Layer) on the platform. Both LLM and Knowledge Graph services with proper AI-DSL descriptions will be automatically accessible in the MeTTa-Motto framework via SDK, becoming interoperable and composable. The SingularityNET Platform Assistant may become the first meta-service provider for this Knowledge Layer.</p><h3>Towards Beneficial AGI</h3><blockquote>“<em>The time to create beneficial Artificial General Intelligence (BGI) at the human level (and soon after, far beyond) is here.</em>”</blockquote><blockquote>Ben Goertzel, <a href="https://bengoertzel.substack.com/p/a-bgi-manifesto">A Beneficial AGI Manifesto</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*qpeqtklEEOAq1-ah" /></figure><p>Our mission is to create decentralized, democratic, inclusive, and beneficial Artificial General Intelligence that fosters the growth of life and materially transforms what it means to be human in a positive way.</p><p>Once AGI has been achieved, it could bring about unprecedented technological and societal advances, solving some of humanity’s most pressing problems and transforming how individuals and groups across society live, work, and interact.</p><p>One of the primary benefits will be the potential for medical breakthroughs. With AI that is as smart or smarter than humans, we can analyze vast amounts of medical data quickly and accurately. This could lead to new treatments and cures for diseases currently considered incurable.</p><p>Another benefit will be the increase in efficiency. With machines becoming smarter and better at processing information, we’ll be able to do things faster and more accurately. This could lead to a massive boost in productivity for businesses and individuals alike.</p><p>Additionally, the increased intelligence of machines could lead to better decision-making in several fields, from finance to politics. Machines may be able to analyze data and make predictions that humans might not be able to make, leading to better outcomes for everyone.</p><p>Similar to how advanced AI surpasses humans in playing chess and Go, AGI will go beyond human capabilities in scientific discovery and technological innovations, leading to a disruptive transformation of our civilization.</p><p>On the other hand, the rapid progress of AI has led to concerns about safety, ethics, and job losses. In early 2023, leading AI voices like Elon Musk, Stuart Russell, and Yoshua Bengio signed a letter calling for a ‘pause’ of AI training due to the potential risks to society and humanity, precipitating a sci-fi conflict between people and machines. Others voiced their worries that advanced AI will cause widespread unemployment by automating cognitive tasks that could previously be done only by people.</p><p>Although we cannot predict what will happen, we can bias the odds in favor of a beneficial AGI and Singularity by developing and governing transparent and interpretable AI and human-level AI systems following an open, decentralized approach that does not serve only a select few.</p><p>This is a future that we at SingularityNET believe in. With the Alpha Release of Hyperon, we will be one step closer to making this a reality. We will continue down this path in the year ahead, looking to scale Hyperon and apply it to real-world use cases while making the development process as seamless as possible for projects and the open-source community.</p><p>Stay tuned for more AGI R&amp;D updates and the latest technical updates on Hyperon Alpha, PRIMUS, and our AGI strategy as it unfolds. With opportunities like hackathons and other developer outreach initiatives on the horizon, the doors will open wide for all who wish to join the OpenCog community and contribute hands-on to the advancement of Hyperon.</p><p>We want to acknowledge everyone who contributed to this report from within the SingularityNET Foundation, our close partners, and the wider OpenCog community: Ben Goertzel, Matthew Ikle, Alexey Potapov, Andre Luiz de Senna, Nil Geisweiller, Sergey Shalyapin, Vita Potapova, Lucius Greg Meredith, Patrick Hammer, Janet Adams, and Khellar Crawford.</p><h3>About SingularityNET</h3><p>SingularityNET is a decentralized Platform and Marketplace for Artificial Intelligence (AI) services founded by Dr. Ben Goertzel with the mission of creating a decentralized, democratic, inclusive, and beneficial Artificial General Intelligence (AGI).</p><ul><li>Our <a href="https://beta.singularitynet.io/">Platform</a>, where anyone can develop, share, and monetize AI algorithms, models, and data.</li><li><a href="https://singularitynet.io/technology/#opencog-hyperon">OpenCog Hyperon</a>, our premier neural-symbolic AGI Framework, will be a core service for the next wave of AI innovation.</li><li>Our <a href="https://singularitynet.io/ecosystem/">Ecosystem</a>, developing advanced AI solutions across market verticals to revolutionize industries.</li></ul><h3>Stay Up to Date With the Latest News, Follow Us on:</h3><ul><li>Join our <a href="https://discord.gg/snet">Discord</a></li><li>Follow us on <a href="https://social.mindplex.ai/@SingularityNET">Mindplex Social</a></li><li>Join our <a href="https://t.me/singularitynet">Main Telegram Channel</a></li><li>Subscribe to our Telegram <a href="https://t.me/snetann">Announcement Channel</a></li><li>Visit our <a href="https://singularitynet.io/">Website</a></li><li>Follow us on <a href="https://twitter.com/singularitynet">Twitter</a> and <a href="https://www.facebook.com/singularityNET.io">Facebook</a></li><li>Sign up for our <a href="http://eepurl.com/dA8ZGb">Newsletter</a></li><li>Explore our <a href="https://singularitynet.io/jobs">Jobs Page</a> → We’re hiring.</li><li>SingularityNET <a href="https://calendar.google.com/calendar/u/0?cid=c2luZ3VsYXJpdHluZXRhbWJhc3NhZG9yc0BnbWFpbC5jb20">Community Events Calendar Link</a> — Stay current on Community, Ambassador, and Deep Fund Events!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66a266c87f8c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/singularitynets-progress-towards-beneficial-general-intelligence-bgi-66a266c87f8c">SingularityNET’s Progress Towards Beneficial General Intelligence (BGI)</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Voyager for Minecraft Under the Hood]]></title>
            <link>https://medium.com/trueagi/voyager-for-minecraft-under-the-hood-3e6cc7e3cb25?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e6cc7e3cb25</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[minecraft]]></category>
            <category><![CDATA[gpt-4]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Fri, 07 Jul 2023 19:07:50 GMT</pubDate>
            <atom:updated>2023-07-10T11:22:18.096Z</atom:updated>
            <content:encoded><![CDATA[<h4>An overview of Voyager Minecraft AI agent</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h65biv-FrtHx-PuARuIwOA.png" /></figure><h3>Introduction</h3><p>In the previous posts we introduced prototypes of our <a href="https://blog.singularitynet.io/towards-general-purpose-minecraft-ai-agents-41fe415d6dd">goal-oriented and exploring agents</a> and <a href="https://blog.singularitynet.io/toward-general-purpose-minecraft-agents-part-2-limitations-of-imperative-algorithms-d60926ba878d">discussed limitations of imperative agents</a>.</p><p>In this post, we analyze capabilities and behavior of <a href="https://github.com/MineDojo/Voyager/">Voyager</a>, which is a GPT-4-powered agent capable of exploratory behavior and achieving such goals as acquiring a diamond.</p><h3>A Hgh-Level Overview of Voyager</h3><p>Voyager uses explicit symbolic representation of its goals and it has a library of skills programmatically implemented as pieces of code. It infers what skills to use to achieve goals or to satisfy conditions of applying other skills. Usage of information about the Minecraft world to achieve explicit goals via subsymbolic skills is similar in general to our agents much more than to end-to-end reinforcement learning.</p><p>The difference is that Voyager uses GPT-4 both to learn new skills and to orchestrate them that sounds quite advanced. While our agents also utilize machine learning for training the vision subsystem and some basic motor skills, they don’t generate brand new skills. They also use quite a limited knowledge base, while GPT-4 has vast knowledge about Minecraft world including not only game rules, receipts, information about drops from mining, etc., but also tricks, techniques, and good practices from different tutorials, which discovery is based on extensive experience.</p><p>It should also be noted that Voyager uses <a href="https://github.com/PrismarineJS/mineflayer">Mineflayer</a>, which has quite high-level path-finding functions, as well as own additional handcrafted control primitives. Thus, both in terms of skills and prior knowledge, it is very far from learning from scratch. But while the latter is interesting in context of certain research, such usage of GPT-4 can be justified from the utility standpoint. As we stated in the mentioned blog posts, Minecraft is complex enough and any means (which human players don’t consider to be too cheaty) of achieving good results in it are fair.</p><h3>Digging Deeper</h3><p>First of all, let’s note that learning a library of skills by Voyager is an expensive process, which requires a lot of calls to GPT-4 to generate valid code for useful skills (and in fact, GPT-3.5 was initially used for a considerable part of calls during training to reduce the cost).</p><p>Let’s consider what is learned on the following example (see <a href="https://github.com/MineDojo/Voyager/tree/main/skill_library">the library of pretrained skills</a>).</p><pre>async function mineFiveCoalOres(bot) {<br>  // Equip the wooden pickaxe<br>  const woodenPickaxe = bot.inventory.findInventoryItem(mcData.itemsByName.wooden_pickaxe.id);<br>  await bot.equip(woodenPickaxe, &quot;hand&quot;);<br><br>  // Find 5 coal_ore blocks<br>  const coalOres = await exploreUntil(bot, new Vec3(1, 0, 1), 60, () =&gt; {<br>    const coalOres = bot.findBlocks({<br>      matching: block =&gt; block.name === &quot;coal_ore&quot;,<br>      maxDistance: 32,<br>      count: 5<br>    });<br>    return coalOres.length &gt;= 5 ? coalOres : null;<br>  });<br>  if (!coalOres) {<br>    bot.chat(&quot;Could not find enough coal ores.&quot;);<br>    return;<br>  }<br><br>  // Mine the 5 coal_ore blocks<br>  await mineBlock(bot, &quot;coal_ore&quot;, 5);<br>  bot.chat(&quot;5 coal ores mined.&quot;);<br>}</pre><p>Here, the main function is findBlocks from Mineflayer (and findInventoryItem as well), and exploreUntil and mineBlock are functions from hand-coded control primitives of Voyager, which wrap pathfinder, collectBlock, and other utilities from Mineflayer. While the code of mineFiveCoalOres is pretty lengthy, it simply says “Find 5 coal ore blocks, mine and collect them” in a purely imperative way.</p><p><a href="https://blog.singularitynet.io/toward-general-purpose-minecraft-agents-part-2-limitations-of-imperative-algorithms-d60926ba878d">As we discussed</a>, there are different problems with the imperative approach. For example, the code requires creating a wooden pickaxe, even if the agent has a stone pickaxe, which usage might typically be more appropriate. Reasoning based on declarative knowledge would not require to indicate what tool should be used in this particular skill. A piece of knowledge that coal ore can be mined with any pickaxe is enough and can be used in any other skill or reasoning context. This is the strength of modularity and compositionality of knowledge.</p><p>Let’s explore the list of skills in the library: collectBamboo, collectFiveCactusBlocks, … cookPorkchops, cookSevenMutton, … craftBucket, craftChest, craftIronAxe, (and huge number of other crafting skills), equipIronSword, …mineFiveCoalOres, mineFiveIronOres, … smeltFiveRawIron, … One skill that sounds more interesting is fillBucketWithWater, but it is also a pretty straightforward wrapper of exploreUntil, findBlock, pathfinder, etc. The main question is — do we really need all these “skills”? An agent capable of declarative reasoning can figure out on fly how to do any of these tasks represented as goals without expensive training, search, or huge tensor calculations. It should also be noted that a lot of examples of skills (i.e., pieces of code) are fed to GPT-4 in order to make GPT-4 capable of writing similar skills.</p><p>Another major issue with competing all these tasks via stand-alone imperative skills is that execution of each of them is blocking. Voyager doesn’t reason, plan and replan at runtime taking the current situation into account. Humans possess much finer-grained symbolic control over motor skills. If the agent is executing mineFiveCoalOres in context of larger imperative skill of crafting iron pickaxe for getting a diamond and runs near a diamond item lying on the ground, it will just ignore this diamond. Such an imperative skill will not ever try to pick a diamond before mining diamond ore if such the possibility is not explicitly coded. This behavior looks not too intelligent, but does it matter if Voyager can acquire a diamond?</p><h3>Field Trials</h3><p>Unexpected situations leading to impasses appear more frequently than that leading to shortcuts, and imperative skills are prone to getting stuck, and one can wonder how Voyager overcomes this. Of course, Voyager doesn’t try to come up with exploreUntil function by itself, and uses a polished handcrafted code. Otherwise, it would get stuck too often. It also executes skills for a limited amount of time, so it doesn’t stay stuck forever. However, such cases are not infrequent. For example, Voyager got stuck for almost 10 minutes even using the teleport cheat (for local movement) in our third run.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZhCKEE6frxh30_hjpXf0IA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m9hm-hB9P-WLx3vsyH_KsA.png" /><figcaption>Voyager got stuck for 10 minutes even using the teleport cheat</figcaption></figure><p>It also appears that Voyager uses findBlocks with maxDistance=32 meaning that it sees through all other blocks and can “notice” coal, iron or diamond ore at 32 blocks distance, so it doesn’t need to search for blocks, but goes directly to them with the use of Mineflayer’s pathfinder. There is a chance of the block to be not found, and Voyager relocates to make a try in a different place, but this is also hand-coded.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FihIc_4xQDIs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DihIc_4xQDIs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FihIc_4xQDIs%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ab88c30aeaec400c337ab895c2d5c01/href">https://medium.com/media/2ab88c30aeaec400c337ab895c2d5c01/href</a></iframe><p>If we allow our agent to “notice” iron and diamond ore (but not other blocks) similar to findBlocks without teleport and other cheats, it will be able to acquire a diamond faster than Voyager.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FwQQsSnpGOug%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DwQQsSnpGOug&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FwQQsSnpGOug%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1deca597850cc75c7a7edf2eb038353/href">https://medium.com/media/a1deca597850cc75c7a7edf2eb038353/href</a></iframe><p>Eventually, is acquiring a diamond by Voyager a considerable achievement? We would say — not really. It is not practical at the moment. Voyager pauses the Minecraft server and spends an order of magnitude more time on thinking that on playing the game itself. And it also costs money for GPT-4 API calls. Its training is much more costly than writing a better skill library manually (especially taking into account that examples of skills are written manually), and still its behavior is far from perfect even with cheats. Its architecture doesn’t seem like a step towards AGI as well. It still has its merit as an example of:</p><ul><li>Usage of information possesses by GPT-4 about specific domain;</li><li>A capability of GPT-4 to write programs with calls to custom libraries described via prompts;</li><li>A possibility of such usage of GPT-4 that connects domain knowledge to program code.</li></ul><p>It would be interesting if GPT-4 could make a real contribution as a part of neural-symbolic architecture with declarative knowledge and reasoning component.</p><blockquote>Special thanks to:</blockquote><ul><li><a href="https://github.com/astroseger">Sergey Rodionov</a> for testing Voyager and preparing the videos;</li><li><a href="https://github.com/noskill">Anatoly Belikov</a> for developing and maintaining <a href="https://medium.com/trueagi/vereya-a-minecraft-mod-for-game-virtual-assistants-and-ai-agents-4ca1b0bc1303">Vereya mod</a>;</li><li><a href="https://github.com/DaddyWesker">Innokentiy Zhdanov</a> for extending functionality of our agent and recording its video.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e6cc7e3cb25" width="1" height="1" alt=""><hr><p><a href="https://medium.com/trueagi/voyager-for-minecraft-under-the-hood-3e6cc7e3cb25">Voyager for Minecraft Under the Hood</a> was originally published in <a href="https://medium.com/trueagi">TrueAGI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Toward General-Purpose Minecraft Agents, Part 2: Limitations of Imperative Algorithms]]></title>
            <link>https://medium.com/singularitynet/toward-general-purpose-minecraft-agents-part-2-limitations-of-imperative-algorithms-d60926ba878d?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/d60926ba878d</guid>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[agi]]></category>
            <category><![CDATA[minecraft]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 06:39:19 GMT</pubDate>
            <atom:updated>2022-08-05T06:39:19.315Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IM5OwMnuiMN5FblKvFHgNw.png" /></figure><p><em>In </em><a href="https://blog.singularitynet.io/towards-general-purpose-minecraft-ai-agents-41fe415d6dd"><em>Part 1</em></a><em>, we described the task of building Minecraft AI agents with open-ended behavior capable of achieving arbitrary goals to use as a testbed for AGI development. As mentioned, attempts to solve a particular problem frequently do not lead to progress towards AGI but instead lead to focusing on domain-specific heuristics and solutions. If a goal or task is narrowly defined, narrow solutions can be made that are more efficient than general solutions (as long as they correspond to the goal); and no progress toward broad AI will be achieved.</em></p><p><em>Here in Part 2, we will explore why an AGI-ish Minecraft agent is valuable, what problems it uniquely solves, and why it is valuable for solving complex real-world problems. We will dive into the following areas:</em></p><ul><li><em>What problems are encountered by narrow AI solutions?</em></li><li><em>What is AGI-ish about Minecraft as a testbed for AI agents?</em></li><li><em>What are the ways that imperative programming and reinforcement learning both create insufficient solutions for novel and complex problems?</em></li><li><em>And an exploration into the practicality and efficiency of AGI-ish agents for effective novel problem solving, as demonstrated in Minecraft</em></li></ul><h3>Introduction</h3><p>The inability of proto-AGI systems to outperform specialized solutions is very natural. This inability doesn’t necessarily imply that the design of such systems is flawed or unnecessary. But how can one tell apart a flawed design from a good but incomplete solution? Why is AGI needed if narrow solutions are more efficient?</p><p>The answer is that we need to take into account both the efficiency of solutions themselves and also the human efforts and resources spent on creating these solutions. Creating one narrow solution to one narrow goal is simpler and more efficient than creating a generally intelligent system; but creating a robust, generally intelligent system will solve many narrow goals — an efficiency over time and effort.</p><blockquote>We want to show that even though what we have developed so far is not a full AGI, introducing some AGI-ish features allows achieving some forms of behavior practically unachievable otherwise.</blockquote><p>Ultimately, usage of AGI technologies will become the only practical route, in the same sense as deep learning is now generally more practical than feature engineering.</p><p>What approach would be practical for creating general-purpose Minecraft agents? The application of deep learning is not practical at the moment, as it is a data and training-intensive approach. <a href="https://minerl.io/">Collecting tens of millions of frames</a> of human playing and training deep neural networks on them requires substantial human and machine resources. And the result is agents capable of solving only a few predefined tasks in restricted conditions — not very impressive. Of course, these results are interesting from the deep RL and imitation learning standpoints but not practical for broader applications, and not scalable to highly complex situations.</p><p>One interesting direction for expanding the intelligence and capability of our agent is to expand beyond video input. Such an agent would use observations from ray and grid, available in <a href="https://github.com/microsoft/malmo">Malmo</a> Minecraft mod, and provide ground truth information on blocks and entities. Programming a useful general-purpose agent directly would then be the most practical approach. Even if a generally capable agent is not created, the work and the results will illustrate what is AGI-ish about this task — helping us refine our principles of AGI.</p><h3>Algorithms and Complexity</h3><p>Let us try to approach the creation of an agent naively. The most straightforward method is to describe our own actions in Minecraft to the computer in terms of algorithms of behavior. When teachers define what an “algorithm” is, the traditional definition is “a finite sequence of rigorous, well-defined instructions.” While this definition is not wrong, it can be interpreted too simplistically.</p><p>In the case of a robot, one may identify “instructions” with such motion commands as “go straight,” “turn right,” etc. The next step would be to condition these commands over sensor readings and internal states and add loops. This is precisely how small children are taught to program Lego robots in Scratch. A “finite sequence of instructions” can contain loops, conditions, variable assignments, arithmetic operations, and random choices and can unfold into arbitrarily complex sequences of “mental” operations — quite complex. Yet, for the layman, the definition can still sound like “just a sequence of commands,” which are sent to motors and tell the robot what to do — simple and straightforward.</p><p>Nevertheless, this imperative programming style is also natural for creating basic Minecraft agents which can do something useful — to a point.</p><h3>Simplest Algorithms — Imperative Programming</h3><p>Running is a simple activity in Minecraft. You don’t need to coordinate a lot of motors like a real-world robot — you just need to send the command “run.” With ground truth information about adjacent blocks, it is also simple to mine resources of interest. It is therefore tempting to describe to the agent what to do in a sequence of actions — find a tree, approach it, cut some wood, craft the wooden pickaxe, dig down at a certain angle, mine some stone, etc. Each of these actions can be detailed into concrete, straightforward algorithms. Searching for a tree is as simple as running and scanning. This would not in any way be considered AGI or even AI. But this would not matter if the task is simply to create a useful agent by any means.</p><p>However, this approach to creating agents encounters issues even in simplified settings. While the agent is running, it can encounter a lava lake. We have to foresee this and describe to the agent what to do in this situation. The agent can turn away or try to get around the lava lake. Just turning away from any obstacle could lead to further undesirable actions — the agent could get caught in a cycle of turning away from one obstacle to another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5pNUZsaUu9DqFIv4NDZa2w.png" /><figcaption>Imperatively Programmed Agent encounters a lava lake, and can only make simplistic decisions about survival — if lava-lake handling has been encoded at all</figcaption></figure><p>This is just one of many examples where the environment can thwart imperative programmed agents:</p><ul><li>If a water lake obstacle is encountered, it might be preferable to jump into it. But there can be difficulty getting out if the shore is high. While this is solvable, the agent can approach its target (e.g., a tree) while still being in the water and start cutting it, which may result in drowning or the inability to attack one block long enough to destroy it.</li><li>While digging diagonally, the agent can encounter water, which will start flowing, and the agent can be caught in the loop of moving forward and trying to dig but being carried back by the water.</li></ul><p>The resulting behavior looks somewhat like animal instincts applied when conditions of their applicability are not satisfied. Although simple time constraints can generally break infinite loops, this behavior will still be inefficient.</p><p>Of course, the algorithms can be improved, making them reasonably reliable for the Minecraft flat world. However, if we switch to the default world of Minecraft, there will be too many unforeseen situations. It is possible to handle all of them explicitly, in an imperative way, but it is practically infeasible. There are just too many factors, and they can have infinite unforeseen combinations. The agent can die by standing near a cactus — but whether it should avoid cacti or cut them may depend on other factors. Whether to go around a deep canyon, climb down, or just go somewhere else may also depend on numerous factors. Manual coding of reactions to all possible combinations of these factors, and all the variety of possible contexts, is highly problematic.</p><blockquote>The algorithm can be improved, but there are always some unaccounted cases.</blockquote><p>This type of difficulty becomes apparent when we interact with simple chatbot AIs on a website — they can answer specific limited queries, but anything outside their narrow expertise returns errors. These systems cannot handle complexity or variations and cannot work with or solve novel problems.</p><h3>Narrow AI Algorithms — Reinforcement Learning</h3><p>To replace manual case-by-case imperative coding with training, using a deep reinforcement learning (RL) model sounds reasonable, theoretically. But as was discussed previously, it doesn’t work well in practice. What is interesting to note is that such models map known situations to learned actions. While the handcrafted imperative algorithm is like an instinct, such RL models are like trained reflexes. This means that if they find themselves in a novel situation, they will behave inadequately.</p><p>The idea that intelligence manifests itself in novel situations for which no ready solution is available is an old idea in cognitive psychology. The best thing a deep RL model can do in an unknown situation is to start performing random motor commands and learn the correct way to act in similar situations by numerous repetitions. However, when the AI is motivating your self-driving car, and the novel situation is an oncoming train, “trying random actions” is hardly a satisfactory solution.</p><p>This ‘reflexive’ reaction to novel problems is even less sophisticated than the behavior of lower animals, which can detect something is wrong and start overproducing motor actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MdNg-KofROsse7UciQiqIw.png" /><figcaption>An imperatively programmed agent will never ‘learn’ not to die by touching cacti in Minecraft. A Reinforcement Learning algorithm will learn after many trials. Human-level intelligence generally only needs one repetition — a far more efficient learning approach.</figcaption></figure><p>Beginning Minecraft players may not know that cacti harm, but they will learn it at once and be able to use this experience differently depending on the context.</p><blockquote>A Reinforcement Learning algorithm may learn to avoid cacti, but it will require a lot of trials.</blockquote><p>Of course, problems of generalization, one-shot learning, etc., are studied intensively in the field of deep learning. However, while deep RL models learn imperative algorithms, they will act as reflexes, which don’t understand what is happening and just follow the instructions. They will never truly understand context, environment, and problem-solving unless their architecture is changed.</p><h3>Debugging Algorithms; or “Why AGI?”</h3><blockquote>“General Intelligence” is the ability to solve novel tasks or to deal with novel situations.</blockquote><p>Debugging hardcoded skills is similar to debugging an ordinary program that displays concrete behavior in concrete situations. Except that, in an ordinary program, we don’t expect the program to start doing anything by itself which wasn’t explicitly programmed.</p><p>Flaws in the agent’s behavior could be considered ordinary bugs to be fixed, and can in fact be treated as such for simple environments, giving the impression that this approach is practical. But the number of such “flaws” grows very rapidly for even moderately complex environments. As the environment increases in complexity, the number of situations to ‘debug’ increase even more rapidly. A distinct desire arises for the agents to somehow see for themselves when they are doing something senseless.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*paXqkbx6uzW2JTjls503hw.png" /><figcaption>An agent attempts to dig down, but does not take the nearby lake into account. The agent repeatedly attempts to move forward and mine, and is repeatedly pushed backward by water. With imperative and RL algorithms, the agent will continue to repeat this senseless action without understanding the problem.</figcaption></figure><p>This desire is obscured in the case of deep RL agents, although the problem remains that agents have no clue what they are doing. If a DNN learns an imperative algorithm, this can save us from having to handcraft this algorithm; but even a learned algorithm remains imperative.</p><p>Let us emphasize that this is not just a matter of ideology, a belief that agents should think like humans; this is a matter of practicality. A direct mapping from states and environmental conditions to optimal actions is a restricted subset of algorithms. For example, if we take an <a href="https://en.wikipedia.org/wiki/NP-completeness">NP-complete problem</a> (a problem that can take an exponential amount of time to find a resolution), such restricted algorithms cannot provide a solution to it.</p><p>These agents will be able to cache solutions for some instances of this problem discovered during training (random enumeration of actions in RL). This can be good enough for a complex but fixed task like the game “Go”. However, it scales up badly with increasing complexity, requiring vast training data; and it still cannot handle novel situations efficiently (e.g., a novel element in Go, like tweaking game board size or shape, may make a trained model act completely unsatisfactorily).</p><blockquote>Reinforcement Learning algorithms lack the skill to generalize well beyond the region of their training set or definition, even when enough information is available.</blockquote><p>So what kind of algorithm can handle complexity and open-ended tasks?</p><h3>Neural-Symbolic AI Agents for Open-Ended Tasks in Complex Environments</h3><p>Humans have long dreamed of telling the computer what to do, not how. We want to give the computer not a ready unambiguous set of instructions that it can mindlessly execute, and we don’t want it to mindlessly try random actions until it finds a good enough sequence. We want it to understand what it is doing and why.</p><p>This does not necessarily mean a guaranteed output of an unambiguous sequence of actions to achieve the task. Some trial-and-error may still be necessary. Further, if the agent constructed a precise plan, and continues executing it after something has gone wrong, this will look no better than the execution of an imperative skill in non-adequate conditions.</p><p>Nevertheless, the very possibility for an agent to infer necessary actions depending on its current goals or desires and present situation makes the agent’s behavior much more flexible. It also removes the necessity for the agent to have ready responses (either hardcoded or pre-trained) for various combinations of multiple factors.</p><p>The following video demonstrates problems encountered by imperative agents. We believe that the spirit of AGI can be better understood through their example — solving each task or problematic situation manually or by brute force is unrealistic, and preparing and annotating sufficient training data is unscalable, even within simplified virtual worlds. Overcoming these limitations in practice is aligned with making agents more AGI-ish.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F-UA_J5p_ZMs&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D-UA_J5p_ZMs&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/af5fa2d8f2bf6fe1273995df42bb8f02/href">https://medium.com/media/af5fa2d8f2bf6fe1273995df42bb8f02/href</a></iframe><p>Our agent described in the previous post has explicit goals, which can be set both by a human or by the agent itself for exploration purposes. Its behavior immediately creates a different impression than an imperative algorithm agent — it looks purposeful rather than mechanical. Of course, the ability to describe what to do is not enough for the agent to act successfully. Both “how-to” knowledge and imperative skills are needed and they can be integrated together in a neural-symbolic architecture. This combination already helps to create a more useful agent, which can autonomously explore the Minecraft world for hours; something that is difficult to achieve with other algorithms.</p><p>This is just the first step — this agent doesn’t yet have a global representation of the situation and may not notice that it is doing the same in some abstract sense. The assessment of the purposefulness and effectiveness of actions does not apply to elementary actions within low-level skills now, so the agent cannot improve its skills deliberatively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_F5mQ_REorQBdOXkbePU9A.png" /><figcaption>The agent would like to get higher, to study the leaves on the tree, but runs out of blocks to build upwards. It solves this by mining the block underneath itself, unable to understand that this solution undermines its ultimate goal. The agent doesn’t anticipate the results of its actions and compare them with reality, yet.</figcaption></figure><blockquote>An agent must anticipate the results of its actions, and compare them with reality. Introducing such a feature is essential, not only to make the agent fancier in terms of cognitive architecture-centered AGI but in order to move forward in creating a general-purpose Minecraft agent in practice.</blockquote><p>An overly-simplistic understanding of algorithms causes an impression or even belief (especially among non-programmers) that human behavior is not algorithmic. However, this impression starts fading when the algorithms are getting more and more complex and less imperative.</p><h3>More Details</h3><p>The <a href="https://agi-conf.org/2022/">AGI-22</a> conference being held August 19 — 22, 2022 will feature a <a href="https://agi-conf.org/2022/schedule/">full-day workshop</a> and a variety of talks covering the development and progress of the OpenCog Hyperon Projects.</p><p>General motivation and an early description of OpenCog Hyperon, a neuro-symbolic AGI framework for research and development, are given in the <a href="https://wiki.opencog.org/w/Hyperon">OpenCog Hyperon Page</a> on the OpenCog wiki.</p><p>See also day 2 of <a href="https://opencog.org/2020/07/virtual-opencogcon-july-15-16/">OpenCogCon</a> -2020 and The AGI-21 <a href="https://wiki.opencog.org/w/Workshop_on_Scaling_up_Neural-Symbolic_and_Integrative_AGI_Architectures">Workshop on Scaling up Neural-Symbolic and Integrative AGI Architectures</a>.</p><h3>Stay Up to Date With the Latest News, Follow SingularityNET on:</h3><ul><li>SingularityNET <a href="https://discord.com/invite/snet">Discord</a></li><li>SingularityNET <a href="https://t.me/singularitynet">Main Telegram Channel</a></li><li>SingularityNET <a href="https://t.me/snetann">Announcement Channel</a></li><li>SingularityNET <a href="https://singularitynet.io/">Website</a></li><li>SingularityNET <a href="https://twitter.com/singularity_net">Twitter</a> and <a href="https://www.facebook.com/singularityNET.io">Facebook</a></li><li>SingularityNET <a href="https://singularitynet.io/jobs">Jobs Page</a> → We’re hiring</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d60926ba878d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/toward-general-purpose-minecraft-agents-part-2-limitations-of-imperative-algorithms-d60926ba878d">Toward General-Purpose Minecraft Agents, Part 2: Limitations of Imperative Algorithms</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards General-Purpose Minecraft AI Agents]]></title>
            <link>https://medium.com/singularitynet/towards-general-purpose-minecraft-ai-agents-41fe415d6dd?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/41fe415d6dd</guid>
            <category><![CDATA[agi]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[minecraft]]></category>
            <category><![CDATA[agents]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Fri, 11 Feb 2022 10:19:41 GMT</pubDate>
            <atom:updated>2022-02-14T03:17:36.031Z</atom:updated>
            <content:encoded><![CDATA[<h4>Preliminary baseline of neuro-symbolic AI Agent achieving open-ended goals in Minecraft environment</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9czi6NzwsPe07uU7LsURdQ.png" /></figure><p>Artificial General Intelligence is a fascinating field, which promises AI systems with breadth of applicability. Both theoretical ideas and their program implementation require practical approbation to prove their viability. Earlier, OpenCog cognitive architecture was used in such applications as humanoid robots, such as <a href="https://awakening.health/">Grace the elder care robot</a> from Awakening Health, biomedical informatics and others. A novel version of OpenCog Hyperon is being designed and developed with similar applications in mind.</p><p>In this series of blog posts, we involve one more testbed for discussing, evaluating, and experimenting with our AGI concepts and design. Namely, we use Minecraft as an open-ended and complex environment which, we believe, can lead to interesting and important conclusions about promising approaches to AGI.</p><h4><strong>Measuring Advances in AGI</strong></h4><p>Evaluating incremental progress in AGI has always been tricky and remains so despite all the achievements in this area. Benchmark tasks which are too narrow force competitors to apply their human intelligence to inventing problem-specific solutions. More complex or general tasks still favor one approach to AGI over another and have a considerable domain-specific component, which incentivizes optimization of a favored AI model, rather than driving innovation of more generally intelligent systems. If the task is too complex, competition revolves around tweaking and tuning existing technologies until the next technology is invented, with a disputable contribution to progress in AGI.</p><p>For example, Natural Language Understanding (NLU) models such as ERNIE 3.0 or T5 show amazing results, which are already superhuman on SuperGLUE (General Language Understanding Evaluation). But it is inappropriate to ask if these models can play chess or could at least be integrated with, say, MuZero to discuss possible modification of the game rules. It may turn out that the latter requires completely different architectures.</p><p>Evaluating integral behavior of autonomous agents such as robots may sound more appropriate in the context of AGI. And it has its merits, indeed. However, navigation in the physical world is an important, but still domain-specific skill. Working in virtual worlds can reduce the contribution of low-level sensorimotor skills into the overall agent performance and can partly shift focus on higher-level cognitive capabilities.</p><p>End-to-end learning to play in 50+ Atari games via deep reinforcement learning (RL) without game-specific priors was very impressive (<a href="https://arxiv.org/pdf/2003.13350.pdf">DeepMind –Agent57</a>, 2020). But what we learned from this is that mastering such a reactive game with fixed goals (reward functions) doesn’t require AGI and is amenable to relatively simple models. Settings of such benchmarks and challenges favor certain classes of models, which manifest reflex-like behavior. In turn, excelling at Starcraft does require significant strategic planning, but AlphaStar achieved this only via a considerable amount of highly Starcraft-specific design.</p><p>Although solving any task which looks challenging from the current AI standpoint can teach us something, we wanted to define a challenge that does not favor too much a specific class of methods (e.g. symbolic or neural), is not solvable by domain-specific hacking, but that still allows visible incremental progress. To show general intelligence, the agent must be challenged to solve an arbitrary, distant goal in a rich environment.</p><p>Researchers interested in more open-ended, creativity-oriented and higher level reasoning focused approaches toward general intelligence have looked to the Minecraft game environment as an alternative. Minecraft (through the Malmö platform) provides a different sort of challenging environment for AI agents, one which is both high-dimensional and requires active cognitive control (not just reactive responses to local situations, but compositional long-term activities).</p><h4><strong>Minecraft environment for AI Evaluation, precedents</strong></h4><p>Using Minecraft as a testbed for AI systems is not new, although attempts to do this are not numerous. Two recent challenges should be mentioned in this regard:</p><ul><li>MarLÖ 2018 — Multi-Agent Reinforcement Learning in Minecraft Competition (an extension of the Malmo Collaborative AI Challenge);</li><li>MineRL Competition 2020 and 2021.</li></ul><p>Both competitions are biased towards reinforcement learning, but approach it differently. MarLÖ provides simplified Minecraft worlds as environments (like a fenced area of 5x5 blocks) with tasks like chasing a pig, which seems not too difficult for RL. However, the challenge is for multiple agents to collaborate in achieving the common goal by recognizing intents and strategies of each other just from their in-game behavior.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*udOazCGazI-KnUf1C-WlWw.png" /><figcaption><a href="https://marlo-ai.github.io/">MarLÖ Competition</a></figcaption></figure><p>While the challenge itself is interesting, its restrictions are not very natural. Humans learn to communicate using language in different settings, and direct communications between agents in MarLÖ are not introduced not because it would be non-AGI-ish or less beneficial for collaborative behavior, but because it doesn’t correspond specifically to subsymbolic RL methodology.</p><p>MineRL, in turn, doesn’t suppose multi-agent collaborations, but considers large Minecraft environments with a distant goal. The <a href="https://minerl.io/diamond/">diamond competition</a> consisted in acquiring a diamond, which requires first to cut some wood, then to craft wood planks, wooden pickaxe, mining cobblestone, crafting stone pickaxe, and digging deep, while avoiding lava. This goal is far from most distant in Minecraft, but deep RL agents fail to learn how to achieve it without hints. MineRL underlines that deep RL in such games as Go or StarCraft require years of play time to achieve superhuman results,which will be unachievable at all in the MineRL challenge. To workaround this problem, the competition proposes to train RL agents using records of human player walkthroughs (this is one of <a href="https://minerl.io/">the largest imitation learning datasets with <strong>over 60 million frames</strong> of recorded human player data</a>).</p><p>The agent also receives auxiliary rewards for obtaining prerequisite items in addition to a high reward for obtaining a diamond. Moreover, in the navigation subtask, additional rewards are given for approaching the provided location. That is, the agent is consequently trained to navigate, to gather one prerequisite item after another.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*XNkqZu6baG3JzBqTGvTSmA.png" /><figcaption><a href="https://minerl.io/diamond/">Diamond Competition</a></figcaption></figure><p>Although there are deep RL models that achieve the final goal, they are intensively guided to do this. They don’t learn to plan in order to achieve arbitrary distant goals; rather they merely learn to imperatively execute a very concrete sequence of steps. Also, while imitation learning is generally valuable for AGI, it is used here as an alternative to giving agents a simple symbolic description of the diamond mining task primarily because it corresponds so closely to the subsymbolic RL methodology. For a human player in the same situation, of course, a simple linguistic (symbolic) description of the task would normally be given, rather than purely evoking the task by examples.</p><p>More recently, the <a href="https://minerl.io/basalt/">BASALT competition</a> has more interesting and less formalized tasks such as “Find Cave”, “Make Waterfall”, “Create Village Animal Pen”, and “Build Village House”. Unfortunately, these are still very concrete goals. Of course, it is amazing if agents can achieve these goals in randomly generated Minecraft worlds, but they learn to imitate sequences of human actions, without understanding them. This is not too far from reactive behavior in Atari games, yet in a more complex environment. In order to train such RL agents for any other task (be it building a cave instead of finding it, or finding a waterfall instead of making it), a huge amount of training data should be gathered first, and the agent should be retrained — obviously not an elegant or sustainable solution to complex problem solving by AI agents.</p><p>We consider Minecraft as a more interesting environment for early stage AGI systems than these prior Minecraft challenges demonstrate. We believe that the most exciting features of the Minecraft world is its openness and creativity. Our agents will explore this world freely and achieve different kinds of goals. We don’t want to restrict the wayMinecraft agents are designed and trained, what prior information they use, etc. However, we feel the Minecraft environment can be leveraged better via AI systems incorporating explicit knowledge representation and reasoning. In this way, instead of adjusting the Minecraft tasks pursued to match the limitations of current RL systems, we intend to solve more complex tasks in a Minecraft context using a neural-symbolic approach.</p><p>We are intentionally not introducing formal metrics for evaluating agents, because it is difficult in settings of our interest and will also force metric-specific optimizations, which are not interesting in AGI context. Thus, Minecraft serves as an experimentation platform (actually, one of several of them) rather than a challenge or competition.</p><h4><strong>First step towards general-purpose Minecraft agents</strong></h4><p>We are developing a Minecraft agent with open-ended behavior capable of achieving arbitrary goals — discovering new blocks, mobs, biomes and other places, crafting new items, building novel structures, collaborating with other agents. Of course, the agent capabilities are being implemented gradually, and it was natural to start with finding blocks and obtaining items like in the diamond challenge. In contrast to this challenge, however, we didn’t restrict our agent with one goal, and thus neither vanilla reinforcement learning nor imitation learning were applicable. The two main classes of goals our agent can deal with are: searching for new blocks and items, and acquiring specified items. However, there is no strict boundary between them, since such goals as “find any novel block and mine it” are also possible, and, in turn, obtaining a certain item may require free exploration.</p><p>This video demonstrates these capabilities of our preliminary agent (running in the standard Malmo AI-experimentation platform on Minecraft, which simplifies certain aspects like crafting and environment sensing):</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FUnryt6XH2FE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DUnryt6XH2FE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FUnryt6XH2FE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccda46d148e6ae7a1180ea44d5bd92b2/href">https://medium.com/media/ccda46d148e6ae7a1180ea44d5bd92b2/href</a></iframe><p>As can be seen, it has some basic exploration capabilities, so it can find new types of blocks and get new items. However, even if we focus on such open-ended intrinsically motivated behavior, we still need our agent to be able to achieve specific goals. Imagine that the agent has discovered an iron ore block and wants to mine it, but doesn’t have a stone pickaxe at the moment. Either from prior knowledge or trial-and-error it can know that mining iron ore with hands or wooden tools is insufficient. Obtaining a stone pickaxe requires achieving subgoals such as cutting wood, crafting wooden pickaxe, and mining cobblestone.</p><p>In different situations the agent may find a need for different items or for achieving different subgoals such as approaching some point or finding a biome, etc. This differs from a linear order of steps of achieving a predefined goal (such as obtaining a diamond). For a general-purpose agent, such goals can be subgoals of each other and of exploratory behavior. One can say that they should not be represented explicitly with necessity. However, multi-agent collaboration supposes that agents can request concrete things from each other. And if we consider such agents as companions of human players, then posing explicit tasks like “Bring me some coal ore” would be quite useful. It is still disputable if the agent should have an explicit interpretable internal representation of such goals, or if we should train it to achieve goals described in natural language in end-to-end black-box fashion. But at least we can agree that the capability of achieving arbitrary goals defined at runtime is useful (at least for assisting human players).</p><p>This capability (in its preliminary form) is demonstrated in the second part of the video. The agent crafts the lever, wooden door, and obtains the iron pickaxe first by achieving a few more subgoals. This result can be considered as a sort of baseline to be improved on. Although we don’t introduce metrics intentionally, we will compare different approaches as examples of this motivation task in the future blog posts.</p><h4><strong>Future Plans</strong></h4><p>SingularityNET is designed not only to be valuable now, but also to foster the emergence of increasingly powerful benevolent general intelligence. Achieving this ultimate goal requires a framework applicable to coordination of numerous AI services deployed on the platform, which may require some sort of <a href="https://blog.singularitynet.io/ai-dsl-toward-a-general-purpose-description-language-for-ai-agents-21459f691b9e">AI services language</a>.</p><p>However, coordinating skills of agents, in particular, in the Minecraft world is not too different. An AGI framework should be useful for any of these and other applications, which is the focus of <a href="https://trueagi.io/">TrueAGI</a> within the SingularityNET ecosystem. We are developing <a href="https://wiki.opencog.org/w/Hyperon">OpenCog Hyperon</a> as such a platform, and, thus, creating Minecraft agents is considered as one of the motivation tasks for it among several others. The upcoming blog posts will be devoted not only to progress in capabilities of our Minecraft agent, but also to discussion of insights about AGI design.</p><p>Join us in a conversation about advances in AI and AGI on the SingularityNET social channels:</p><ul><li>SingularityNET <a href="https://t.me/singularitynet">Main Telegram Channel</a></li><li>SingularityNET <a href="https://t.me/AGIDevelopers">AGI Developers Channel</a></li><li><a href="https://nunet.io/">S</a>ingularityNET <a href="https://discord.gg/69qFdn76">Discord</a></li><li><a href="https://nunet-io.github.io/public/NuNet_Whitepaper.pdf">S</a>ingularityNET <a href="https://singularitynet.io/">Website</a></li><li><a href="https://twitter.com/nunet_global">S</a>ingularityNET <a href="https://twitter.com/singularity_net">Twitter</a> and <a href="https://www.facebook.com/singularityNET.io">Facebook</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41fe415d6dd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/towards-general-purpose-minecraft-ai-agents-41fe415d6dd">Towards General-Purpose Minecraft AI Agents</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Making Homes Really Smart with OpenCog and SingularityNET: Part 1]]></title>
            <link>https://medium.com/singularitynet/making-homes-really-smart-with-opencog-and-singularitynet-part-1-66e22a3a8407?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/66e22a3a8407</guid>
            <category><![CDATA[smart-home]]></category>
            <category><![CDATA[cognitive-computing]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Mon, 23 Mar 2020 19:34:08 GMT</pubDate>
            <atom:updated>2020-03-23T19:44:09.410Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HOSFD9iApReFJTpz6owkHQ.png" /></figure><h3>What would make homes really smart?</h3><p>The idea of smart homes is far from new, and tech geeks have been trying it for decades. Nowadays, many companies produce various smart home devices abundantly present in the mass market. Many smart home integrators exist, who help users designing and installing whole-house projects bringing all these smart devices together.</p><p>Manufacturing companies are doing their best to make their solutions work out-of-the-box, developing their own ecosystem of devices being managed by proprietary smart home applications. Tech giants like Google, Apple, Amazon, and others push forward their virtual assistants to interact with both third-party and own smart home devices. In most cases, smart homes rarely meet end-user expectations and usually turn out to be expensive toys with few really useful functions.</p><p>Home automation software offers some level of solution to this problem by allowing manual scripting and/or GUI for sending commands to devices and displaying information. Virtual assistants add voice interfaces to this, which is very useful in many situations and creates a somewhat deceptive impression of intelligence. One may argue that they add much more intelligence, but if you don’t want to get annoyed by them, you shouldn’t expect them to be smart. Much better user experience can be achieved, if one considers them as a voice-controlled analogue of GUI to the connected devices and pre-programmed scripts. Virtual assistants do their best to disambiguate a vague natural language input to figure out what menu item to choose and what values to fill in the slots of a certain skill service.</p><p>To see what the skill-oriented approach lacks, let’s consider the following query: “Turn on the light”. It is so simple. What can go wrong?</p><ul><li>If the light is already on, but smart home sends a command to the device anyway, it may seem not a big deal if the user is not aware of this. But still, it will indicate that smart home acts not too intelligently. Also, it would be better if smart home says “The light is already on” instead of silently doing nothing because there can be a real reason behind this useless request.</li><li>The light is off, and the command to the device is sent, but the light doesn’t turn on.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5MhIQ0G9_KiGam9pBO1omg.jpeg" /></figure><p>Of course, both cases are not difficult to take into account, but this should not take a form of ad hoc solutions for each device separately. In fact, anticipating the outcome of own actions is one of the general features of intelligence.</p><ul><li>Then, what light should be turned on? There can be several lamps in the home, but only one of them can be off. The user could mention a concrete location in the previous phrase (e.g. “Is it dark in the kitchen?”). Without any context, the users most typically want to turn on the light in the room, where they are. Something can be handled via dialogue-based slot-filling that takes the dialogue context into account. Other cases can be hand-coded on the skill side. However, it would be difficult to manually cover all the situations especially for new third-party devices with limited interaction between skills. What we really expect from smart homes is to have some common sense that can be transferred to new devices and situations without re-implementing it from scratch each time.</li><li>A not smart lamp can be connected to electricity through a smart socket, but an ordinary user will still prefer to say “Turn the light on” instead of “Switch the socket on”. What smart home should do is not the blind command execution but the fulfilment of users’ goals by achieving the desired state of the environment. This can be done via reasoning, in the course of which the sequence of actions leading from the current state to the desired state can be inferred.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ocDdFRg-VUFLEWda-BilZw.jpeg" /></figure><p>The user may want the room to be dark. This may require not only turning off the lamps but also pulling the curtains. These two actions can be united in a hand-coded scenario. But this should not really be necessary if a smart home can reason. The reasoning is compositional. Scenarios are not. If the smart home knows that bright light wakes humans up, and it is undesirable to wake up humans without necessity, then the smart home can postpone the execution of the user command to turn the light on if it knows that someone is sleeping (and ask the user for confirmation)… or can even figure out how to fulfil the request to wake up the user at night by turning the lights on without being specially programmed for this type of request! This may really look smart, while the ability to do only what the system is programmed for has never been considered as intelligent behaviour.</p><p>Thus, what smart homes need (and what they are lacking) are knowledge, common sense, and reasoning. More advanced features would include episodic memory and learning new pieces of knowledge.</p><p>Traditional symbolic systems are focused on knowledge representation and reasoning, but they typically manipulate symbols, which lack semantic grounding. At the same time, the reasoning for smart homes should be substantially based on the physical reality behind the symbols. Either a lamp is on or off is a question of not logical truth, but consistency with reality. Thus, what is needed is <em>grounded reasoning</em>, which we studied in our previous <a href="https://blog.singularitynet.io/towards-a-practical-neural-symbolic-framework-240bff77ce4a">blog posts</a> with the use of the OpenCog cognitive architecture on the example of the Visual Question Answering task. Can it be used here as well? In this series of blog posts, we will try answering this question.</p><h3>Integrating OpenCog and Home Assistant</h3><p>First of all, OpenCog should have means to communicate with smart home devices. There are different ways to do this, but since we need to send low-level messages to and receive them from various devices without excessive interference and restrictions, and want to do knowledge representation and reasoning locally, and, at the same time, we do not want to rely on proprietary home automation solutions, especially, running in the cloud, which require sending private information out, the ideal solution for us is to build on top of open-source locally deployable home automation platforms. We found convenient to use <a href="http://www.home-assistant.io/">Home Assistant</a> (hass), although other similar platforms could be equally good (our implementation of the OpenCog and hass integration can be found <a href="https://github.com/singnet/coghome/">here</a>).</p><p>Installing hass is fairly simple. One way convenient for the Python users would be python3 -m pip install homeassistant or just pip install homeassistant depending on the environment (that should typically just work, but one may need to create a python or conda environment for hass with an appropriate version of Python and in some rare cases manually install some missing dependencies like aiohttp_cors). Another way is to use a docker container (see <a href="https://www.home-assistant.io/docs/installation/">the guide</a> for more details if necessary). After installation, one needs to run hass --open-ui (note that the first run can take a few minutes before the web interface appears) and add necessary devices to hass.</p><p>Installing OpenCog is <a href="https://github.com/singnet/atomspace#building-and-installing">more involved</a>, but there is always an option to <a href="https://github.com/singnet/coghome/blob/master/examples/run_in_docker.sh">use docker</a>. Let’s assume that both hass and OpenCog are set up and running either on the same or different machines.</p><p>The way to integrate OpenCog with hass can also be different. For example, one can receive and send messages using the hass event bus directly. However, we found using the WebSocket API more convenient (it requires websockets package, which can be installed via python3 -m pip install websockets), which allows for subscribing to events, sending messages, requesting states of the connected devices, etc. while possibly running on another computer. The only additional requirement is <a href="https://www.home-assistant.io/docs/authentication/">authentication</a>. The client (used by OpenCog) to communicate with hass is <a href="https://github.com/singnet/coghome/blob/master/coghome/hass_communicator.py">fairly simple</a>. To connect to hass, it requires Long-Lived Access Tokens, which can be generated using the web interface to a running Home Assistant (at the bottom of the user’s profile page). Let’s put both the token and hass WebSocket address (which will be ws://localhost:8123/api/websocket if hass is accessed from the same machine) in the <a href="https://github.com/singnet/coghome/blob/master/examples/config.cfg">configuration file</a>.</p><p>OpenCog reasons over its knowledge base stored in a hypergraph container, <a href="https://github.com/singnet/atomspace">Atomspace</a>. In order to reason over not just abstract symbols, but over the real world in its current state, OpenCog implements grounded Atoms. For example, grounded predicates (typically used in robotics and machine perception) are those predicates whose truth-values are determined not inside the system, but by the state of the environment or some external process. Although <a href="https://wiki.opencog.org/w/GroundedPredicateNode">GroundedPredicateNode</a> is a standard type of Atoms in OpenCog and it fits well with logic-style reasoning, more recent <a href="https://github.com/singnet/atomspace/blob/master/opencog/atoms/execution/GroundedObjectNode.h">GroundedObjectNode</a>, which embeds foreign objects into Atomspace and allows executing their methods from Atomese, is technically more convenient for dealing with smart home devices.</p><p>In our implementation, the Python class <a href="https://github.com/singnet/coghome/blob/master/coghome/entity.py">Entity</a> describes entities known by hass. They can correspond to regular smart home devices or some additional entities like users, weather and sun, etc. Entity objects are supposed to be created automatically by requesting entity states from hass. In our implementation, <a href="https://github.com/singnet/coghome/blob/master/coghome/home_state.py">HomeState</a> is responsible for this: get_states message is sent to hass by HassCommunicator just after authentication and the reply message is passed to the constructor of HomeState. It also wraps created Entity objects into GroundedObjectNodes stored in the Atomspace, which then can be accessed from Atomese by their IDs (IDs of known entities are stored in a text file). Entity objects have some methods (accessible from Atomese) to get information from and send commands to the entities. For example, if we have a smart bulb with ID light.bedroom_lamp, executing (with execute_atom function) the following Atomese code (embedded in Python) will turn the bulb off:</p><pre>ApplyLink(<br>    MethodOfLink(<br>        GroundedObjectNode(&quot;light.bedroom_lamp&quot;),<br>        ConceptNode(&quot;send_simple_command&quot;)),<br>    ListLink(ConceptNode(&quot;turn_off&quot;)))</pre><p>Sending a command with parameters through Atomese to hass can be done by wrapping them into GroundedObjectNodes in the following way (only supported services for lamps in hass are turn_off, turn_on and toggle, so one needs to call turn_on service with corresponding parameters to change brightness or colour even if the lamp is already turned on):</p><pre>GroundedObjectNode(&quot;:bright&quot;, {&quot;brightness&quot;: 100})<br>GroundedObjectNode(&quot;:red&quot;, {&quot;hs_color&quot;: [0, 100]})<br>ApplyLink(<br>    MethodOfLink(<br>        GroundedObjectNode(&quot;light.bedroom_lamp&quot;),<br>        ConceptNode(&quot;send_command&quot;)),<br>    ListLink(ConceptNode(&quot;turn_on&quot;),<br>             ListLink(GroundedObjectNode(&quot;:bright&quot;),<br>                      GroundedObjectNode(&quot;:red&quot;))))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BKiXcyEvVASBmC6PvGfqBw.jpeg" /></figure><p>Similarly, get_state_cn method returns the current state of the entity (e.g. if the bulb is on or off) as a ConceptNode, which can be further used in other Atomese expressions.</p><p>Since we want to react to events, we introduce one more class <a href="https://github.com/singnet/coghome/blob/master/coghome/event.py">Event</a> and create GroundedObjectNode(&quot;current_event&quot;), which refers to the corresponding object. Its methods get_type_cn and get_data_cn allow us accessing the event content from Atomese, e.g.</p><pre>EqualLink(<br>    ApplyLink(<br>        MethodOfLink(<br>            GroundedObjectNode(&quot;current_event&quot;),<br>            ConceptNode(&quot;get_data_cn&quot;)),<br>        ListLink(ConceptNode(&quot;click_type&quot;))),<br>    ConceptNode(&quot;double&quot;))</pre><p>will be evaluated to true if the event is a double click.</p><h3>Home Automation in Atomese</h3><p>Combining conditions and actions in <a href="https://wiki.opencog.org/w/SatisfactionLink_and_BindLink">BindLink</a> will yield basic home automation in Atomese</p><pre>BindLink(<br>    EqualLink(<br>        ApplyLink(<br>            MethodOfLink(<br>                GroundedObjectNode(&quot;current_event&quot;),<br>                ConceptNode(&quot;get_data_cn&quot;)),<br>            ListLink(ConceptNode(&quot;click_type&quot;))),<br>        ConceptNode(&quot;double&quot;))<br>    ApplyLink(<br>        MethodOfLink(<br>            GroundedObjectNode(&quot;light.bedroom_lamp&quot;),<br>            ConceptNode(&quot;send_simple_command&quot;)),<br>        ListLink(ConceptNode(&quot;turn_off&quot;))))</pre><p>— turn the bulb off if a button is double-clicked. More conditions can be added using AndLink to check if the desirable button is clicked and so on.</p><p>This still doesn’t differ from automations and scripts supported by Home Assistant. The latter also supports locations or areas, which can be assigned to devices and other entities. Knowledge about locations can naturally be represented in Atomese and used in BindLinks. Ordinary predicates can be used for this purpose, e.g.</p><pre>EvaluationLink(<br>    PredicateNode(&quot;placed-in&quot;),<br>    ListLink(<br>        GroundedObjectNode(&quot;light.bedroom_lamp&quot;),<br>        ConceptNode(&quot;bedroom&quot;)))</pre><p>BindLinks in Atomese are not mere if-then rules. They can include unknowns (variables) and are executed by Pattern Matcher, which tries to find if any subgraph in the knowledge base can be matched against the query. For example, executing the following query will (unconditionally) turn off all light devices.</p><pre>BindLink(<br>    EvaluationLink(<br>        PredicateNode(&quot;has_domain&quot;),<br>        ListLink(VariableNode(&quot;$l&quot;), ConceptNode(&quot;light&quot;))),<br>    ApplyLink(<br>        MethodOfLink(VariableNode(&quot;$l&quot;),<br>                     ConceptNode(&quot;send_simple_command&quot;)),<br>        ListLink(ConceptNode(&quot;turn_off&quot;))))</pre><p>We can also modify our previous rule, which turns off the lamp with a known ID on any double-click event. For example, the following modification says that all smart lamps in any area should be turned off if any smart home button in the same area is double-clicked (complete example can be found in the <a href="https://github.com/singnet/coghome/tree/master/examples">repository</a>).</p><pre>BindLink(<br>    AndLink(<br>        InheritanceLink(VariableNode(&quot;$l&quot;), ConceptNode(&quot;lamp&quot;)),<br>        InheritanceLink(VariableNode(&quot;$b&quot;), ConceptNode(&quot;button&quot;)),<br>        EvaluationLink(<br>            PredicateNode(&quot;placed-in&quot;),<br>            ListLink(VariableNode(&quot;$l&quot;), VariableNode(&quot;$room&quot;)),<br>        EvaluationLink(<br>            PredicateNode(&quot;placed-in&quot;),<br>            ListLink(VariableNode(&quot;$b&quot;), VariableNode(&quot;$room&quot;)),<br>        ...),<br>    ApplyLink(<br>        MethodOfLink(<br>            VariableNode(&quot;$l&quot;),<br>            ConceptNode(&quot;send_simple_command&quot;)),<br>        ListLink(ConceptNode(&quot;turn_off&quot;))))</pre><p>It should be noted that such rules can be rather general, and one can write down a number of such rules applicable to any house, which configuration will be reduced to specifying some declarative knowledge about devices and their connections. For example, this rule could rely on a predicate “connected”, and toggle any device $d when any button $b is pressed if there is the fact in the knowledge base that $d is connected to $b.</p><p>Chaining of such rules in order to find actions leading from the current state to the desired state is the crux of reasoning.</p><h3>What’s Next</h3><p>In subsequent posts, we will develop the topic of reasoning for smart homes on the base of OpenCog, consider the problem of creating a natural language interface to such a cognitive home using contemporary NLP DNNs and probabilistic generative models, describe how to use SingularityNET services to make a home smarter while remaining the master of own home.</p><h3>Join Us</h3><p>SingularityNET plans to reinforce and expand its collaborations to shape the coming AI Singularity into a positive one, for all. To read more about our recent news click <a href="https://blog.singularitynet.io/">here</a>.</p><p>And if you have an idea for AI tools or services you’d like to see appear on the platform, you can request them on the <a href="http://rfai.singularitynet.io/">Request for AI Portal</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*VTVsWc-_rRLRd9cR" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66e22a3a8407" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/making-homes-really-smart-with-opencog-and-singularitynet-part-1-66e22a3a8407">Making Homes Really Smart with OpenCog and SingularityNET: Part 1</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards a Practical Neural-Symbolic Framework]]></title>
            <link>https://medium.com/singularitynet/towards-a-practical-neural-symbolic-framework-240bff77ce4a?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/240bff77ce4a</guid>
            <category><![CDATA[deep-neural-networks]]></category>
            <category><![CDATA[neural-symbolic-systems]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[knowledge-representation]]></category>
            <category><![CDATA[cognitive-architecture]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Mon, 25 Nov 2019 09:46:14 GMT</pubDate>
            <atom:updated>2019-11-25T09:46:14.908Z</atom:updated>
            <content:encoded><![CDATA[<h3>Towards a Practical Neural-Symbolic Framework.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DZwsA8y8T_-llLxf8R3Zjg.jpeg" /></figure><h3>The Need for Neural-Symbolic Integration</h3><p>Deep learning is still bearing fruits. However, the standard types of networks are exhausting their possibilities, and researchers seek out such extensions to the basic neural network models, which will weaken their inherent limitations. Some extensions such as <a href="https://arxiv.org/abs/1706.03762">self-attention layers</a> have enjoyed great practical success.</p><p>Remarkably, many shortcomings of neural networks mirror the advantages of symbolic systems (and vice versa). Indeed, one can note that both self-attention layers and <a href="https://arxiv.org/abs/1710.09829">capsule networks</a> are attempts to work around the notorious variable binding problem described in the <a href="https://www.semanticscholar.org/paper/Connectionism-and-Cognitive-Architecture-and-%3A-1-A-Fodor-Pylyshyn/5d0afc529e624cc43d32afc0e62f372ef90a8405">Fodor and Pylyshyn’s paper</a>, which is easily solved in symbolic systems but is very inconvenient for neural networks.</p><p>Neural networks are bad at solving compositional problems and require non-standard extensions to combat them (e.g. <a href="https://arxiv.org/abs/1511.02799">neural module networks</a> and <a href="https://arxiv.org/abs/1803.05268">their variations</a>), while compositionality is the main feature of symbolic systems.</p><p>Explicit knowledge constitutes the main content of symbolic systems, but its integration into neural networks is problematic. And yet even limited use of prior knowledge can yield important improvements in <a href="https://arxiv.org/abs/1802.05930">neural language understanding</a>, visual scene understanding (and even <a href="https://arxiv.org/abs/1612.04844">image classification</a>), etc.</p><p>Although we can see that neural networks can be extended to compensate for one missing aspect or another, this is done for each aspect independently and in a task-specific way. The very idea of the <a href="https://arxiv.org/abs/1711.03902"><strong>neural-symbolic approach</strong></a> is to utilize the strengths of both neural and symbolic paradigms to compensate for all the drawbacks of each of them at once, basically, to combine flexible learning with powerful reasoning.</p><p>An interesting approach to neural-symbolic integration is to use the same computational model to represent both neural and symbolic operations, or, more concretely, to map <a href="https://pdfs.semanticscholar.org/9e37/95d0f66caa046bf744832254318839131e75.pdf">logic-based knowledge representation and inference into neural networks</a>. On the one hand, one can claim that limitations of the neural networks are the very reason to resort to symbolic systems, and such mapping is not useful. On the other hand, the brain does consist of neurons, which are the computational substrate for symbolic reasoning also, and although artificial neurons differ from natural neurons, they can be developed further to capture the necessary properties making this mapping efficient. In particular, the works on <a href="https://arxiv.org/abs/1711.03902">Neural Symbolic Cognitive Agent</a> show the possibility to map First-Order Logic into Restricted Boltzmann Machines.</p><p>This approach is very interesting and promising, but it restricts us to the models of a certain type, leaving outside its scope a huge body of elaborated models and inference techniques from both neural and symbolic domains. Indeed, the success of deep learning is not due to one particular model, but due to the frameworks that make developing new models simple and efficient. Thus, what can be really impactful is a hybrid neural-symbolic framework that extends an existing deep learning framework with a symbolic knowledge representation and reasoning system.</p><p>Here, we present a prototype of such a framework that integrates the PyTorch deep learning library with the OpenCog cognitive architecture and discuss its utility on an example of visual reasoning.</p><h3>Problem</h3><p>As we <a href="https://blog.singularitynet.io/deep-semantic-gap-to-be-bridged-for-singularitynet-e9270d67b7ad">discussed earlier</a>, the most basic (yet frequently used) approach to hybrid neural-symbolic systems, which consists simply in running deep neural networks (DNNs) to produce symbols for subsequent symbolic reasoning, is far from enough, and cognitive feedback to control DNNs processing subsymbolic data (e.g. image) is necessary, which is lacking in the naïve hybrid systems.</p><p>This situation can be understood on an example of visual question answering (VQA). Indeed, reliable and exhaustive symbolic descriptions, which would be enough for answering questions via reasoning, cannot be extracted in a bottom-up data-driven way. Even humans analyze images in detail depending on their goals (e.g. questions). For example, are all boats on the same side of the river as bicycles and cars in the following image?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YtVwFIpnV8fm9yKiYNlrPQ.jpeg" /></figure><p>And now let us try to answer a few more questions. How many trees with green leaves were there? How many boats with humans in them were there? Most of us will need to look at the image once again. The rest will be able to recall the image itself without looking at it. But none of us will be able to answer arbitrary questions without processing visual information once again.</p><p>Pure DNN-based VQA models use attention mechanisms that alter the way how the images are processed. However, they are <a href="https://arxiv.org/abs/1712.00377">criticized</a> for overfitting to the biases in the datasets and for incapability to process more complex compositional questions.</p><p>At the same time, visually poor synthetic images with compositional questions can be dealt with quite well by naïve hybrid systems with the <a href="https://arxiv.org/abs/1810.02338">complete disentanglement</a> of vision from reasoning and language processing (which is claimed to be a feature, although we consider it as a limitation).</p><p>Apparently, both symbolic reasoning and cognitive feedback are needed to deal with both rich ambiguous natural images and compositional questions (although the study can be conducted on an example of synthetic datasets also).</p><p>As we described in our previous posts (<a href="https://blog.singularitynet.io/enabling-cognitive-visual-question-answering-a93febd454a7">this</a> and <a href="https://blog.singularitynet.io/towards-declarative-visual-reasoning-or-not-a8f84ca09b39">this</a>), a deeper neural-symbolic integration in <a href="http://compositional/">OpenCog</a> can readily be achieved with the use of <a href="https://wiki.opencog.org/w/GroundedPredicateNode">grounded predicates</a> in <a href="https://wiki.opencog.org/w/Atomese">Atomese</a> (OpenCog’s knowledge representation language), which are evaluated in the course of reasoning. This can be considered either as a hard attention imposed by the symbolic knowledge-based system onto the subsymbolic/neural vision models, or as a way to assemble neural module networks on fly with the use of general declarative reasoning engine instead of the use of specialized imperative program <a href="https://arxiv.org/abs/1705.03633">execution engine</a>, which is typically used in this class of VQA models.</p><p>Unfortunately, the original version of OpenCog lacks some functionality to conveniently run and train assembled networks. In particular, it has no means to pass tensors from one grounded predicate (neural network module) to another directly, and thus no means to assemble neural modules into an unbroken computational graph allowing for the gradient descent training. Also, grounded predicates in Atomese are bound to static functions in another language (e.g. Python), while we need to bound them to methods of concrete dynamically created objects (i.e. forward and backward steps of neural modules).</p><p>We filled this lack of functionality in the <a href="http://github.com/singnet/atomspace">SingularityNET fork of OpenCog</a>. With this extended functionality, a tight neural-symbolic integration can be achieved. Below, we describe one experimental design of a neural-symbolic framework without going into the implementation details.</p><h3>The Idea</h3><p>Let us imagine we want to re-use some existing neural modules implemented within a certain popular deep learning framework. We consider PyTorch here due to its native support for dynamic computational graphs, but other choices are quite possible.</p><p>Let us consider the <a href="https://github.com/davidmascharka/tbd-nets">Transparency by Design (TbD) model</a> as an example. It contains a number of classes for different modules, e.g. OrModule, AndModule, AttentionModule, QueryModule, SameModule, etc. One class can be instantiated into many objects (particular neural modules corresponding to certain concepts). For example, there are both attention (filter) and query (classification) networks for each color (red, green, etc.), for each shape (cube, cylinder, etc.), material (metal, wood, etc.).</p><p>The TbD model takes text question as input and converts it to a “program” (by a seq2seq model), which is then executed by <a href="https://github.com/davidmascharka/tbd-nets/blob/master/tbd/module_net.py">hard-coded imperative narrow program executor</a>. Our intention is to replace this very specific program executor with general-purpose OpenCog’s reasoning engine without introducing any domain-specific modifications to it. At the same time, we would like to reuse the neural modules themselves.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZIdnXuJjAKpNu2Y_UA7ew.png" /><figcaption>Module network assembled and executed by the imperative program executor (question: How many blocks are tiny blue objects or big purple metallic objects?)</figcaption></figure><p>Our idea is to bind neural modules to Atoms in OpenCog’s knowledge base, which represent corresponding concepts, relations, and logical operations.</p><h3>Atomese</h3><p>As described in <a href="https://blog.singularitynet.io/towards-declarative-visual-reasoning-or-not-a8f84ca09b39">out previous post</a>, OpenCog’s Atomspace can be populated with such pieces of knowledge as</p><pre>InheritanceLink<br>  ConceptNode &quot;red&quot;<br>  ConceptNode &quot;color&quot;</pre><p>and grounded predicates (as Atoms) can be bound to DNNs via external functions in such a way that queries like the following can be handled by OpenCog through grounded reasoning</p><pre>AndLink<br>  InheritanceLink<br>    VariableNode “$X”<br>    ConceptNode “color”<br>  EvaluationLink<br>    GroundedPredicateNode “py:filter”<br>    ConceptNode “cylinder”<br>  EvaluationLink<br>    GroundedPredicateNode “py:filter”<br>    VariableNode “$X”</pre><p>In particular, this query can help to find what color is the cylinder. However, as mentioned above, EvaluationLink evaluated in the course of reasoning, should return OpenCog’s TruthValue, which can be combined by <a href="https://wiki.opencog.org/w/Probabilistic_logic_networks">Probabilistic Logic Network</a> <a href="https://github.com/singnet/opencog/tree/master/opencog/pln/rules">rules</a>. This breaks computational graphs of deep learning libraries and hinders end-to-end training. We would like to keep and combine both DNN modules with possibility to train them and Atomspace knowledge representation with possibility to execute queries via symbolic reasoning.</p><h3>CogNets</h3><p><a href="https://github.com/singnet/semantic-vision/tree/master/experiments/opencog/cog_module">CogNets</a> is a prototype of neural-symbolic framework with a DNN-centric design. That is, it provides means to conveniently extend DNN models with OpenCog in Python rather than to extend OpenCog with DNNs in Atomese. The core class is CogModule that is inherited from torch.nn.Module. If one wants to use his or her PyTorch neural network in reasoning, it suffices to change its base class, e.g. from class AttentionModule(nn.Module) to class AttentionModule(CogModule). CogModule will do all the necessary wrappings. The only necessary thing is to provide Atom to the constructor, to which the instance being created will be bound. This will be a valid program in python:</p><pre>class AttentionModule(CogModule):<br>  def __init__(self, atom):<br>    super().__init__(atom)<br>    #initializing DNN parameters...</pre><pre>  def forward(self, x):<br>    #processing...</pre><pre>InheritanceLink(ConceptNode(&quot;red&quot;), ConceptNode(&quot;color&quot;))                       InheritanceLink(ConceptNode(&quot;green&quot;), ConceptNode(&quot;color&quot;))                       net1 = AttentionModule(ConceptNode(&quot;red&quot;))                       net2 = AttentionModule(ConceptNode(&quot;green&quot;))</pre><p>Created networks will keep the same behavior as original PyTorch networks. For example, one can execute net1(image) on some tensor input. However, they will also have another way of execution — through Atomese queries. To do this conveniently, one can create InputModule, which only purpose is to memorize the input tensor and bind it to some Atom in Atomspace to make it accessible by OpenCog. InputModule is defined in CogNets and can readily be used, so one can write down, e.g. InputModule(batch, Concept(&quot;batch&quot;)), where batch is PyTorch tensor to be processed.</p><p>Then, one can form Atomese query in the nearly same form as usual in OpenCog, e.g.</p><pre>BindLink(<br>  TypedVariableLink(VariableNode(&quot;$X&quot;), TypeNode(&quot;ConceptNode&quot;)),<br>  AndLink(<br>    InheritanceLink(VariableNode(&quot;$X&quot;), ConceptNode(&quot;color&quot;)),<br>    evaluate(VariableNode(&quot;$X&quot;), execute(ConceptNode(&quot;batch&quot;))),<br>  VariableNode(&quot;$X&quot;))</pre><p>Here, evaluate and execute replace EvaluationLink and ExecutionLink and create necessary wrappers to pass tensors from one neural module to another (they don’t execute these modules directly, but tell OpenCog how to execute them; that’s why we can use VariableNode inside them).</p><p>The whole TbD model can be put <a href="https://github.com/singnet/semantic-vision/tree/master/experiments/opencog/tbd_cognets">into this form</a>. There will be a few differences, though. In particular, queries will be represented in terms of variable grounding instead of applying the output classifier.</p><h3>Tensor Truth Values</h3><p>Direct execution of BindLink results in treating AndLink in a crisp logic style and in loosing the possibility to define a differentiable loss function. In contrast, PLN deals with continuous truth values. PLN is implemented as a set of rules for the <a href="https://wiki.opencog.org/w/URE">Unified Rule Engine</a>. In particular, these rules can calculate truth values of logical expressions based on truth values of their constituents. Equations for calculating these truth values are implemented as <a href="https://wiki.opencog.org/w/GroundedSchemaNode">GroundedSchema</a> nodes.</p><p>We have introduced <a href="https://github.com/singnet/atomspace/blob/master/opencog/atoms/truthvalue/TensorTruthValue.h">tensor truth values</a> into Atomese, and implemented <a href="https://github.com/singnet/opencog/tree/master/opencog/torchpln/pln">PLN version</a> that operates with them using PyTorch over tensors. As a result, the output of PLN becomes PyTorch tensor connected to the whole computational graph assembled in the course of reasoning. Thus, one can construct a differentiable loss function and run gradient descent optimization. Interestingly, tensor truth values can be assigned to IhneritanceLink or ImplicationLink, which are a part of the knowledge base, and can also be optimized in the course of learning.</p><p>Another task that can be solved with the use of the very same reasoning engine is illustrated in the following picture. This task was considered in the <a href="https://arxiv.org/abs/1805.10872">paper on DeepProbLog</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/145/1*g6Q9FWkhaT7QXMmyJI2HXA.png" /><figcaption>Another task that <a href="https://github.com/singnet/semantic-vision/blob/master/experiments/opencog/cog_module/mnist.py">can be solved by CogNets</a></figcaption></figure><h3>Conclusion</h3><p>Thus, our prototype of the neural-symbolic framework can be used to re-implement such things as TbD VQA model and DeepProbLog programs. It brings together a modern deep learning library and a powerful symbolic knowledge representation and reasoning system in a practical way. Not only can rich ontologies be used together with deep neural networks, but the weights of relations in these ontologies can be learned or adjusted by gradient descent.</p><p>More details can be found in the <a href="https://github.com/singnet/semantic-vision/tree/master/experiments/opencog/cog_module">repository</a> and our recent papers on <a href="https://arxiv.org/abs/1907.04592">differentiable PLN</a> and <a href="https://link.springer.com/chapter/10.1007/978-3-030-27005-6_15">CogNets</a> (<a href="http://agi-conf.org/2019/wp-content/uploads/2019/07/paper_19.pdf">preprint</a>).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*-l_SwJORgaGk1Ceb" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=240bff77ce4a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/towards-a-practical-neural-symbolic-framework-240bff77ce4a">Towards a Practical Neural-Symbolic Framework</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Are generative models good enough? A case study on class modeling]]></title>
            <link>https://medium.com/singularitynet/are-generative-models-good-enough-a-case-study-on-class-modeling-9a57c91ddcae?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a57c91ddcae</guid>
            <category><![CDATA[research]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[generative-model]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Wed, 24 Apr 2019 13:49:50 GMT</pubDate>
            <atom:updated>2019-04-24T13:49:50.714Z</atom:updated>
            <content:encoded><![CDATA[<h3>Are generative models good enough?</h3><p>Analyzing via a case study on class modeling whether generative models are good enough in terms of approximating density distributions of patterns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iS6PpkJt29ZAscx31Dz7bw.png" /></figure><h3>Motivation: Visual Concept Learning</h3><p>Visual concept learning is an essential subtask of semantic vision.</p><p>Consider the tasks of image caption generation or visual question answering. These tasks suppose the capability of an agent to say that some objects with certain attributes and in certain states are present in the image (e.g. “the happy woman is dancing”), i.e., to associate an image representation with words forming corresponding concepts.</p><p>One can try to train an image caption generation or visual question answering model end-to-end hoping that it will learn the necessary concepts on its own together with learning how to solve the downstream task. However, it is quite tricky, and the quality of learned concepts appears to be rather low.</p><p>When it is not known which part of the image corresponds to what concept, error signals are very weak and not too informative. That is why image representations are usually pre-trained with strong supervision (e.g., on ImageNet and/or Visual Genome).</p><p>Why can we not just use a pre-trained classifier to recognize visual concepts? Unfortunately, we do not have full information about labels that should and should not be assigned to certain images or their regions. For example, if some bounding box in the image is labeled as a <em>T-shirt</em>, it does not mean that it cannot be labeled as a person or a woman. If it is labeled as <em>red</em>, it can also be partially green, and so on.</p><p>Thus, it is natural to state the task of training by positive examples — only assuming that classes are not mutually exclusive and can intersect arbitrarily.</p><p>We want our agent to be able to tell if something is, say, a cat — independent of its knowledge of all possible alternatives. Even if it has never seen a platypus, it could say that this image does not correspond to any known concept (except for ‘an animal’ possibly). This statement (known as one-class classification or class modeling) corresponds to anomaly or novelty detection tasks and is of considerable practical interest.</p><p>When it is necessary to describe a certain class and then be able to identify its elements, distribution of elements of this class (a membership function or a probability density function) should be modeled.</p><p>Generative models are precisely intended for this purpose since they are trained to approximate the likelihood function <em>p</em>(<strong>x</strong>) by its maximization on observed patterns <strong>x</strong>. If some generative models ideally describe distributions of some classes, then the task of recognition can also be ideally solved. In other words, if such models of two classes assign non-zero probability for a certain image, then either the classes really overlap (and the image belongs to both of them), or the image is not informative enough (low contrast, small, blurry, etc.) for telling, which of two mutually exclusive classes it belongs to.</p><p>However, it is well-known that modeling the whole density distribution of patterns in classes is much more complicated than just drawing a border between them — which is the reason for discriminative models being much more practical in the limited supervised learning settings.</p><p>Recently, we have seen considerable progress in deep generative models achieving the capability to generate diverse high fidelity images (meaning that samples, which are considered likely by the model, are also likely in terms of a distribution of real images). However, are they good enough in terms of approximating density distributions of patterns?</p><h3>Linear Models</h3><p>The simplest probabilistic models to describe pattern distributions within each class are Gaussians. With their example, one can understand both the meaning of generative models for concept learning, as well as some possible difficulties.</p><p>It is evident that in some cases Gaussians can approximate real distributions awfully, so it would not be possible to distinguish separable classes (an example is shown in the following picture).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*iXJEYQk4UMTURh9jRJiKBQ.png" /><figcaption>Separable classes which are modeled by highly overlapping Gaussians</figcaption></figure><p>Nevertheless, such models can be reasonably good in some cases and can serve as a simple baseline.</p><p>Let us consider MNIST as an example and try to describe distributions of images of each digit with Gaussians. Here, we immediately face the first technical issue, i.e., the covariance matrix is degenerate, and its inversion required by the equation of Gaussian distribution cannot be directly computed. The reason for this is that some pixels in the images of the training set are always black (or always white, or brightness of some pairs of pixels is 100% correlated), i.e., the training images lie on some lower-dimensional hyperplane in the space of all possible images.</p><p>We can approximate the distribution of images by a Gaussian on this hyperplane, but we will have zero dispersion in the directions perpendicular to it, and thus the probability assigned to images not lying on this hyperplane will be strictly zero. At the same time, the test set will contain images (of same classes), which do not lie on the corresponding hyperplanes. Even such a simple model as an (unconstrained) normal distribution overfits to the data.</p><p>Bayesian approach tells us that some priors should be imposed on the parameters of the model (e.g., Inverse-Wishart distribution can be used), but considering this problem from a simplified coding perspective could be more intuitive. Fitting a Gaussian distribution corresponds to the Principal Component Analysis (PCA) since principle components are the eigenvectors of the covariance matrix.</p><p>Patterns can be represented as their projections onto these components (that will correspond to the latent code for this pattern). However, if the pattern lies outside the subspace formed by these components, its reconstruction will be imprecise. Thus, lossless encoding of an input pattern will consist of its latent code (which length, in bits, can be derived from the estimated Gaussian distribution) and reconstruction residuals (which description length is a reconstruction error). Both these components can characterize the degree, to which a pattern belongs to a modeled class.</p><p>Let us first consider the probability assigned by the Gaussian distribution. The source code for all experiments can be found on<a href="https://github.com/singnet/semantic-vision/tree/master/experiments/class_modelling/mnist"> Github</a>.</p><h3><strong>Log-likelihood in the PCA subspace</strong></h3><p>If we train our model on images of one digit and test it on images of another digit, we can observe the following histograms of (shifted negative logarithms of) probabilities assigned to the patterns (their projections onto PCA subspace) by the model with different sizes of the latent code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*vcXz8KYWQf6gcDs1wQWRrA.png" /><figcaption>Histograms of estimated densities of “real” and “fake” classes</figcaption></figure><p>With 10 latent variables, probabilities for “real” and “fake” patterns are badly separated, while this separation for 100 latent variables is reasonable, but far from perfect (which is expected, considering the simplicity of the model).</p><p>If one takes more similar digits like “3” and “5”, the separation will be quite bad even for 100 latent variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*6Ea_wgaXRwGyBExs32OuIg.png" /><figcaption>Histograms of estimated densities of “real” and “fake” classes</figcaption></figure><p>It would be useful to qualitatively estimate the degree of separation of “real” patterns (for describing which distribution the model is constructed) from “fake” patterns by imposing some threshold on the log-likelihood. For example, the optimal threshold gives 15.1% of “recognition” errors while trying to identify “real” images of “3” in the presence of “5” as “fake” images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/335/1*gYajq-YbJxe6NHfGBQDYdA.png" /><figcaption>Recognizing “real” images by imposing a threshold</figcaption></figure><p>This result can be slightly improved if we find the most appropriate size of the latent code. For example, 14.25% of “recognition” errors can be achieved for 84 latent variables while separating “3” and “5”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/361/1*T1ap_X9N6LaLzVP_ExQlXw.png" /><figcaption>Dependence of the error rate on the latent code size</figcaption></figure><p>It should be noted that the distribution of “fake” patterns is not used here (except for choosing a threshold), so images of any other class could be considered. We just took a similar class as a difficult case. As was noted earlier, the task is to construct a model for a class of patterns given only its positive examples — to make it possible to successfully answer the question if some pattern belongs to this class even if it belongs to some class which has never been encountered before.</p><p>This task is more complicated than the traditional classification task. Since shallow models give far from perfect results even for classification, the achieved recognition rate should not be immediately discouraging, and it is natural to ask if deep neural networks can achieve a satisfactory precision in the modeling of distributions of at least MNIST images.</p><h3><strong>Adversarial Autoencoders</strong></h3><p>Let us consider<a href="https://arxiv.org/abs/1511.05644"> adversarial autoencoders</a> (AAE). They, in essence, perform a sort of non-linear PCA — its encoder <em>E</em>(<strong>x</strong>) projects input pattern <strong>x</strong> into the space of latent variables <strong>z</strong>, while its decoder or generator <em>G</em>(<strong>z</strong>) performs the reconstructions. To ensure that the posterior distribution of latent variables has the desirable form (e.g., standard normal distribution), an additional adversarial loss is imposed with the use of a discriminator that tries to distinguish latent codes produced by the encoder from random vectors sampled from a prior distribution.</p><p>After training, one can sample <strong>z</strong> from the specified prior distribution, e.g., <strong>z</strong>~<em>N</em>(0, <strong>I</strong>), and generate image <strong>x</strong>=<em>G</em>(<strong>z</strong>). If the model is good, generated images will be distributed like real images. But how to estimate the probability density for some real pattern <strong>x</strong>, which is implicitly assigned by the model? Is it correct to substitute the latent code constructed by the encoder <strong>z</strong>=<em>E</em>(<strong>x</strong>) into the prior distribution <em>N</em>(0, <strong>I</strong>)?</p><p>Not precisely. This can be easily seen if we take a uniform distribution as priors. All values of <strong>z</strong> (in a certain range) will be equiprobable, while the non-linear generator can produce arbitrary distributions of <strong>x</strong> from these <strong>z</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZ3Vg4nZPyLBphVj9OQKmQ.png" /><figcaption><em>P</em>(<strong>z</strong>) can say nothing about P(<strong>x</strong>)</figcaption></figure><p>If we have some density of patterns <em>p</em>(<strong>z</strong>) around <strong>z</strong> and want to estimate their density after transformation <em>G</em>(<strong>z</strong>), we need to calculate how unit volume is changed by <em>G</em> at this point. In brief, <em>p</em>(<strong>z</strong>) should be multiplied by |inv(<em>J</em>(<em>G</em>(<strong>z</strong>)))|, where <em>J</em> is the Jacobi matrix. More precisely, we should use a product of singular values of this matrix, since it is usually not square. However, we will skip the technical details here.</p><p>Let us consider an adversarial autoencoder. We used the encoder with three convolutional and two dense layers, and the decoder with one dense and four convolutional layers. The discriminator used in the adversarial loss computed over the latent code contained three dense layers. Batch normalization and spectral regularization were used.</p><p>Let us consider the negative log-likelihood (or simply modules) of codes (projections) <strong>z</strong>=<em>E</em>(<strong>x</strong>), where <em>E</em> is an encoder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*jIrpFPxld-p3M2U5Icl5gA.png" /><figcaption>Distinguishing patterns of modeled and novel classes by values of |<strong>z</strong>| using AAE</figcaption></figure><p>By choosing an optimal threshold, 26.6% and 14.2% of recognition errors can be obtained.</p><p>Using the probability density in the space of input patterns <strong>x</strong> improves these scores by some percentages. For example, the same trained model with 10 latent variables can show improvement from 27.19% to 23.44% errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*NjqEgD9Ij1SZF0GO_D7gdw.png" /><figcaption>Distribution of (neg-log) densities of “real” and “fake” patterns in the space of <strong>z</strong> (left) and <strong>x</strong> (right)</figcaption></figure><p>However, it is apparent that overlapping distributions in the space of <strong>z</strong> will remain overlapping in the space of <strong>x</strong>, and improved criteria will not help to distinguish them.</p><p>So, let us consider the distribution of each component of <strong>z</strong> (for ten components) for “real” and “fake” classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/744/1*2_M8hoqb68NbuGLXWDYoeA.png" /><figcaption>Distribution of 10 latent variables for “real” (“3”) and “fake” (“5”) images</figcaption></figure><p>It can be seen that latent variables of “real” patterns are distributed normally with zero mean (and with very low correlations in fact). In turn, some latent variables of “fake” patterns are shifted, but still not too far, and the distributions of “real” and “fake” patterns overlap considerably.</p><h3>Accounting for Reconstruction Error</h3><p>It appears that projections of “fake” patterns can get inside the area of the “real” class, for which the generative model is constructed, and projections of both classes can appear to be distributed almost identically. In this case, the generator will reconstruct “fake” patterns as “real” patterns (e.g., images of “5” will be reconstructed as “3”). At the same time, the model can appear to reconstruct “fake” patterns as well as “real” patterns. In both cases, the model can describe the distribution of “real” patterns equally well as shown in the following illustration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPjEznOYAIW6HyUhXLVSPA.png" /><figcaption>Different locations of the “fake” class (red) w.r.t. the “real” class (green)</figcaption></figure><p>AAE trained to generate images of “3” can reconstruct images of “5” both as “3” and “5” depending on the size of the latent code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*WdLS-lLNOBQPvmWkxXixFg.png" /><figcaption>Reconstruction of original images (left) by AAE with 10 (middle) and 100 (right) latent variables</figcaption></figure><p>This means that projections of “fake” patterns can appear both inside and outside the region of projections of “real” patterns, and considering only this projection cannot be enough to judge if the pattern is “real” or “fake”.</p><p>As in the case of PCA, the model describes the distribution of patterns only in their projection to some manifold, while even “real” patterns can lie outside it — and the question of evaluating the probability density outside this manifold remains.</p><p>The simplest way is to use Euclidian distance from the pattern to its projection, i.e., to calculate the reconstruction error. This corresponds to the following extension of the generative model: <strong>x</strong>=<em>G</em>(<strong>z</strong>)+<strong>e</strong>, where <strong>z</strong>~<em>N</em>(0, <strong>I</strong>) as before and <strong>e</strong>~<em>N</em>(0, <strong>I</strong>s), where s is some scalar.</p><p>Let us consider separately on the possibility to perform “recognition” solely based on the reconstruction error.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*1fJL-W5LdUKTVAiE_fq2Jw.png" /><figcaption>Distinguishing patterns of modeled and novel classes by the reconstruction error using PCA</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/362/1*45atq9M0xAqL65ibGU8CLg.png" /><figcaption>Dependence of the error rate on the latent code size</figcaption></figure><p>The minimum error of 13.49% is achieved for 16 latent variables, which is similar to the error achieved with the use of the estimated density, but for smaller latent code (since for larger latent code, it is easier to achieve better reconstruction for “fake” patterns also).</p><p>The situation with AAE is similar, but the results are considerably better.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*v9qjT7fmGG6HZyliSajdyg.png" /><figcaption>Distinguishing patterns of modeled and novel classes by the reconstruction error using AAE</figcaption></figure><p>In particular, the error appears to be 6.8% for ten latent variables.</p><p>The whole generative model with pixel noise supposes that both components should be used to calculate the probability density.</p><p>Can “recognition” be improved by the use of their combination?</p><p>Unfortunately, it is not precisely the case. What we can obtain with this combination is nearly constant recognition rate independent of the size of the latent code. However, this rate corresponds to recognition rates with optimal sizes of the latent code, e.g., for PCA one can obtain:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*CR84obtQ7Z68HlUPsl4grA.png" /><figcaption>Error rates obtained with the use of different criteria for different sizes of the latent code</figcaption></figure><p>Thus it is enough to use the reconstruction error with an appropriate latent code size (it is interesting to note that some<a href="https://arxiv.org/abs/1807.02588"> papers</a> propose more elaborated criteria incorporating density estimations on manifolds, but, in fact, the latent code size used in these models is optimal for the reconstruction error criterion, and this criterion gives mostly the same recognition results for these models as more elaborated ones as we found out in our experiments). Of course, if someone wants to use models with larger latent codes, for which the reconstruction error criterion gives poor results, taking the estimated density in the projection on the manifold would be essential.</p><h3><strong>Generative Adversarial Networks</strong></h3><p>Although the result of AAE is not bad, it is far from perfect. One can assume that AAEs are not too good as generative models. Models from the Generative Adversarial Networks (GANs) family are directly trained to generate images instead of reconstructing them, and they can produce sharper images.</p><p>Can GANs be better in describing density distributions of patterns (i.e., better literally as probabilistic generative models)? However, GANs should have an encoder to be applicable for our task.</p><p>One of the models with the encoder is<a href="https://arxiv.org/abs/1805.10717"> BiGAN</a>. Unfortunately, this model appears to be worse than the considered AAE. For example, with 100 latent variables, one can obtain the following result with 31.6% and 18.5% error rates correspondingly:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*v9B3bJ5Pm7bmLjGNMZEBlA.png" /><figcaption>Distinguishing patterns of modeled and novel classes by |<strong>z</strong>| (left) and reconstruction error (right) using BiGAN (100 latent variables)</figcaption></figure><p>Similarly, the<a href="https://arxiv.org/abs/1606.03657"> InfoGAN</a> model can be tested. Although this model separates meaningful (structured) variables from noise variables in its latent code, and its Q-network, which can be used in place of the encoder, calculates only values of meaningful variables, some reconstruction can be performed (e.g., with finding best values of noise variables via sampling).</p><p>In particular, InfoGAN with a small number of meaningful variables (and a larger number of noise variables) behaves similarly to AAE with a small size of its latent code. For example, the InfoGAN model trained on the images of “3” will give the following reconstruction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/926/1*VkqyhL7FbR72_3lagDZ3gQ.png" /><figcaption>InfoGAN reconstruction of “5” images as “3”</figcaption></figure><p>The reconstruction error criterion should work better in this case, but the recognition rate appears to be low (31.1%):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*Q_zO5rTBgMvHf3731yFTCw.png" /><figcaption>Distinguishing patterns of modeled and novel classes by the reconstruction error using InfoGAN (5 meaningful latent variables)</figcaption></figure><p>The reason is that the reconstruction of “real” patterns has considerably larger errors than that of AAE, i.e., it is far from precise on the pixel level. This result can be somewhat improved with a careful choice of the latent code structure, but not much (up to 20% errors).</p><p>Although InfoGANs can perform a reasonable unsupervised clustering given all mutually exclusive classes during training and given an appropriate structure of the latent code, it seems they do not model pattern distributions quite well (however, this is not a solid conclusion).</p><h3><strong>Variational Autoencoders</strong></h3><p>Although<a href="https://arxiv.org/abs/1807.02588"> some papers argue</a> that AAE is better suited for the class modeling task than Variational Autoencoders (VAE), VAE appeared to be comparable to or even better than AAE.</p><p>We took<a href="https://openreview.net/forum?id=Sy2fzU9gl"> β-VAE</a> — a recent extension of VAE used for disentangled representation and concept learning. However, best results were obtained with β=1 that corresponds to ordinary VAE (although one would expect that better disentanglement should be connected to the better class modeling). We used four convolutional layers and one dense layer in the encoder, and one dense and five (transpose) convolutional layers in the decoder. Among three sizes of the latent code (10, 20, 100), best results were obtained with the size 20 solely on the base of the reconstruction error criterion with 5.4% recognition error:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/331/1*rporF344dp1wW74lK-6HKQ.png" /><figcaption>Distinguishing modeled and novel classes by the reconstruction error using VAE (20 latent variables)</figcaption></figure><p>Interestingly, the reconstruction of “real” patterns appears to be quite good for very different images of “3”, while “fake” patterns are still reconstructed as “3”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*x7g7LvBC3GfbNtOpgSxZkg.png" /><figcaption>Results of reconstructing images of the modeled class with VAE</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*TMm1-4ZSa-jPugn289DTQg.png" /><figcaption>Results of reconstructing images of the “false” patterns with VAE</figcaption></figure><p>Unfortunately, this result is still not excellent. Indeed, if we use the nearest neighbor one-class classifier, which merely compares the distance to the nearest neighbor in the class being modeled with some threshold (instead of comparing the distances to the nearest neighbors in all classes), we can achieve about 10% error rate. If we use some additional tricks (earth move distance and deskewing), the error rate can be reduced to 6%, which is nearly the same as with the use of deep generative models.</p><p>This indicates that the density distribution of patterns is modeled by DNNs far from perfectly (in terms of capturing underlying regularities). Indeed, if we try to train the model on the images of “1”, the error rate will be about 1% while recognizing “1” against all other classes. At the same time, recognizing “8” against all other classes gives more than 11% error rate, implying that the deep models describe a more complex density distribution of images of “8” — much worse than “1” (in particular, images of “8” and “1” will be more frequently confused if we model the distribution of images of “8” than if we model “1”).</p><p>Also, if we take even more complex images, the result will still be unsatisfactory. One can argue that it would be too naïve to expect good results from such direct modeling (with not too deep networks and without showing images of any other class to the model) of the distribution of images corresponding to such concept as, for example, “person”. That is true, but still, the considered models achieve state-of-the-art results on MNIST, and these results cannot be called satisfactory.</p><p>If we cannot model with enough precision the distribution of centered images of “3” or “8”, which have low variability, what is wrong?</p><p>One can argue that computations performed by formal neurons are not well-suited to efficiently represent the necessary distributions, and some extensions like<a href="https://blog.singularitynet.io/singularitynets-ai-team-experiments-with-generative-capsule-networks-c48ebc3fb2e1"> generative CapsNets</a> or<a href="https://blog.singularitynet.io/just-deep-is-too-flat-b3813e2242f1"> HyperNets</a> are necessary.</p><p>However, this might not be the only and main reason. The problem may stem from the vagueness of the task statement. We do not want our generative model simply to describe the distribution of patterns in the training set. We want it to generalize, so we can calculate the probability density for new patterns and get non-zero values for patterns belonging to the modeled class. But, what class?</p><p>Should a model trained on the MNIST images of “5” assign a non-zero probability to slightly rotated images of “5” or images with an additional small stroke? If the model does not recognize such images as “5”, we could blame it for bad generalization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*GHqo6z6T0y_-ea_rni_2jA.png" /><figcaption>Images of “3” (left) and “5” (right), which shouldn’t be recognized correctly by one-class classifiers</figcaption></figure><p>However, if it assigns a high probability for images of other digits, is it that wrong since all such images belong to the same class of handwritten digits?</p><p>For example, if one trains a GAN model on images of one digit, and tries to run its discriminator on images of other digits, the discriminator will recognize them as “real” images. If the generator produced images of “5” instead of “3”, the discriminator could easily be able to learn to distinguish real images from fake, so this seems like an unexpected and incorrect behavior of the discriminator. However, one can also claim that the discriminator performed a nice generalization inducing the notion of a handwritten symbol.</p><p>We cannot hope that our generative model will guess our intentions and correctly generalizes that “5” with an additional stroke or almost without one stroke is still “5” while “3” is not a badly spelled “5”.</p><p>However, we may want our model to tell what is the specific difference between a new image and the previously seen images of the modeled class. We hope to describe in one of our future posts, how this can be done with the use of the representational minimum description length principle and module networks.</p><h3><strong>How Can You Get Involved?</strong></h3><p>If you would like to learn more about SingularityNET, we have a passionate and talented community which you can connect with by visiting our <a href="https://community.singularitynet.io/">Community Forum</a>. Feel free to say hello and to introduce yourself <a href="https://community.singularitynet.io/c/hello">here</a>. We are proud of our developers and researchers that are actively publishing their research for the benefit of the community; you can read the research <a href="https://blog.singularitynet.io/research/home">here</a>.</p><p>If you are looking to monetize your AI services or create new ones, we invite you to learn more about the nature of our platform and what its <a href="http://beta.singularitynet.io/">Beta version</a> has to offer by visiting the SingularityNET <a href="https://dev.singularitynet.io/">developer portal</a>.</p><p>For any additional information, please refer to our roadmaps and<a href="http://singularitynet.io/"> subscribe to our newsletter</a> to stay informed about all of our developments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*E8KIEoi7r_gDdBqc" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a57c91ddcae" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/are-generative-models-good-enough-a-case-study-on-class-modeling-9a57c91ddcae">Are generative models good enough? A case study on class modeling</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inverting Discriminative Representations with HyperNets]]></title>
            <link>https://medium.com/singularitynet/inverting-discriminative-representations-with-hypernets-b259dc64530c?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b259dc64530c</guid>
            <category><![CDATA[representation]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Tue, 08 Jan 2019 12:01:00 GMT</pubDate>
            <atom:updated>2019-01-08T12:01:00.876Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Exploring the utility of HyperNets in overcoming traditional models’ limitations when inverting discriminative representations.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mB_2LFg_l1LHNmnJ42Ox5g.jpeg" /></figure><h3>Introduction</h3><p>Generative models are essential for general vision systems. They can be used to represent visual concepts, and relations between them, by describing conditional distributions of the images of objects with corresponding attributes, subparts, etc. Learning visual concepts by fitting these distributions into samples of real images can be done with little to no supervision. Different <a href="https://arxiv.org/abs/1606.05579">publications</a> have addressed the problem of visual concept learning on the basis of generative models.</p><p>Unfortunately, training deep and expressive generative models has proven to be very challenging. Using discriminatively trained image representations is still the favored method in downstream computer vision tasks including both applied tasks of object detection and recognition, and tasks of semantic vision like image caption generation or visual question answering.</p><p>That is why inverting discriminatively trained powerful representations is of a certain interest as a practical tool facilitating the construction of better generative models for semantic vision (although one might argue that unsupervised or reinforcement learning of representations is more AGI-ish).</p><p>With high-level discriminative features at hand, a decoder or a conditional generative adversarial network can be trained. To further ease the process of training the generative model, intermediate discriminative features can be used to guide the reconstruction or sampling, as in<a href="https://arxiv.org/abs/1612.04357"> stacked GANs</a>.</p><p>In this article, we present an additional option to improve models for inverting discriminative representations: HyperNets. These appear to be beneficial as decoders at least for inverting some discriminative features. Herein we will use the term HyperNets according to the definition set out in our previous <a href="https://blog.singularitynet.io/just-deep-is-too-flat-b3813e2242f1">post</a>: referring to artificial neural networks that have higher-order connections, i.e., connections on connections.</p><h3>Task</h3><h4>HyperNets for approximating families of functions</h4><p>The purpose of discriminative models is to predict target variables (e.g. class labels) given observable variables (e.g. images). The values of these target variables are usually invariant to certain transformations of input patterns. Thus, discriminative models naturally benefit from learning representations that discard irrelevant information. That is why some additional features <strong>n</strong> are needed in order to generate or reconstruct a concrete image <strong>x</strong>=<em>g</em>(<strong>n</strong>|<strong>z</strong>) despite its high-level discriminative features <strong>z</strong>=<em>f</em>(<strong>x</strong>). These features can be considered as “noise” sampled from a certain prior distribution, e.g. <strong>n</strong>~<em>N</em>(0, I), in purely generative settings (inducing a conditional distribution <em>p</em>(<strong>x</strong>|<strong>z</strong>)), or as an extension of the latent code constructed by an additional encoder <strong>n</strong>=<em>e</em>(<strong>x</strong>) in the case of autoencoders.</p><p>The question is, however, how to mix up these features -<strong>z</strong> and <strong>n</strong>- in the generator. The simplest way is just to take their concatenation and train the generator as (an approximation of) a rendering function of two arguments. Alas, these arguments are quite different in their nature. While features “<strong>z”</strong> describe high-level image content, vector “<strong>n”</strong> can be put into correspondence to parameters of some image transformation. This is more accurately modeled as a parametric family of functions rather than a single function of two arguments.</p><p>As we discussed in one of our<a href="https://blog.singularitynet.io/just-deep-is-too-flat-b3813e2242f1"> previous posts</a>, traditional neural networks are not well suited for approximating families of functions. Specifically, if “<strong>n”</strong> contains spatial transformation parameters, then ordinary first-order networks fail to generalize the transformation -itself disentangled from the image content. Additionally, the reconstruction of images for those values of transformation parameters appears to be unsuccessful; for which similar images were not presented in the training set.</p><p>Conversely, HyperNets successfully deal with this task due to their ability to approximate classes of functions, mapping the function parameters to the weights of the approximating neural network, and naturally disentangling this mapping from the image content.</p><p>When the images are subjected to known classes of spatial transformations, specialized models can be efficiently utilized. Nevertheless, inverting discriminative representations is a not a contrived practical case of an unknown transformation to be learned, thus making this task an interesting test application for HyperNets.</p><h4>Why invert Faster R-CNN?</h4><p><a href="https://arxiv.org/abs/1506.01497">Faster R-CNN</a> is a widely used method for object detection and recognition. Since it is trained to recognize a limited set of classes, it is not the labels assigned to the extracted bounding boxes around salient objects, but their high-level features that can be of main utility. For example, a number of visual question answering (VQA) models are built on the top of Faster R-CNN (e.g.<a href="https://arxiv.org/abs/1803.07724"> here</a>). However, the VQA task supposes not just the ability to recognize an extended set of object classes, but also to identify their attributes (both general and class-specific), performed actions, relations, and more which require going down to visual features.</p><p>It is common practice to fine-tune relatively general features trained on a wide dataset (e.g. ResNet features trained on ImageNet) or dataset from a target domain. Otherwise, these features will not display a state-of-the-art performance (see, e.g.,<a href="https://arxiv.org/abs/1805.08974"> this paper</a>). Thus, the fine-tuning of Faster R-CNN features is desirable for VQA -albeit not usually carried out. The problem is, however, that labels for bounding boxes are absent in VQA datasets, and fine-tuning cannot be done with supervision.</p><p>In such situations, generative models can help because they describe the density distribution of input patterns, and this distribution can be fine-tuned to fit a new dataset without supervision In other words, at first, one needs to train a generative model conditioned by discriminative features on the same dataset as it was used for training a discriminative model.</p><p>Prior to attempting to build a fully-fledged generative model, we would like to ask what kind of decoder will be capable of reconstructing the content of bounding boxes from Faster R-CNN features (and such a decoder alone<a href="https://arxiv.org/abs/1807.10591"> can be useful</a> for unsupervised fine-tuning).</p><p>Hereunder we will describe an attempt to create a decoder that will be able to reconstruct images in bounding boxes through their Faster R-CNN features.</p><h3>Experiments</h3><h4>Reconstructing from Faster R-CNN features only</h4><p>Let us first start with a naïve model that tries to reconstruct images in bounding boxes solely from the Faster R-CNN features (pre-trained on<a href="http://www.image-net.org/"> ImageNet</a> and fine-tuned on<a href="https://visualgenome.org/"> Visual Genome</a>). We used the model with the following architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*RYRtWi55dN-wxPe6" /><figcaption><em>Simple convolutional decoder from Faster R-CNN features</em></figcaption></figure><p>We trained the model on different subsets of Visual Genome.</p><p>One could expect that Faster R-CNN features to be rich enough, and original images to be reconstructed from them, however, this is not really the case. The reconstructed images appear to be rather blurry:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*_to5-SlS6jmmqRI0" /><figcaption><em>Reconstruction of images from the training set based on Faster R-CNN features only</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*NS_tg3ZOlMfh11RM" /><figcaption><em>Reconstruction of images from the test set based on Faster R-CNN features only</em></figcaption></figure><p>Deepening the model can help to improve the results, but we will consider different models of the same small depth to make the difference in the reconstruction quality more visible.</p><h4>Encoding lost information</h4><p>As it was noted above, discriminative models benefit, in general, from discarding some factors of variation (e.g. concrete position of objects), to which the results of recognition should be invariant. Thus, it is natural to extend the features from Faster R-CNN with some latent features constructed by an additional encoder in such a way that the original images can be successfully reconstructed. These additional features are supposed to be parameters of some transformation, and their number should not be large in order to avoid a direct encoding of image content in them.</p><p>Basically, an autoencoder, which encoder contains a pre-trained fixed part, should be trained. We used the following architecture for this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*8mXwytVz9auIwCCe" /><figcaption><em>Additional encoder for recovering lost information</em></figcaption></figure><p>The decoder is the same as before, but it takes concatenated Faster R-CNN and with extra learned features as input:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*16SonTU04QaMFKu3" /><figcaption><em>The same decoder as above, but from concatenated features</em></figcaption></figure><p>Not surprisingly, this model can produce better reconstructions. However, while its results on the train set are reasonable, reconstructions of test images are still bad:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*9DUcioIJJE9kyVlS" /><figcaption><em>Reconstruction of images from the training set with the use of additional features</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*lN9oxDKj0tln0q18" /><figcaption><em>Reconstruction of images from the test set with the use of additional features</em></figcaption></figure><p>Although the decoder uses Faster R-CNN features, it fails to generalize beyond the training set on how to combine them with additional latent features.</p><h4>Utilizing HyperNets</h4><p>As we discussed in one of our<a href="https://blog.singularitynet.io/just-deep-is-too-flat-b3813e2242f1"> previous posts</a>, traditional “flat” decoders fail to learn how to transform images disentangled from their content even given explicit transformation parameters as input. On the other hand, HyperNets can do this.</p><p>Here, we do not know what transformation should be applied and what parameters it has, but we can hope that an additional encoder will learn such latent code and that a HyperNet will learn the transformation that the decoder will be able to reconstruct from the images.</p><p>We used the following architecture for the decoder, while the additional encoder is identical to the one above, but its features are fed to the control network instead of concatenating them with Faster R-CNN features (the code can be found<a href="https://github.com/singnet/semantic-vision/tree/master/experiments/feature_inversion/faster_rcnn/HyperNet"> here</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*HGZfx0qC5F5G-MrZ" /><figcaption><em>HyperNet decoder with the control network</em></figcaption></figure><p>HyperNet achieves considerably better reconstruction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*x5PxgHvkYieFgGzC" /><figcaption><em>Reconstruction of images (top) from the train set by HyperNet (bottom) in comparison with traditional models (middle) of the same depth</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*ODjOARh7GUF3Wqjb" /><figcaption><em>Reconstruction of images (top) from the test set by HyperNet (bottom) in comparison with traditional models (middle) of the same depth</em></figcaption></figure><p>It should be highlighted that the model really uses Faster R-CNN features, and does not ignore them by simply training an additional encoder. Indeed, if we train the same model, but replace Faster R-CNN features with zeros, the result -even on the training set- would be:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*dB8rZXFMSSDu_eZ4" /><figcaption><em>Results of reconstruction with ablated Faster R-CNN features</em></figcaption></figure><p>At the same time, the reconstruction results can be improved (both for hypernets and baseline autoencoders) either by making the model deeper or by eliminating upsampling (unfolding the dense latent code into the feature maps of the same size as the image to be reconstructed). In the first case, the results will be slightly more blurry, but less noisy, while in the second case, the reconstruction will be sharper, but noisier:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/0*Azer6YGiOHrGLW1S" /><figcaption><em>Reconstruction by the deeper decoder (top — images from the training set, bottom — novel images)</em></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/0*SbVqWMimDy7F63mA" /><figcaption><em>Reconstruction by the decoder without upsampling (top — images from the training set, bottom — novel images)</em></figcaption></figure><p>Interestingly, the results of reconstruction are worse (in the case of test images) for the images, of which the content is semantically less clear.</p><p>To conclude, what is important to note here is the fact that the separation of the latent code into the features describing the image content and the parameters of its transformation eases the task of learning the inversion of representation. These parts of the latent code have different computational effects. If one tries to learn representation, in which all latent variables induce the same kind of computations, it would be more difficult to disentangle these two types of variables. Hence, considering the aforementioned limitations of more traditional methods, it would be worthwhile to use HyperNets in the task of learning disentangled representations.</p><h3>How Can You Get Involved?</h3><p>If you would like to learn more about SingularityNET, we have a passionate and talented community which you can connect with by visiting our <a href="https://community.singularitynet.io/">Community Forum</a>. Feel free to say hello and to introduce yourself <a href="https://community.singularitynet.io/c/hello">here</a>. We are proud of our developers and researchers that are actively publishing their research for the benefit of the community; you can read the research <a href="https://blog.singularitynet.io/research/home">here</a>.</p><p>For any additional information, please refer to our roadmaps and<a href="http://singularitynet.io/"> subscribe to our newsletter</a> to stay informed about all of our developments.</p><p><a href="https://blog.singularitynet.io/singularitynet-releases-updated-roadmaps-d4aa2c0d7bc7">SingularityNET Releases Updated Roadmaps</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*C66AE0AM4mnqC9re" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b259dc64530c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/inverting-discriminative-representations-with-hypernets-b259dc64530c">Inverting Discriminative Representations with HyperNets</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Towards Declarative Visual Reasoning… Or Not?]]></title>
            <link>https://medium.com/singularitynet/towards-declarative-visual-reasoning-or-not-a8f84ca09b39?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a8f84ca09b39</guid>
            <category><![CDATA[cognitive-computing]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Tue, 06 Nov 2018 17:44:32 GMT</pubDate>
            <atom:updated>2018-11-06T17:44:32.517Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Towards Declarative Visual Reasoning. . . Or Not?</strong></h3><p><em>Exploring how SingularityNET will advance the research and applicability of tasks that require reasoning and pattern recognition.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*lqiBKYPtocgkc20H" /></figure><h3>Compositional Visual Reasoning</h3><p>It is an undeniable fact that Deep Neural Networks (DNN) have shown impressive results in various hard to solve problems, especially when it comes to image analysis and pattern recognition.</p><p>There still are many tasks, however, for which Deep Neural Networks are not well suited. These are tasks with compositional or combinatorial nature, in particular, if we suppose exponentially large spaces of objects. Roughly speaking, these are tasks that require “reasoning.” Although attempts are being made to extend DNN models, other approaches perform better in solving such tasks — for example, one such prominent domain is <a href="https://arxiv.org/abs/1608.04428">algorithmic induction</a>.</p><p>Furthermore, there are some tasks which require both reasoning and pattern recognition. One example of such tasks is Visual Question Answering (VQA), in which humans still outperform DNN solutions by a large margin. For instance, the state-of-the-art DNN models score less than 70% on the <a href="http://visualqa.org/">standard COCO VQA benchmark</a>, while the human score stands at more than 83%. Moreover, such DNN models are <a href="https://arxiv.org/abs/1705.03633">heavily criticised</a> for exploiting dataset biases and directly mapping inputs to outputs instead of explicitly modeling the underlying reasoning processes.</p><p>The <a href="https://arxiv.org/abs/1612.06890">CLEVR dataset</a> is specifically designed to facilitate compositional reasoning. The dataset contains arbitrarily nested questions like “<em>What size is the sphere that is left of the green metal thing that is left of the small cylinder?</em>” although for a simplistic visual domain. Such questions cannot be put into a fixed-size embedding as is usually done in COCO VQA models. Consequently, the state-of-the-art models for this benchmark are the <a href="https://arxiv.org/abs/1511.02799">neural module networks</a> (for details, see the <a href="https://arxiv.org/abs/1705.03633">paper</a> mentioned earlier). Some of these models are even designed to be <a href="https://arxiv.org/abs/1803.05268">transparent and interpretable</a>.</p><p>However, these models are based on a seq2seq mapping of questions to programs composed of a sequence of neural modules with partially hard-coded behavior. For example, the union block in the example below merges two attention maps by taking an element-wise maximum among them. The program itself looks like:</p><pre>00 = {‘inputs’: [], ‘function’: ‘scene’, ‘value_inputs’: []}<br>01 = {‘inputs’: [], ‘function’: ‘scene’, ‘value_inputs’: []}<br>02 = {‘inputs’: [0], ‘function’: ‘filter_size’, ‘value_inputs’: [‘small’]}<br>03 = {‘inputs’: [2], ‘function’: ‘filter_color’, ‘value_inputs’: [‘blue’]}<br>04 = {‘inputs’: [1], ‘function’: ‘filter_size’, ‘value_inputs’: [‘large’]}<br>05 = {‘inputs’: [4], ‘function’: ‘filter_color’, ‘value_inputs’: [‘purple’]}<br>06 = {‘inputs’: [5], ‘function’: ‘filter_material’, ‘value_inputs’: [‘metal’]}<br>07 = {‘inputs’: [3, 6], ‘function’: ‘union’, ‘value_inputs’: []}<br>08 = {‘inputs’: [7], ‘function’: ‘filter_shape’, ‘value_inputs’: [‘cube’]}<br>09 = {‘inputs’: [8], ‘function’: ‘count’, ‘value_inputs’: []}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZIdnXuJjAKpNu2Y_UA7ew.png" /><figcaption>How many blocks are tiny blue objects or big purple metallic objects?</figcaption></figure><p>The filter modules in the example above accept the attention maps produced by previous modules, which are used to mask an input image (represented by its high-level ResNet-101 features) and produce new attention maps. At the end of the program, there is typically a query module (which also takes a feature and attention maps as input, but produces a new feature map as output), followed by a classifier.</p><p>The programs are run step-by-step by the execution engine written in Python. This, in essence, is an imperative domain-specific language in which a simple model translates questions without any use of explicit knowledge about visual concepts and their relations (while even mere classifiers can <a href="https://arxiv.org/abs/1612.04844">benefit from the use of knowledge graphs</a>). Does this correspond to the “underlying reasoning processes”?</p><p>Therefore, it is tempting to replace the imperative-style domain-specific execution engine with a declarative knowledge-base general reasoning system — making it even more transparent and interpretable.</p><h3>Declarativization of Visual Reasoning</h3><p>As we discussed in one of our <a href="https://blog.singularitynet.io/enabling-cognitive-visual-question-answering-a93febd454a7">previous posts</a>, cognitive architectures can be used to integrate the DNN image analysis capabilities with general-purpose reasoning engines over knowledge bases to enable cognitive VQA.</p><p>For simple questions, the imperative question-answering programs can be easily converted to declarative queries.</p><p>Consider, for instance, the question “<em>What color is the cylinder?</em>” The corresponding program will look like:</p><pre>00 = {‘inputs’: [], ‘function’: ‘scene’, ‘value_inputs’: []}<br>01 = {‘inputs’: [0], ‘function’: ‘filter_shape’, ‘value_inputs’: [‘cylinder’]}<br>02 = {‘inputs’: [1], ‘function’: ‘query_color’, ‘value_inputs’: []}</pre><p>The query color module takes as input the image features masked by the attention map produced by filter_shape[cylinder] module and outputs new feature map, which is then passed to the final classifier. The multinomial classifier calculates the probabilities of all answers.</p><p>However, we can explicitly introduce the query variable $X, replace the query module with the corresponding filter module filter_color[$X], and ask the reasoning engine to find such value of $X which will produce a non-empty final attention map.</p><p>Therefore, the question “<em>What color is the cylinder?</em>” can be represented declaratively using OpenCog’s Atomese language:</p><pre>(AndLink<br>  (InheritanceLink<br>    (VariableNode “$X”)<br>    (ConceptNode “color”))<br>  (EvaluationLink<br>    (GroundedPredicateNode “py:filter”)<br>    (ConceptNode “cylinder”))<br>  (EvaluationLink<br>    (GroundedPredicateNode “py:filter”)<br>    (VariableNode “$X”)))</pre><p>In the example above, the predicates are grounded in deep neural networks — which can be the same modules as filter modules in neural module networks processing high-level image features (omitted here for the sake of brevity).</p><p>OpenCog’s reasoning system (<a href="https://wiki.opencog.org/w/The_Pattern_Matcher">Pattern Matcher</a> or the <a href="https://wiki.opencog.org/w/Probabilistic_logic_networks">Probabilistic Logic Networks</a>, PLN) will try to find an appropriate grounding for the variable $X, for which the whole conjunction is true. This is the reason why we don’t need to have both filter attribute and query attribute modules — query attribute modules extended by a classifier is an imperative way to determine an appropriate answer. The knowledge about ontological relations between concepts (e.g., “red” and “color”) is explicitly utilized through the InheritanceLink.</p><p>In one of <a href="https://blog.singularitynet.io/enabling-cognitive-visual-question-answering-a93febd454a7">our previous posts</a>, we used models which deal with bounding boxes. OpenCog’s reasoning system had to find the bounding boxes and apply grounded predicates to them to satisfy the declarative query. Consequently, grounded predicates could produce just one truth value per bounding box, and truth values of logical expressions over these predicates could be easily calculated with the use of PLN.</p><p>However, most models for CLEVR deal with dense attention maps. This leads us to some interesting scenarios: should the declarative reasoning system attend each element of the dense attention maps? Should it necessarily deal with the extracted objects? Should it operate with whole attention maps as tensor truth values?</p><p>All of these solutions are possible with their own strong and weak points, and possibly, should be somehow combined. In humans, we observe that we can deliberately attend individual pixels in images, but we don’t usually consciously reason about each pixel.</p><p>For the sake of simplicity, however, let’s assume that we choose to deal with attention maps as a whole. In such a scenario, we will be able to see some additional differences between the use of module networks in imperative and declarative fashions. Consider the program for a slightly more complicated question like “<em>What color is the large cylinder</em>?”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8JQGEwDel_DToLtc_C8MKg.png" /><figcaption>What color is the large cylinder?</figcaption></figure><p>The first filter: size[large] will take the image feature maps and the default attention map (covering the whole image) and produce the attention map that highlights large objects.</p><p>The next filter: shape[cylinder] will take the image features masked by the attention map produced by the previous filter and output a new attention map, which can then be used to mask the image features once again, and these features will be passed to the query color module — which will produce the new features fed to the final classifier. Also, note that the result for different order of filters can be different (especially if we consider two filters for attributed), which seems somewhat strange.</p><p>In contrast, a less imperative form of this program would be the same as above — but with the additional conjunct (EvaluationLink (GroundedPredicateNode “py:filter”) (ConceptNode “large”)). That is, the attention maps would be produced by all filters independently and then And’ed (which can be done pixel-wise).</p><p>The query attribute modules can appear in the middle of the program and not at the end. For example, in the case of a question: “<em>Is the small gray object made of the same material as the big cube</em>?<em> </em>There will be two query material modules executed after the consequent filtering of <em>small+gray</em> and <em>large+cube</em>. They will produce two feature maps, which will then be passed to the comparison module:</p><pre>00 = {‘inputs’: [], ‘function’: ‘scene’, ‘value_inputs’: []}<br>01 = {‘inputs’: [0], ‘function’: ‘filter_size’, ‘value_inputs’: [‘small’]}<br>02 = {‘inputs’: [1], ‘function’: ‘filter_color’, ‘value_inputs’: [‘gray’]}<br>03 = {‘inputs’: [2], ‘function’: ‘query_material’, ‘value_inputs’: []}<br>04 = {‘inputs’: [], ‘function’: ‘scene’, ‘value_inputs’: []}<br>05 = {‘inputs’: [4], ‘function’: ‘filter_size’, ‘value_inputs’: [‘large’]}<br>06 = {‘inputs’: [5], ‘function’: ‘filter_shape’, ‘value_inputs’: [‘cube’]}<br>07 = {‘inputs’: [6], ‘function’: ‘query_material’, ‘value_inputs’: []}<br>08 = {‘inputs’: [3, 7], ‘function’: ‘equal_material’, ‘value_inputs’: []}</pre><p>This program can be converted into a declarative form. For example:</p><pre>(AndLink<br>  (Inheritance (Variable “$X”) (Concept “material”))<br>  (Inheritance (Variable “$Y”) (Concept “material”))<br>  (EqualLink $X $Y)<br>  (AndLink<br>    (Evaluation (GroundedPredicate “py:filter”) (Concept “small”))<br>    (Evaluation (GroundedPredicate “py:filter”) (Concept “gray”))<br>    (Evaluation (GroundedPredicate “py:filter”) (Variable “$X”)))<br>  (AndLink<br>    (Evaluation (GroundedPredicate “py:filter”) (Concept “large”))<br>    (Evaluation (GroundedPredicate “py:filter”) (Concept “cube”))<br>    (Evaluation (GroundedPredicate “py:filter”) (Variable “$Y”))))</pre><p>Thanks to the absence of the necessity to pass attention maps from filter to filter, this expression can be simplified with the use of only one variable.</p><p>Here, internal AndLinks deal with tensor truth values, while external AndLink is a traditional PLN conjunction, so EqualLink will compare concepts — not feature maps as done by the equal_material module.</p><p>Thus, this is not only a computationally different representation of the question but also its different formalization. A question about the similarity of colors can imply either a positive or negative answer for green objects, with a different shade, and humans can answer this question by focusing on both visual features and names of colors.</p><p><strong>Is a declarative formalization of questions more natural?</strong></p><p>In terms of <strong>what</strong> we want to find, this way is definitely better. However, it might not be better in describing <strong>how</strong> do humans actually find the answer.</p><p>For instance, consider the question “<em>What color is the tiny matte block left of the blue block?</em>”</p><p>In the neural module networks, the notion of “left” is represented as a neural network that also accepts feature maps masked by the attention output of the previous module, and produces another attention map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LX6NjaINuRLb8-XVsSByOQ.png" /><figcaption>What color is the tiny matte block left of the blue block?</figcaption></figure><p>In the case of “large blue block” there is no real need to pass attention maps from “large” filter to “red” filter, and further to the “cube” filter, the attention maps can be calculated in parallel and then fused. However, in the case of “left of the blue block” it is essential to use the attention map produced by “blue block” in “left of” and to pass the produced attention map further — which is definitely not a pixel-wise operation over attention maps as truth values, and which looks really like a sequential execution of imperative programs.</p><p>Does it mean that this question cannot be represented declaratively? Apparently, it does not.</p><p>“Left of” and similar relation modules act as functions returning new objects (selected pixels), but not as predicates (uniformly applied to the given set of objects). In logic, “left of” and other relations are usually formalized as predicates with two arguments. However, this predicate will also have to accept two attention maps (or feature maps masked by attention maps). It is not really a problem in OpenCog, because grounded predicate nodes (or rather, schema nodes, which are similar to grounded predicates — they both accept Atoms as input and produce them as output instead of producing truth values as output) can be nested, for example:</p><pre>(EvaluationLink<br>  (GroundedPredicateNode “py:relation”)<br>  (ConceptNode “left”)<br>  (ExecutionOutputLink<br>    (GroundedSchemaNode “py:filter”)<br>    (ConceptNode “cube”))<br>  (ExecutionOutputLink<br>    (GroundedSchemaNode “py:filter”)<br>    (ConceptNode “cylinder”)))</pre><p>Which will be evaluated to true if there is a cube left of a cylinder. Isn’t it an imperative program?</p><p>Apparently, there is some piece of procedural knowledge (which is still introspectable except DNNs though), but it is really more declarative. Of course, instead of some concrete concept, there can be a variable, which will be grounded by a general reasoning system not specifically designed for this task.</p><p>Furthermore, we can have a general knowledge that if X is left to Y, then Y is right to X — so we can infer one specific fact from another. In fact, in the case of the question “<em>Is the red cube left of the green pyramid?</em>” one can first attend the red cube and then examine the image to the right of it. However, this example also shows that “left” is not used here as a predicate of two arguments, but rather as an instruction to examine a part of an image. At the same time, humans can first independently find two objects and then check their relative location.</p><p>Interestingly, the use of functional mappings instead of predicates to represent relations corresponds to <a href="https://en.wikipedia.org/wiki/Skolem_normal_form">Skolemization</a> in logic. Indeed, if we want to prove that for every X there exists such Y that p(X, Y) holds, then we can instead prove that p(X, f(X)) holds for every X. Instead of searching for Y for every given X using a general reasoning engine, we compute it directly. Like our cognitive system can know that left(X,Y) :– right(Y,X), it can also know that Y=f(X) :– left(X,Y), and use this knowledge to efficiently satisfy the query containing “left” as a predicate of two arguments (because it will know that in order to prove left(X,Y), it is enough to calculate Y=f(X)). Moreover, the cognitive system can have both “left” as a grounded predicate and “f” as a grounded schema, so, in principle, it will be able to follow any way of reasoning like humans.</p><p>Similarly, the classifier <em>y</em>=f(<strong>x</strong>) that outputs class labels <em>y</em> for given patterns <strong>x </strong>can be considered as a Skolem function for some predicate p(<strong>x</strong>, <em>y</em>), in which truth value can be calculated for a pair of <strong>x</strong> and <em>y</em>. Here, one can also find an interesting connection with the relation between probabilistic discriminative and generative models. A reasoning system, which has knowledge that <em>y</em>=f(<strong>x</strong>) :– p(<strong>x</strong>, <em>y</em>) or that the discriminative model approximates posterior probabilities specified by the generative model, can decide to use the classifier even if the query is in the form of a declarative query with variables to be grounded.</p><p>What is important is that OpenCog has trainable inference control capabilities, as highlighted in this <a href="https://blog.singularitynet.io/introspective-reasoning-within-the-opencog-framework-1bc7e182827">post</a>, so depending on the circumstances, it can potentially learn to choose a better line of reasoning.</p><p>Of course, the tricky part is to integrate all these capabilities together in one end-to-end trainable system that doesn’t require too much specific hand-coded knowledge.</p><p>The SingularityNET platform will be able to facilitate this research by bringing together AI services and agents of different nature including deep neural networks, real-world knowledge bases, and general reasoning systems.</p><h3>How Can You Get Involved?</h3><p>If you would like to learn more about SingularityNET, we have a passionate and talented community which you can connect with by visiting our <a href="https://community.singularitynet.io/">Community Forum</a>. Feel free to say hello and to introduce yourself <a href="https://community.singularitynet.io/c/hello">here</a>. We are proud of our developers and researchers that are actively publishing their research for the benefit of the community; you can read the research <a href="https://blog.singularitynet.io/research/home">here</a>.</p><p>For any additional information, please refer to our roadmaps and<a href="http://singularitynet.io/"> subscribe to our newsletter</a> to stay informed about all of our developments.</p><p><a href="https://blog.singularitynet.io/singularitynet-releases-updated-roadmaps-d4aa2c0d7bc7">SingularityNET Releases Updated Roadmaps</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*C-xzKvtG6O6aeueqX1q2rw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a8f84ca09b39" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/towards-declarative-visual-reasoning-or-not-a8f84ca09b39">Towards Declarative Visual Reasoning… Or Not?</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling Cognitive Visual Question Answering]]></title>
            <link>https://medium.com/singularitynet/enabling-cognitive-visual-question-answering-a93febd454a7?source=rss-c6e960c4fe5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/a93febd454a7</guid>
            <category><![CDATA[deep-neural-networks]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[unsupervised-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Alexey Potapov]]></dc:creator>
            <pubDate>Thu, 30 Aug 2018 19:25:38 GMT</pubDate>
            <atom:updated>2018-08-30T19:25:38.076Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Exploring a hybrid approach to visual question answering through deeper integration of OpenCog and a Vision Subsystem.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Ip5_AqPoC_gbswAO" /></figure><h3>Introduction</h3><p>Let us imagine a scenario in which <a href="https://en.wikipedia.org/wiki/Sophia_(robot)">Sophia</a>, the social humanoid robot, is asked a simple question by someone:</p><p>“<em>Sophia, is it raining?</em>”</p><p>If Sophia says “yes” to the question, does she know <em>why </em>she gave that answer? In other words, <em>how</em> does Sophia answer the question?</p><p>The ability to answer questions about visual scenes, in other words, the ability to perform <a href="https://tryolabs.com/blog/2018/03/01/introduction-to-visual-question-answering/">Visual Question Answering</a> (VQA) is something that comes naturally to humans. However, the current state-of-the-art models of VQA leave much to be desired.</p><p>One of the control systems used to <a href="http://www.hansonrobotics.com/how-sophia-the-robot-works-goertzel/">operate</a> Sophia is <a href="https://opencog.org/">OpenCog</a>, a <a href="http://cogarch.ict.usc.edu/">cognitive architecture</a>. OpenCog operates over a knowledge base represented as a hypergraph called <a href="https://wiki.opencog.org/w/AtomSpace">Atomspace</a>. For Sophia to accurately answer questions about visual scenes, the content of those scenes needs to be made accessible to <a href="https://opencog.org/">OpenCog</a>.</p><p>In an earlier <a href="https://blog.singularitynet.io/deep-semantic-gap-to-be-bridged-for-singularitynet-e9270d67b7ad">research article</a>, we discussed that the simplest way to achieve that would be to process images with a Deep Neural Network (DNN) and to insert the descriptions of the images into Atomspace. One example of such a DNN would be <a href="https://pjreddie.com/darknet/yolo/">YOLO</a>, which describes an image with a set of labeled <a href="https://computersciencewiki.org/index.php/Bounding_boxes">bounding boxes</a>.</p><p>Although such a simple approach can be useful for semantic image retrieval, it will not be sufficient for answering arbitrary visual questions.</p><p>For instance, the questions “<em>is the child happy?</em>” and “<em>is the boy jumping?</em>” can refer to the same bounding box. This makes it clear that one label per bounding box is not enough. Furthermore, it would be difficult to assign all possible relevant labels by the image processing system in advance. The insufficiency of such a simple approach becomes even more obvious when the questions require analyzing visual features and not labels. For example, it might be asked “<em>are the people looking in the same direction?</em>” or perhaps “<em>are the chairs similar?</em>”</p><p>It is obvious that in order to answer such questions, deeper integration of the cognitive architecture and a vision subsystem is required. The question, therefore, is how do we achieve such a deeper level of integration?</p><h3>Grounded Predicates</h3><p>OpenCog supports <em>grounded predicates. </em>Simply put, these are predicates with truth-values that are calculated by some external procedures, in particular by DNNs.</p><p>In our previous <a href="https://blog.singularitynet.io/deep-semantic-gap-to-be-bridged-for-singularitynet-e9270d67b7ad">research article</a>, we shed light on how OpenCog’s <a href="https://wiki.opencog.org/w/The_Pattern_Matcher">Pattern Matcher</a> can be used to execute queries like, find a video frame containing a man in a car. If the corresponding labels are assigned correctly to the bounding boxes, the retrieval will be successful.</p><p>The Pattern Matcher can be used in the same way even if we do not assign labels to the bounding boxes and connect them to their corresponding Concept Nodes by Inheritance Links. That is because<strong> the Pattern Matcher can use the grounded predicates instead</strong>. In such an approach, rather than verifying the presence of the corresponding Inheritance Link, the Pattern Matcher will simply evaluate the corresponding grounded predicates.</p><p>To understand how this approach will work, let us first consider a simple “yes” or “no” question:</p><p><em>“Are the zebras fat?</em>”</p><p>To parse the question, OpenCog utilizes the <a href="https://en.wikipedia.org/wiki/Link_grammar">Link Grammar</a> parser and the <a href="https://wiki.opencog.org/w/RelEx_Dependency_Relationship_Extractor">RelEx</a> Dependency Relationship Extractor. The Link Grammar parser will produce something like this:</p><pre>(S are.v (NP the zebras.n) (ADJP fat.a) ?)</pre><p>or in the graphical form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/0*xMsEy3iDFD5cPU-A" /><figcaption><em>Link Grammar parse tree</em></figcaption></figure><p>The RelEx form will simply be _predadj(zebra, fat).</p><p>This can be further converted to the query in <a href="https://wiki.opencog.org/w/Atomese">Atomese</a> , which is an internal language of OpenCog, to represent knowledge and thoughts. Over here, we use a Scheme syntax:</p><pre>(SatisfactionLink</pre><pre>  (TypedVariable (VariableNode “$X”) (Type “ConceptNode”))</pre><pre>  (AndLink</pre><pre>    (InheritanceLink (VariableNode “$X”) <br>                     (ConceptNode “BoundingBox”))</pre><pre>    (EvaluationLink</pre><pre>      (GroundedPredicateNode “py:recognize”)</pre><pre>      (ListLink (VariableNode “$X”) (ConceptNode “zebra”)))</pre><pre>    (EvaluationLink</pre><pre>      (GroundedPredicateNode “py:recognize”)</pre><pre>      (ListLink (VariableNode “$X”) (ConceptNode “fat”)))))</pre><p>In the syntax above, we have one grounded predicate recognize implemented in Python. Furthermore, we could have used grounded predicates like zebra and fat directly, but passing Concept Nodes (which can be connected to other pieces of knowledge) to a single predicate is more flexible.</p><p>Lastly, the Pattern Matcher will automatically find such a <em>grounding</em> for Variable $X, which is a bounding box. For this Variable, the evaluation of the grounded predicate recognize (implemented as a DNN) will give high truth value for both zebra and fat.</p><p>We can also convert other questions to the Pattern Matcher queries. For example, the question “<em>What color is the plane?</em>” can be automatically converted to the Relex form:</p><pre>_det(color, _$qVar);_obj(be, plane);_subj(be, color)</pre><p>After which, the following Pattern Matcher query can be constructed:</p><pre>(BindLink</pre><pre>  (VariableList</pre><pre>    (TypedVariable (Variable”$B”) (Type “ConceptNode”))</pre><pre>    (TypedVariable (Variable “$X”) (Type “ConceptNode”)))</pre><pre>  (AndLink</pre><pre>    (InheritanceLink (VariableNode “$B”) <br>                     (ConceptNode “BoundingBox”))</pre><pre>    (InheritanceLink (VariableNode “$X”) (ConceptNode “color”))</pre><pre>    (EvaluationLink</pre><pre>      (GroundedPredicateNode “py:recognize”)</pre><pre>      (ListLink (VariableNode “$B”) (ConceptNode “plane”)))</pre><pre>    (EvaluationLink</pre><pre>      (GroundedPredicateNode “py:recognize”)</pre><pre>      (ListLink (VariableNode “$B”) (VariableNode “$X”))))</pre><pre>  (ListLink (VariableNode “$B”) (VariableNode “$X”)))</pre><p>Here, we need two variables to be grounded. The first variable is the bounding box, while the other is the answer to the question, which is passed to recognize. The Pattern Matcher will consider only those groundings for this variable, which correspond to concept nodes inherited from the Concept color. Although the knowledge about such ontological relations should be presented in Atomspace, it can also be directly extracted from the training set.</p><h3>Comparison with pure DNN models</h3><p>One might wonder, why don’t we use purely DNN-based solutions that have state-of-the-art results on existing VQA benchmarks. The reason is simple; such DNN-based solutions aim to solve specific tasks and are trained to exploit the biases of specific datasets. Such models, therefore, are not <a href="http://cogarch.ict.usc.edu/">cognitive architectures</a>.</p><p>More specifically, VQA models are trained to map pairs (image, question) to one-word answers and cannot perform anything else. In contrast, cognitive architectures answer visual questions not by a stand-alone model but rather by an integrative system that can also perform other actions. Such actions may depend on the answer or even influence it.</p><p>Perhaps an analysis of DNN models might help to reveal the possible improvements of the hybrid system that possesses both symbolic and subsymbolic components. Therefore, let us consider one of the recent state-of-the-art <a href="https://arxiv.org/abs/1803.07724">VQA models</a>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ogoxBREUBb7PvVvC" /><figcaption><em>A state-of-the-art </em><a href="https://arxiv.org/abs/1803.07724"><em>DNN model</em></a><em> for VQA</em></figcaption></figure><p>This model relies on bounding boxes with a pre-trained high-level feature extractor. It uses standard word embeddings pre-trained on large text corpora that were not related to the VQA datasets. Furthermore, the model uses an “attention” mechanism that assigns weights to bounding boxes depending on their relevance to the question, based on its trainable embedding calculated by the GRU.</p><p>Another <a href="https://arxiv.org/abs/1707.07998">VQA model</a>, rather than using the whole question embedding, used individual words to calculate attention weights for the bounding boxes.</p><p>In essence, such <em>attention</em> is similar to recognizing if the bounding boxes correspond to certain words performed by the DNN-based grounded predicates executed by the Pattern Matcher. The difference is that the VQA models use word embeddings matched with visual features, instead of separate classifiers. Such an approach can be implemented in OpenCog; we would only need to implement the grounded predicate recognize in the following form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/0*wobmMA1cZHbqqKBw" /><figcaption><em>Implementation of the grounded predicate that matches visual features with the word embedding</em></figcaption></figure><p>One interpretation of this network would be to consider it as a predicate of two arguments, that takes both the <strong>word embedding</strong> and <strong>visual features</strong> as input.</p><p>What we find interesting is that such a construct can be generalized with the use of <a href="https://blog.singularitynet.io/just-deep-is-too-flat-b3813e2242f1">HyperNets</a>, which can take the <strong>word embedding</strong> as input and return a network that can then accept the <strong>visual features</strong> as the input — giving us the probability with which those features correspond to the given word.</p><p>However, despite the similarities,<strong> there are some considerable differences between the two approaches</strong>. For instance, the attention mechanism in the DNN-based VQA models operates by first assigning weights to the bounding boxes, the features of these bounding boxes are then summed, after which the bounding boxes are fused with the question embedding and passed to the classifier. Such a classifier might be considered to be similar to a set of separately grounded predicates trained to recognize each concept. However, the classifier is not applied to the visual features of <em>each</em> bounding box. Instead, it is applied to the summed features of all the bounding boxes filtered with the use of question embedding.</p><p>In the construction outlined above, if the question is “<em>What color is the car?</em>” only those features are kept, which are relevant to the question so that the classifier can answer red instead of car. Such a construction is somewhat strange. To illustrate why let us compare the questions:</p><p>“<em>Is the car red?</em>” and “<em>What color is the car?</em>”</p><p>When presented with the first question, the attention mechanism will be responsible for selecting the bounding boxes corresponding to the notion of red(car), whereas, if presented with the second question, the classifier will recognize the selected bounding boxes as red. In contrast, OpenCog’s Pattern Matcher will do much more similar operations when presented with the two questions.</p><p>More importantly, not all questions will have such straightforward formalization. For example, the question: “<em>Is it raining?</em>” does not mean that there is a bounding box which can be characterized as it and raining. Rather, the model should look for umbrellas and clouds.</p><p>We can also recognize any bounding box as it and recognize umbrellas as raining. That is actually what DNN-based solutions also do; they simply associate the positive answer to this question with the presence of umbrellas. However, the DNN-based solutions can, in principle, account both for clouds and umbrellas by summing up visual features of the corresponding bounding boxes.</p><p>Similarly, questions like “<em>Is he eating?</em>” or “<em>Is the room dark?” </em>require the DNN model to attend to several bounding boxes. Although the weighted summation is a very simplified way to do that, it somehow works.</p><p>The problem, of course, <strong>is that the DNN model does not know<em> </em>why it answers “yes” to the question “Is he eating?”</strong></p><p>The model simply matches the summed visual features with the holistic question embedding. As we have said earlier, although such holistic matching is robust, it is far from perfect. If it encounters an unexpected question, it can give a non-sensible answer.</p><p>For example, when fed the following image and asked the question “<em>What is tree doing?</em>” The demo DNN model <a href="http://vqa.cloudcv.org/">at this site</a> answers with a 67% certainty that it is eating and attaches a 13% certainty to the answer that it is walking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*e1zqdLZM9U1T3Ofo" /><figcaption><em>The image to which the </em><a href="http://vqa.cloudcv.org/"><em>model</em></a><em> replies that the “tree” is “eating” and “walking.”</em></figcaption></figure><p>Therefore, we believe that a hybrid approach that works at both the feature and the symbolic levels can do better. Although, such an approach is more challenging to implement.</p><p>For example, OpenCog contains a module called <a href="https://wiki.opencog.org/w/Pattern_miner"><em>Pattern Miner</em></a>, which is intended for finding patterns in Atomspace. In particular, we believe that it might be able to find that the concept of raining is associated with the concepts umbrella and cloud, while the concept of eating is associated with the concepts of animals or human and food.</p><p>If that is the case, then hopefully a future model of Sophia that would be operated through SingularityNET (which will leverage the OpenCog framework) <strong>will be able to explain why she thinks it is raining</strong> when asked the question: “<em>is it raining?</em>” Unlike the models that match a mixed visual feature vector with the question embedding, a SingularityNET operated Sophia would hopefully be able to find that the concept raining is associated with several other concepts such as umbrella, clouds and water drops.</p><h3>What are the challenges?</h3><p>Of course, there are still several difficult challenges that need to be overcome. For instance, mapping from natural language questions to the form understandable by OpenCog needs to be learned. We believe that SingularityNET’s <a href="https://blog.singularitynet.io/how-singularitynet-is-advancing-unsupervised-language-learning-2679dbfca645">Unsupervised Language Learning </a>project can contribute to solving this problem.</p><p>We also believe that a deepening of symbolic-subsymbolic integration is necessary. More specifically, training signals should be propagated through symbolic inference traces — not only to reach the DNNs of the vision subsystem (which is trained separately now) but also to modify the truth-values of the nodes and links constituting the knowledge base.</p><p>Lastly, further development of the vision subsystem is also required. For instance, to robustly recognize that “<em>the boy is holding the cup</em>” one might need to perform a semantic segmentation or perhaps even a 3D reconstruction. It would be quite the challenge to make such finer image details accessible from the symbolic level. One solution to overcome that challenge might be to construct a generative model of a scene that spans both the symbolic and subsymbolic levels. Such a generative model might also be necessary to deal with other tasks such as text-to-image transformation.</p><p><strong>How can you get involved?</strong></p><p>We will report on our progress in overcoming the challenges that we face in the future research articles. You can visit our<a href="http://community.singularitynet.io/"> Community Forum</a> to chat about the research mentioned in this article.</p><p>Over the coming weeks, we hope to not only provide you with more insider access to SingularityNET’s groundbreaking AI research but also to share with you the specifics of our development.</p><p>For any additional information, please refer to our roadmaps and<a href="http://singularitynet.io/"> subscribe to our newsletter</a> to stay informed regarding all of our developments.</p><p><a href="https://blog.singularitynet.io/singularitynet-releases-updated-roadmaps-d4aa2c0d7bc7">SingularityNET Releases Updated Roadmaps</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ksgSjJ9_h4YMcGrn" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a93febd454a7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/singularitynet/enabling-cognitive-visual-question-answering-a93febd454a7">Enabling Cognitive Visual Question Answering</a> was originally published in <a href="https://medium.com/singularitynet">SingularityNET</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>