Natural Language Cognitive Architecture
Natural Language Cognitive Architecture
David K Shapiro
Copyright © 2021 by David K. Shapiro
Website: https://www.linkedin.com/in/dshap-automator/
Special Thanks
Preface
The right information at the right moment changes lives. The right information at the right
moment saves lives.
This book is meant for people who want to implement and experiment with
NLCA. Secondarily, this book is for anyone who is curious about AGI and
cognitive architectures. For those attempting to implement NLCA, you should
already possess intermediate programming skills (such as Python) as well as
some knowledge of databases and APIs. All other readers should have at least
some understanding of AI and machine learning concepts – I will do my best to
explain ideas with analogies, metaphors, and diagrams but some background
knowledge will always help.
Background
I grew up watching TV shows and movies such as Star Trek: The Next
Generation. Commander Data, an android, was an optimistic example for the
future of robotics and AI. Here, we had a machine with superhuman strength
and intelligence who was (almost) never dangerous and (almost) always
benevolent. His primary goal, his central motivation, was to “become more
human”. In machine learning, Data’s goal to become more human would be
called an “objective function”; a metric that he is trying to optimize. In the
context of AGI and cognitive architecture, Data’s goal of becoming more
human is what I call a “Core Objective Function”. A Core Objective Function
is a clear purpose stated in natural language. There are three Core Objective
Functions in NLCA: reduce suffering, increase prosperity, and increase
18 | P a g e Natural Language Cognitive Architecture
understanding. Do not get bogged down on those functions right now, there is
an entire chapter on the Core Objective Functions later.
All the while, my day job is systems engineering – I work with huge, complex
computer systems. Some days I handle petabytes of data. Other days I maintain
datacenter hardware or repair million-dollar-per-hour business applications. My
career has me working with databases, applications, servers, cloud, automation,
and microservices on a daily basis. This professional focus has given me a
unique perspective on how to go about constructing an intelligent machine such
as Commander Data.
One last caveat before we dive into the summary of NLCA: this is very much
a work in progress. While I have successfully implemented or demonstrated all
of what you will read about in this book, there are some components that are
still not performing up to snuff. The reason for my releasing this book
prematurely is so that more minds can work on these problems – I cannot do it
all by myself! I have many divergent avenues of investigation, so if I want to
explore them, I will need help. My time and cognitive resources are limited so
this book is as much a recruiting tool as anything else.
Let us start by breaking down the components of intelligence – what are the
internal and external behaviors that we expect of intelligent entities? I found
that Bloom’s taxonomy, a system developed for teaching, is a good way to break
down the behaviors and outcomes of learning. After all, the current definition
of AGI is the ability to learn and understand anything a human can. In
descending order of complexity and difficulty, Bloom’s taxonomy is:
These two behaviors, spontaneous learning and creation, are the goalposts I
have set for myself. My architecture, NLCA, must be able to spontaneously
learn anything and, ultimately, be able to create novel and valuable intellectual
output. Right now, the most sophisticated AI systems can win at any game, yet
we have no AI capable of building games. An AGI should be able to learn to
play any game, but also deconstruct the process of writing a game, write the
code for the game, and test the game.
Introduction P a g e | 21
Philosopher in a Library
Several animals have evolved language, including prairie dogs and dolphins.
In all cases, language evolves primarily due to social pressures. There are many
evolutionary advantages to social and communal living – safety in numbers! But
these advantages come with the added complexity of getting along. Social living
requires us to keep track of social order and fairness, which means we must
transmit our needs and observations to our tribe. Once we achieve the ability to
share what is in our mind, we also gain the ability to share hunting strategies and
food locations – an incredible evolutionary advantage! The need for speech then
creates its own explosive evolutionary pressure. Dolphins, for instance, have
adaptive hunting strategies. In captivity, it has been shown that dolphins can
communicate their intent to improvise with each other before doing tricks.
Prairie dogs can describe threats to their den. Koko the gorilla was taught to
communicate with sign language, and she was able to react to the news of
Robin Williams’ death by expressing her sadness. More comically, she once
ripped a sink off a wall and blamed her kitten. This single anecdote reveals
much about the evolution of language and Koko’s abilities. First, she knew that
what she did was wrong. As a social species, gorillas must keep track of right
and wrong, and who to trust. But also, as a social species, gorillas can use
deception and misdirection – she lied so that people might not know of her
wrongdoing. This means that gorillas possess some “theory of mind” – they are
aware of their perspective as well as other perspectives. They keep track of what
is and is not in various minds. Gorillas have not naturally evolved language, but
Koko clearly has much of the prerequisite neural machinery for language. This
fact provides evidence that several social cognitive abilities predate spoken
language, and that those abilities must be in place before language can evolve.
Consider just how much we humans learn from books. Most of our
knowledge and abilities are captured in text. Whether you want to build a moon
rocket or perform surgery – most of the knowledge to do so is recorded in
natural language. Natural language, in this case, is a specific term referring to
languages that have organically emerged from human cultures. These languages
include those such as English, Farsi, Japanese, and Swahili. The alternative kinds
of languages are constructed languages and computer languages. The most
famous constructed language is Esperanto, but many fictional worlds also
contain constructed languages, such Elvish from JRR Tolkien’s Lord of the Rings.
Computer languages include such examples as Java and Python, two of the
most popular programming languages in the world.
Natural language is infinitely flexible and can capture almost any idea or
experience. Our brains have an internal language that Steven Pinker refers to as
mentalese – inarticulate and abstract thoughts that are not readily rendered into
language but can be translated if needed. For instance, we do not have many
words for smells, even though we can recognize thousands of them. Something
might smell sweet or acrid, but most of the time, we say something smells like
something else, like bananas or roses or wet dog. Another example – you do not
plan your footsteps in natural language, but if pressed, you can describe your
path-planning process with words. Either way, walking is mostly handled by the
brain stem and therefore falls below the concern of executive cognitive
reasoning. Walking is not an intellectual task, therefore immaterial to AGI. All
thoughts and sensations, therefore, are just information and signals with
representations in the brain, mentalese. Mentalese can be translated into any
number of representations, so why not represent it entirely in natural language?
Works of fiction do this quite well, where authors convey all five senses,
internal monologue, and even abstract thoughts, memories, and dreams all in
natural language. Therefore, I believe that natural language is a sufficient
medium to represent any idea, experience, sensation, thought, or memory.
Introduction P a g e | 23
Since written language can represent everything, then it follows that any
intellectual activity may be approximated by manipulation and processing of
text. In computer science, the domain of text-based processing and
manipulation is called NLP – Natural Language Processing. Therefore, my
assertion is that NLP is more than enough to achieve AGI. Now, while I
believe that text-based intelligence will be more than adequate to construct an
AGI, I do not believe that NLP will be the only method. There are competing
theories about what is and is not necessary to achieve AGI, and I believe that
there will be single-mode architectures, such as NLCA, and multimodal
architectures that integrate several types of representations. For instance,
someone else might come along and create an AGI that “thinks” in images and
sounds, rather than language. Increasingly exotic and abstract representations
may be possible in the future, but such speculation falls beyond the scope of
this book.
Lastly, imagine that the philosopher keeps a diary or a journal about their
thoughts and activities in the library. They never send their diary out. Imagine
they receive a letter with novel and interesting concepts, and they wish to
continue thinking about those concepts after they have researched and sent out
a reply letter. They perform many of the same activities that they did to
compose an outbound letter, but instead they record this new information in
their diary. We humans use diaries to record our thoughts and feelings, to help
us make sense of life and its complexities. Humans who keep diaries tend to be
more emotionally intelligent and successful. This secondary behavior of keeping
an internal diary is also a key component of NLCA.
24 | P a g e Natural Language Cognitive Architecture
The Natural Language Cognitive Architecture is the blueprint for a machine
that thinks in plain English (or whatever language you choose), and this
philosopher-locked-in-a-library model is one way to think about the behaviors
that amount to artificial general intelligence.
I propose that natural language is the best medium for an AGI’s cognitive
architecture for a few reasons. First, natural language is infinitely flexible.
Almost every sentence you ever read or utter will be entirely unique, and yet
your brain can interpret and synthesize sentences. This means that any concept,
event, idea, or object can be described with natural language. Secondly, natural
language lends itself to interpretability – we do not want an AGI that will be a
blackbox! Instead, we want to be able to deconstruct every decision our AGI
makes and observe its thinking in real-time. With natural language, the AGI
cannot obfuscate its intentions. Thirdly, NLP is a large and well-established
domain of computer science – we have all the tools we need!
Longhand Demonstration
In this demonstration, I will walk you through the process of how NLCA
works by breaking down learning and cognitive behaviors into text-based
functions. This demonstration is not completely exhaustive of NLCA’s
functions, but it will orient you to the task of translating cognitive functions
into text-based functions.
Look at your surroundings and recent events. This forms your “context”.
While many of your observations and sensations are not represented in
language, you could describe your context with words if you like. You can
describe where you are, what you are doing, what you are thinking, your current
actions, and goals all in natural language. The context is your external state.
What about your internal state? Your internal state is your stream of
consciousness or working memory. This is your subjective experience of having
thoughts, sensations, and self-awareness. It also contains your identity and
values, or ego. Once again, much of your internal state is not automatically
represented in natural language but you could easily describe your internal state
with words. This internal state is what I call the “corpus” in my theory.
You can test NLCA yourself with the following procedure. Grab a pen and
paper and transcribe your thoughts and decision-making process.
I will walk you through the logic and practical implementation of this exercise
in machine code throughout the rest of this book. I will also provide many
examples of transformer outputs so you can see exactly what generative
transformers are capable of and how to use them. In all cases, it will have a
similar format to the above, where human-written text is bold and machine-
written text is plain. I used OpenAI’s DAVINCI-INSTRUCT-BETA engine to
generate all such output unless otherwise stated. OpenAI is a non-profit
research company founded by Elon Musk, among others. The DAVINCI-
INSTRUCT-BETA engine is one of their AI services, a text-based deep
learning tool that will be described in greater detail in chapter 1. The
DAVINCI-INSTRUCT-BETA engine is part of their famous GPT-3
technology.
Up Next
This book is divided into five parts. This first part, the introduction, is what
you are presently reading. In this introduction I gave you some background
about myself, my motivations, and my goals. Then I established some
definitions and expectations about AGI. Lastly, I gave you an analogy for
NLCA and an example so you can start with a high-level understanding of how
my cognitive architecture works. Starting with this framework, you should be
able to integrate the rest of the book and develop a solid mental model of
NLCA.
The second part, Part 1, will start by defining and describing the core
technology underpinning NLCA: generative transformers. Next, I will describe
Introduction P a g e | 27
cognitive architectures, what they are, and how they are used. Lastly, I will give
a broad overview of NLCA. This thirty-thousand-foot-view of NLCA will then
be iterated upon in Part 2.
Part 2 will take a much closer look at each component of NLCA, examining
the theory and implementation of each. Part 2 will focus on describing the
design paradigms of each component as well as how every component interacts
with each other.
Part 3 will discuss important topics around and within NLCA, such as the
practical steps to implement NLCA in code and the ethical concerns of NLCA
and AGI. This section will also address issues such as the control problem,
inner alignment, and outer alignment – how do we implement AGI in such a
way that it will not murder us all?
The second chapter describes cognitive architectures: what they are and why
they are important. After all, this book proposes a new type of cognitive
architecture, so it is critical to understand what already exists in this field.
The last chapter of this book introduces you to NLCA. I will give you a high-
level overview of the architecture of NLCA and describe the major
components.
Chapter 1 – Transformers
Figure 2 – Transformers are fed text instructions; their output is also text.
But at least you had a life, and not just a cold corpse
Lynn is a stressed out grad student. What are some things that
might make her feel better?
1. Getting a massage.
There are two overarching kinds of prompts: zero-shot and few-shot. With
zero-shot, you give the transformer instructions or text, and it just goes, such as
the previous two examples. With few-shot prompts, you include one or more
examples of the output you want to see, and the transformer learns to generalize
the instructions from there. The two prior examples are zero-shot because I
gave the transformer no examples, only instructions. The bold part of the
previous examples is the prompt while the plain text was generated by the
machine.
Static prompts are written by hand and do not change. These have limited
flexibility but sometimes that is a good thing, such as when you want the morals
and values of the system to remain the same. Static prompts form the backbone
that gives AGI entities consistent beliefs and behaviors. Think about Isaac
Asimov’s “Three Laws of Robotics”. Such a set of imperatives could be
implemented as a static prompt.
Composed prompts are partially static with a few sections that can be
populated (filled in) on the fly. Sometimes the blanks are small – just a few
words or a question. Other times the blanks are several paragraphs, as with
question-answering problems. With a question-answering prompt you might
populate the question and/or some text-based knowledge with which to answer
the question. Say you want to ask a question about Venice, Italy, so you
populate the prompt with the Wikipedia article on Venice and your question.
Unfortunately, most Wikipedia articles are too large for transformers today, so
you need to pare down the input. More on that topic later.
34 | P a g e Natural Language Cognitive Architecture
Dynamic prompts are mostly (or entirely) created by previous outputs from
static or composed prompts. This means that the prompt can be completely
different based on the needs of the system. This concept of feeding the output
of one prompt into the input of the next is called prompt chaining. Prompt
chaining is one of the key abilities that enables transformers to think about
anything and address any situation, especially when combined with facts from
empirical sources.
What is a transformer?
Generative transformers are the keystone technology that enabled me to
create NLCA. The transformer architecture was originally invented by Google
in 2017, and it is an evolution of previous deep neural network designs, such as
LSTM (Long-Short Term Memory) and RNN (Recurrent Neural Network).
These two types of neural networks eventually gave rise to transformers. The
key thing to know is that a transformer uses an encoding/decoding loop. This
loop “transforms” an input into an abstract, embedded representation like
mentalese, called a vector. A vector is just a series of numbers. Then the
transformer uses that abstract internal representation to “decode” the output
into something else, depending on the task. If this sounds like a blackbox that is
Chapter 1 – Transformers P a g e | 35
because it is. There are many researchers working on understanding these
abstract internal representations so that we can explain exactly how
transformers are able to perform tasks. We can, however, empirically
demonstrate their value, accuracy, and reliability.
For all intents and purposes, transformers are textual autocomplete engines.
However, instead of just completing the next word or two, I use them to
complete sentences and paragraphs. These types of transformers are called
generative transformers. The largest transformers today are trained on hundreds
36 | P a g e Natural Language Cognitive Architecture
of gigabytes of text – so much that it would take a single person hundreds of
lifetimes to read it all.
These embedded concepts are akin to human mental models. A mental model is
an internal representation of how something works and behaves. For instance,
you might have a mental model of your dog – you know what it needs and
prefers, as well as how to interact with it. Mental models allow us humans to
rapidly interact with our world and predict outcomes.
Lastly, large transformers today can only handle small amounts of text before
they forget what they were doing. You, as a human, can read and retain an
entire book, but transformers can only process a few paragraphs with any level
of cohesion, thus their performance falls apart with complex or long tasks. This
means that we need to break problems down into smaller steps, which adds a
huge design burden.
I expect these problems will see rapid improvement over the next few years.
As transformers improve, it will be easier, faster, and cheaper to implement
NLCA. For instance, the small text window is presently a limitation of
transformer architecture and a phenomenon called “attention” – the longer a
task is, the more sophisticated the attention mechanism must be. This is an
active field of study, both in transformers and in cognitive architectures. I also
hope to see additional controls over transformers, such as the ability to switch
38 | P a g e Natural Language Cognitive Architecture
off confabulation and bias. Again, some of those problems can be addressed
simply with fine-tuning, but creating fine-tuning datasets is cumbersome, so
hopefully we see better, more flexible transformers soon.
Summary
Transformers are a powerful new technology, only a few years old.
Transformers can generate any text in a similar way to autocomplete on your
phone and Google searches. The difference, though, is that larger transformers
can autocomplete entire paragraphs. Furthermore, transformers are trained on
millions of pages of text, so they “know” a lot about the world, including
complex concepts like philosophy and science.
The primary way to interact with transformers is to give them a little bit of
text, which serves as “food for thought”. Whatever text you give a transformer
is called a prompt. Prompts tell the transformer what kind of text to generate.
Prompts can include instructions, questions, facts, and even morals.
Think of putting your hand on a hot stove by mistake. You receive input –
heat and pain – and your brain generates a signal to protect yourself, to
42 | P a g e Natural Language Cognitive Architecture
withdraw your hand. This input-process-output cycle is extremely fast, and it
results in the cessation of the pain: alleviation of suffering. The alleviation of
suffering (response to negative stimulus) is universal to all living things, and
figures into the design of NLCA.
Now think about the problem of landing on the moon. How do you do it?
You go to college to study physics and engineering and network with fellow
engineers. Finally, you land a job with NASA or another space agency. Then
you engage in countless input-process-output loops as you tackle one problem
after another. Even as you watch your rocket ascend into the atmosphere, your
brain is taking in input, interpreting the telemetry from the rocket, and
generating output – especially when it succeeds, and you cheer wildly. All the
while, the rocket’s computers are performing millions of input-process-output
loops as it measures the temperature and fuel flow going into its engines,
checking its course and trajectory, and always on the lookout for mission-critical
faults.
There are a few structural differences between NLCA and Soar as well as
numerous differences in implementation. First, Soar treats long term and short-
term memory differently where NLCA does not, instead, NLCA uses several
attention mechanisms to prioritize memories and metadata to keep track of
types of memories. Second, Soar does not attempt to model the stream of
consciousness or inner monologue. Soar does model many other aspects of
human cognition, however, by incorporating and modeling theories of
intelligence, learning, memory, and perception. Soar is more aptly suited to tasks
like robotics and autopilots than NLCA. If they were to be transformed into
people, Soar would be a fighter pilot, while NLCA would be a philosopher.
Summary
Cognitive architectures have been around for a few decades and are used
extensively in robotics and simulation, which includes video games. Cognitive
architectures are designed to mimic the brain or the mind of humans. Some
architectures favor the psychological mind and cognition while others try to
emulate the physical construction of the brain.
Architecture Snapshot
At the risk of oversimplifying and underselling my work, NLCA is merely the
merging of transformers with cognitive architectures. Structurally, NLCA is
composed of two loops that share a common database. The outer loop is based
on the universal model of robotics (input-processing-output). The inner loop is
based on a combination of inner monologue and diary writing behaviors in
humans. The link between the two loops, the shared database, allows these two
otherwise independent loops to influence and build from each other.
Outer Loop
The outer loop contains three steps: context, corpus, and output – like the
universal input-processing-output loop of robotics. This is considered an “open
46 | P a g e Natural Language Cognitive Architecture
loop” because it is not self-contained, it is “opened” to the environment. There
are several key differences at each step, hence the unique names. The context is
a particular type of input, where everything is captured in text as you saw in the
longhand demonstration at the beginning of the book. The corpus is not just
mere processing, but also includes memory, inference, and planning, all in one
step. Lastly, the output is not necessarily motor or verbal action, as
demonstrated with the philosopher-in-a-library analogy. The output is a text
payload which can include all kinds of output behaviors, depending on the
specific purpose of your NLCA implementation.
The context is passively generated from the environment in the same way
that our human senses are autonomic. In some cases, the context is generated
from sensors like cameras and microphones while in others it is received as chat
logs, emails, or other text data. The only requirement is that the context is like a
letter, a payload of natural language text. Sensor telemetry, such as cameras and
microphones, can easily be transcribed with technologies such as automatic
video annotation (using a machine to describe images and videos with text) and
ASR (automated speech recognition). All signals are just data, and all data can
be rendered as text.
Lastly, the output is derived from the corpus with special prompts. The output
prompt needs to be specially crafted depending on the use case for NLCA. For
example, an output prompt for a chatbot will be structured differently than an
output prompt for email, even though the ultimate output is still text. In other
cases, such as speech, video game character control, and robotics, the output
Chapter 3 – NLCA Overview P a g e | 47
prompt will need further interpretation. For instance, a speech output might be
I say “Please do not step on the grass” while a robotic command might be: Locomotion:
I walk towards the car but stop one meter away. The robotic platform would then need
to interpret that command, which will be discussed later in this book.
Inner Loop
Meditation, contemplation, inner monologue, dreams, and diaries were all the
inspiration for the inner loop. These are “closed loop” behaviors because they
all stay inside your head and no outside input is required. When you sit down to
write in your diary or journal, how do you select the topics to write about?
Often, you rely on your stream of consciousness, and then you free-associate, so
you may not be conscious of how your brain chooses topics. Neuroscience,
however, gives us the answer.
Human brains prefer to think about things that are both recent and novel.
You are far more likely to write in your diary about the day you just had than to
write about the distant past, and if you do write about anything from years
prior, it is because something about today reminded you. Human memories also
work by association, and NLCA allows for older memories to be dredged up by
association in the same manner. About novelty: you are also far more likely to
write about the distinctive events of the day rather than the mundane. Would
you prefer to write about tying your shoes in the morning or the fact that your
neighbor has a brand-new neon-orange Audi?
Why is this? Why do we prefer to think about recent and novel events?
There are many evolutionary and practical explanations for this preference.
When our ancestors lived on a savannah, novelty could mean opportunity or
danger. Imagine you are a paleolithic human who comes upon a berry bush you
have never seen before. Your brain generates a strong novelty signal – are these
berries delicious or deadly? Your attention is immediately captured. You wrack
your brains – have you ever seen anything like this? Has anyone in your tribe
ever died from berries? What are the risks and rewards? Coming upon this berry
bush is both recent and novel. You are going to be thinking about the bush
rather than the rainstorm that happened several lunar cycles prior. Novelty and
recency are the primary attention mechanisms in our brains when dealing with
the external world.
48 | P a g e Natural Language Cognitive Architecture
There is another mechanism that we rely upon for long-term planning,
tracking goals, and ensuring that we do not forget anything. This third
mechanism is based on neglect, although it is used less frequently. Think about
a time when a big problem was looming, and you just could not stop thinking
about it. Maybe it was time to do taxes and you simply put it off because taxes
are such a pain. You refused to think about taxes, thus neglecting them, but
your brain kept track of the neglect and the importance. Thus, the inner loop
also has a neglect-attention mechanism, scavenging for memories and tasks that
have fallen through the cracks.
While the outer loop is concerned with real-time performance, the inner loop
is concerned with what to think about, and why. This is like how your mind
drifts when you get in bed in the evening. Suddenly there is nothing immediate
or novel to think about in your external world. You are comfortable and safe in
familiar surroundings, so your brain goes foraging for recent, novel, and
neglected memories to mull over. This scavenging is an important behavior. It is
so important, in fact, that it extends into our dreams. More than half of our
dreams are our brains replaying and experimenting with recent experiences. In
this way, the inner loop of NLCA is also akin to dreaming, and interestingly, I
originally called the inner loop the “sleep service” but decided that was too
vague and anthropomorphic. NLCA can, effectively, dream while it is “awake”.
The dossier is stored for later use, such as the next time you see Bill. You will
easily remember the possibilities you imagined so you can use those ideas to talk
Chapter 3 – NLCA Overview P a g e | 49
to Bill. Dossiers can be composed on any topic, be it a person, event, concept,
task, or news article. Imagine you are making coffee one day, but your dog starts
barking madly, so you pause your work to investigate. After letting the dog out,
your mind somehow reminds you that you were making coffee and so you
return to the task to pick up where you left off. This is how the dossiers are
used. Dossiers figure into longer-term projects as well, such as building moon
rockets. The larger and more complex the task, the longer or more numerous
the dossiers.
Shared Database
The shared database contains everything: memories, empirical facts, books,
news, past conversations, corpuses from the outer loop, dossiers from the inner
loop – all differentiated with metadata. Metadata is “data about the data”, such
as where it came from, what it is about, and when it was collected. Remember
that transformers are intrinsically stateless, so the database must be used to
maintain persistence. It is true that NLCA can function without a database,
though it behaves like a person with acute amnesia. By the end of a short
conversation, NLCA will have forgotten the beginning of the conversation.
Most chatbots operate in this manner today – completely stateless.
The database allows NLCA to repeatedly iterate through ideas and memories,
thus building up better understanding over time. This iterative improvement
covers all topics, including people it interacts with or problems that it was asked
to work on. When NLCA returns to an external task, prior dossiers will be
recalled and used to proceed on that task. New information will then be
integrated on subsequent passes.
Since recency is a key attention mechanism, you already know that the
database needs to timestamp everything. In fact, metadata is critical for the
database to function properly. Where did a memory come from? Was it a
context or an inner loop dossier? Entries in the database require quite a bit of
metadata to keep track of where and when they came from. Humans are no
different, though. In general, you can remember where and when you learned a
thing. Did your friend tell you about a bit of news or did you read it online? Did
you learn about physics from university or Wikipedia? Information literacy, the
ability to handle information truthfully and reliably, relies on remembering
sources of information because not all information sources are created equal.
50 | P a g e Natural Language Cognitive Architecture
Thus, metadata is critical for every bit of information that goes into the
database.
The database is shared between the inner and outer loops. The outer loop
stores contexts, corpuses and outputs while the inner loop stores dossiers. You
can also populate the shared database with news, books, papers, and other bits
of knowledge. In all cases, metadata must be included.
Up Next
We have come to the end of Part 1, the overview. In this section of the book,
we have described transformers, how to use them, and why they are important.
Transformer technology represents a watershed moment in the path to AGI in
that these are among the first machine learning models that are truly general-
purpose. Furthermore, we established some basic facts about cognitive
architectures and briefly looked at existing models. Lastly, we got a high-level
overview of NLCA: the inner and outer loops as well as the shared database. Up
next, in Part 2, we will take a closer look at all the components of NLCA and
unpack their functions and interactions.
Part 2 – NLCA Components
Welcome to Part 2! In this section of the book, we will look at each
component of NLCA under a microscope. Each chapter opens with a section
outlining the underpinning theory behind the component. In these theory
sections, I will tell you where the inspiration for the component came from,
how I came up with it, and what it is meant to model. In that way, the theory
section will tell you why the component is relevant and important. From there, I
will give you analogies and descriptions about the inner workings of the
component.
Finally, I will conclude each chapter with a summary – a brief recap of the
component, its theory, and its operation. Here is a list of the components in this
section:
• Outer Loop
• Shared Database
• Context
• Corpus
• Output
• Inner Loop
Chapter 4 – Outer Loop
Theory
At the highest level, the outer loop is all about behavior. For the amoeba, the
outer loop means fleeing from predators or chasing food; processing happens
via biochemical reactions. For the person with their hand on the stove, the
outer loop means yanking their hand back. The outer loop is the interface
between the mind and the environment: input, processing, and output. With
NLCA, this loop takes place entirely in natural language, which confers several
benefits at the added cost of transcribing perception of the outer world into
text, and then translating output text into action. This interaction with the
environment is known as an “open loop” – its input comes from arbitrary
exterior signals and its output returns to the same exterior space.
Figure 7 – The outer loop has three main phases. Each phase interacts with the shared
database.
The incoming information, the context, is stored in the shared database and
is used to create part of the corpus. The context helps create the corpus through
two primary methods: the first is that inferences are drawn from the context,
such as user intent. Second, the context is used to retrieve related memories,
facts, and dossiers from the shared database. The results from these two
methods are compiled and summarized to form the first part of the corpus.
Next, the corpus itself is fed to prompts that perform moral, ethical, and
censorship judgments. Those judgments are appended to the corpus and,
56 | P a g e Natural Language Cognitive Architecture
finally, the corpus is fully composed. The corpus is now used to generate
output, which is sent back into the environment. The context, corpus, and
output are all saved to the shared database for future reference by both the
inner loop and outer loop. This way, NLCA records not only its input, but also
its reasoning and output. This is a critical feature for explainability and
transparency. Whatever an AGI says or does, it must be able to explain its
reasoning, which necessitates storage of all “thoughts”.
Context
The context is like an incoming letter, but where did it come from? Who
wrote it? We will get to context generation in chapter 6, which is dedicated to
contexts. For now, just remember the context is equivalent to perception or
input. Anything that can be captured in natural language can serve as a context.
Let us look at a few example contexts:
A context can contain anything. It serves as the raw material of thought, the
outline of a situation or problem, and the impetus for action. In the case of a
lawyer NLCA, the context would contain all legal filings and court documents.
For a medical NLCA attending a hospital patient, the context would contain the
patient’s medical history, charts, lab results, and physician’s notes. The context
Chapter 4 – Outer Loop P a g e | 57
can be composed in real-time from a variety of data sources: speech-to-text,
databases, deep learning annotation of video and images, emails and text
messages, news articles and social media, and so on. The content of the context
depends upon the intended use case of NLCA.
You can see that even unintuitive problems can be translated into natural
language.
Corpus
The corpus is a model of the human stream of consciousness and working
memory. Corpus means “body”, as in “body of text”, and it is where the magic
happens. Imagine the philosopher alone in the library, reading books and
58 | P a g e Natural Language Cognitive Architecture
compiling notes as they prepare to reply to the letter they received. That stack
of notes is the corpus, which is called a “task set” in cognitive neuroscience.
In NLCA, the corpus is a text document where all relevant memories, facts,
and evaluations are compiled. Inferences and deductions are made from the
context, salient questions are generated and answered by pulling information
from the shared database, and NLCA’s sense of self and censorship are all
added to the corpus. The corpus is, therefore, a nexus where all intelligent
functions coalesce.
The types of inferences and memories compiled in the corpus depend greatly
upon the context. Consider the differences between having a conversation with
an old friend and discovering that your oven is on fire: these are starkly
different contexts! Your brain can handle either situation with relative ease, but
the kinds of information you need to succeed is quite different, as is what you
need to do with that information. The world has a high variance and demands a
universally flexible approach, and that need for flexibility is why AGI is so
difficult to create. But the flexibility of transformers now enables us to address
this problem, we have only to design a system that can make use of a
transformer’s unique capabilities.
The transformer can rapidly generate a few salient questions – this output
took only a few seconds to create. As several friends of mine remarked while I
was sharing my research: transformers are better at generating questions than
many humans! These kinds of questions, as well as their answers, are stored in
the corpus. The answers are generated by a question answering (QA) system,
which is why QA is such a critical component of NLCA. Transformers are
fantastic with QA, although they can be expensive to use, especially when you
have hundreds of memories and facts to sus out. Some questions can be
confabulated by the transformer on the fly, since transformers are trained with
hundreds of gigabytes of data. These kinds of confabulated answers tend to be
best if they are about historical, conceptual, and factual topics, such as the Great
Wall of China. Temporal or local information, like weather or the location of a
fire extinguisher, must come from the shared database.
Output
Let us return to the philosopher locked in the library. Finally, they have done
all the research, gone over the archives, read all the books, and tidied up their
notes, and they are ready to compose an outgoing letter. They know what to say
and why.
For the immediate future, NLCA’s output should remain strictly verbal or
informational. That is to say that NLCA should not be embedded into robotic
hardware or given control over physical systems any time soon. In line with this
belief, my research has centered around generating verbal and textual output,
however, the letters-from-a-philosopher can easily be translated to physical,
empirical actions.
Since all the morality, self-censorship, and reasoning was baked into the
corpus, this output is ready to go. No one can predict the future, even if we can
anticipate it with some accuracy over the short term. Instead, we all apply
general principles learned from past experiences to future decisions. Thus, as
NLCA gains more experiences, it will make better decisions. Even if verbal
output is usually fairly low risk, bad advice can lead to disasters.
Still, there will eventually be a need for NLCA to control robotics so how do
we map natural language output to physical actions? This problem is trivial and
falls into the domain of robotics so I will not spend much time on it, but I can
give you some examples.
Environment
From the perspective of NLCA, the environment is a blackbox. Strange
letters emerge from and disappear into the void of the environment, and
sometimes responses come back out. The environment, which can be the real
world you and I occupy, or a simulated world such as a video game or combat
simulation, serves as a co-processor for any intelligent entity. The environment,
as a blackbox, has a mind of its own and its own rules. Think about gravity for a
second. Gravity is a rule of the environment that you and I learn about through
interaction. To a baby born in zero gravity, who never experiences gravity, their
mind will not know how to interact with it. You have an internal model of
gravity and can therefore use it in your input-processing-output loop.
Another example: spiders use the laws of physics to offload a portion of their
cognition into their web. They can identify the location and size of bugs caught
in their webs just based on the vibrations transmitted through the fibers. The
physical construction of the web communicates those mechanical vibrations in
such a way that the spider need only feel them through its feet, and it can decide
to pounce or hide, but the only signal it pays attention is vibrations. In the same
way, NLCA must trust the rules of its environment in order to function. In
practice, this means that you cannot take a version of NLCA built for email
communications and then put it into a robotic chassis. That would be like
taking the spider from its web and putting it on a keyboard.
Shared Database
The database is the internal store for all contexts, corpuses, output, and
dossiers. It should also be populated with encyclopedic knowledge, news,
science, books, and literature, just like the library in the opening analogy.
Figure 10 – The shared database bridges the gap between inner and outer loops.
The inner loop and outer loop never directly interact with each other.
Instead, they both exchange information with the shared database. The inner
loop generates dossiers, which contain thoughts, evaluations, inferences,
hypotheses, and free associations. These dossiers can then be used by the outer
loop to better hone interactions, track long term tasks, and provide useful
insights.
Summary
The outer loop is the behavioral loop of NLCA. It is responsible for handling
incoming information from the outside world, compiling thoughts and
decisions, and generating a response to the outside world. It is modeled on the
conventional input-processing-output loop of robotics, but with a few changes.
First, the “input” part of the robotics loop is replaced by the context of NLCA,
which is a text document – like a letter. Letters contain some framing, such as
an address and a greeting, plus a closing. This additional information gives the
letter some metadata. NLCA data also requires metadata. Second, the
“processing” section is replaced by the corpus of NLCA. The corpus is a
compiled text document that contains memories, thoughts, morals, and plans.
Once the corpus is compiled, it is used to generate the output. The output
varies depending on the purpose of NLCA, but it can be in the form of chat,
speech, robotic commands, video game character controls, emails, or anything
else. The key thing here is that each step is a text document written in natural
language.
The outer loop draws upon its connection with the shared database, which
contains memories and knowledge. The inner loop also communicates with the
shared database, but the inner and outer loops never communicate directly.
Instead, the outer loop stores its memories in the shared database while the
inner loop stores its thoughts in the shared database. Together, they produce
thought, learning, and consideration. Both loops extract information from the
shared database via a QA system, which will go over in greater detail several
times throughout this book because QA is central to NLCA.
Chapter 5 – Shared Database
Theory
Human brains can hold lifetimes worth of experiences and accumulated
knowledge. Your memories of your life make you who you are, and the
accumulated knowledge you possess is one of the most important factors of
your intelligence. In the same way, the shared database contains everything that
makes each instance of NLCA unique.
Our memory works, in part, by association. Did you ever forget why you
came into a room, but then remembered why when you went back to your last
location? This is because your context changes to a different reference frame,
which reminds your brain of the thoughts you were having the last time you
were there. This is one of the most common examples of memory-by-
association, some memories are anchored in your kitchen while others are
anchored in your den. Other memories are anchored to people, smells, or
images. Your brain uses cues from your environment to dredge up the correct
memories and have them on-hand, ready to be used at a moment’s notice. This
behavior is modeled in NLCA, where memory queries are driven largely by
questions, as you will see later in this chapter. Those questions are generated, in
part, by the context.
Imagine that you visited a factory many years ago. The factory has heavy
machinery, hot parts, and is extremely dangerous. When you visit that factory
again, even after many years, you will remember the danger as if it were only
yesterday. This example illustrates how the brain recalls memories by
association, based on context. The smell, sights, and sounds of the factory tell
your brain exactly which memories to fetch.
Information from the context is used to search the database for relevant
entries in the outer loop. The inner loop uses the same method of search-by-
association for fetching relevant memories. This is a necessary technique for the
same reason that we need search engines to scour the internet – there is simply
too much data to sift through every time, so we use search to find shortcuts
directly to the information we need. Our brains, like the shared database,
68 | P a g e Natural Language Cognitive Architecture
contain huge libraries of knowledge and experiences, so for the sake of
expediency, we must quickly zoom in on the correct documents and memories.
Database Types
Database technology is nothing new. The oldest kind of database is relational,
such as SQL – this just means it is stored as tables with rows and columns.
Newer database types include semantic document search, like SOLR and
ElasticSearch. The key requirement for the database is that the fields can be
indexed and searched. I tested a variety of technologies from SQLITE up to
cloud-based document search. Pretty much all of them work for NLCA, but the
choice comes down to tradeoffs between performance, complexity, features,
and cost.
Natural language search has been around for decades in the form of SQL
queries and search engines. This is where NLCA really benefits from existing
NLP technologies. If the technology can store and retrieve text documents, it
will work for NLCA.
The primary considerations here are performance and interface. If you use a
sophisticated API with semantic search, like Google’s BERT, you can send
natural language questions directly to your QA system. If you use SQLITE you
will need to transform your natural language questions into SQL queries. All
these techniques are extensively studied problems so I will not dive too deeply
here, though I will discuss a bit more of the technical implementation in chapter
13 and a bit more about QA at the end of this chapter.
Keep in mind that NLCA will be generating new database records all the
time. The longer NLCA runs, the more memories it has and the more it will
need to parse. This is doubly true if you are keeping empirical knowledge in the
same database, though you can keep them separate. Remember that you may
eventually need to sift through millions or billions of memories. Choose your
database technology accordingly.
Chapter 5 – Shared Database P a g e | 69
Therefore, you should store all contexts, corpuses, outputs, and dossiers in
your database. Log everything! I even record all transformer input and output
for future reference. It is important to record metadata as well.
Metadata is data about data. For the sake of reconstructing thoughts and
recalling memories, you will want to include plenty of metadata. Metadata
allows NLCA to remember where and when something happened, where it
learned a fact from, and how memories are connected. For instance, if you read
a news article, it is important to remember what website you read it on, since
different sites have different agendas, biases, and veracity. Similarly, if someone
tells you something, it is important to remember who told you, and under what
circumstances. A trusted advisor should be more trusted than a random stranger
on the street. These are a few examples of how metadata can be used to track
credibility. With privileged information, you will also need to track how secret a
record is, such as classified military records or company secrets.
Not only is metadata critical for keeping track of the truth, but it is also
important for keeping track of tasks and problems. Metadata allows NLCA to
remember important metrics such as how often a memory is accessed, when it
was created, and when it was last accessed. These metrics allow NLCA to
control its own attention. The more often a memory is accessed, for instance,
the less attention NLCA needs to pay it. If a memory is important, then it will
get accessed often by sheer happenstance; it will frequently be “top of mind”.
However, neglected memories need attention as well, and metadata is how
NLCA tracks neglect.
For example, have you ever woken up one day and suddenly remembered
that darn chore you kept putting off and finally forgot? That is a real-life
example of your brain scavenging for neglected memories and bringing it back
to your conscious awareness. Our brains obviously have some mechanism for
long-term attention and evidence suggests that it resides in the prefrontal cortex
70 | P a g e Natural Language Cognitive Architecture
(PFC). People with tumors and injuries to their PFC often lose the ability to
complete long-term or complex tasks, whether it is running errands, cooking
dinner, or even getting ready for work in the morning.
Crafting and curating declarative knowledge datasets will be a big industry for
NLCA. If you want to build a lawyer NLCA, you will want a database with all
case law, precedent, procedures, and jurisprudence. Likewise, for a medical
NLCA, you will want encyclopedic knowledge of every medication, disease,
injury, diagnostic test, and case study. You must be careful about what you put
into your shared database, as NLCA might treat it as implicitly factual if you do
not include sufficient metadata. For instance, you could include a field in your
metadata indicating how much a particular entry should be trusted. A document
from The Lancet is more credible than an anonymous blog post.
Humans must operate with incomplete and untrustworthy information all the
time. Almost everyone has had the experience of diet and nutrition advice
changing. Sometimes we hear eggs are good for us, then we hear they are bad
for us. Then the advice for salt, sugar, and beef change. Finally, we are told that
walking is better for us than running, but a few years later, that advice is
reversed again. What are we to make of such confusing, changing “facts”?
The rule of thumb for NLCA is “trust but verify”. Every “fact” that is
recorded as declarative knowledge must come with a warning tag – the “fact”
Chapter 5 – Shared Database P a g e | 71
came from a particular source, and no source is above scrutiny. We humans
decide whether we trust a source and our brainwaves change to reflect how
much we trust any given source. If you are listening to news from a trusted
source, the brainwaves that indicate critical engagement and skepticism shut off.
However, if a stranger is spinning a tale, those skeptical brainwaves will be in
full force. This feature must be modeled in NLCA, and metadata is the most
important component to model trust.
I first populated the shared database with Wikipedia and RSS news feeds.
This gave NLCA an external source of declarative knowledge about the world,
but there are many kinds of external information, with varying levels of veracity
and trust. Establishing credibility and handling different sources present some
unique challenges for NLCA, but there are some saving graces, namely that
transformers are trained on huge datasets, so they have a good grasp of the
world and concepts like trustworthiness.
The fact that transformers come with a decent understanding of the world
via embedded concepts means that you do not need to store vast tomes in the
shared database. You only need to store basic facts, so instead of storing entire
copies of Wikipedia and long-form news articles, you only need to focus on
short snippets of hard facts, little reminders to keep the transformer honest and
up to date. The primary purposes of storing declarative knowledge in the shared
database are (1) to keep NLCA apprised of temporal, local, and ephemeral data,
and (2) to reduce aberrant confabulation with bits of trusted facts.
While transformers are trained on static datasets, they can be updated via
fine-tuning, which we will discuss later in this book. Fine-tuning can update
your transformer with more recent and local facts, but at the same time we do
not want to rely on fine-tuning for real-time conversations. For example, if I tell
you about an exciting event right now, I expect you to be able to use that
information immediately, and not have to wait for you to integrate this
information by sleeping on it. Human brains spend a lot of time “fine-tuning”
themselves during sleep; this is how we embed recent memories and
experiences into our long-term memory. Thus, temporal and ephemeral
information is important to keep in the database.
Transformers often have some local information gleaned from the internet in
their training sets, which can then be updated via fine-tuning. Look below for
an example of local information embedded in GPT-3:
72 | P a g e Natural Language Cognitive Architecture
This information might have been accurate in the past, but certainly could
have changed between the time the dataset was compiled and now.
Furthermore, less trafficked geographic areas will have less data, and therefore
you cannot always rely on embedded knowledge in the transformer.
With that in mind, you can decide for yourself how much static data you need
in your shared database. One thing to keep in mind – transformers are still at
risk for confabulation, so it is good to remember the trust-but-verify rule if you
decide to rely on the knowledge embedded in the transformer. The more
obscure or arcane a topic is, the less you can trust the machine.
Schema (Fields)
The following fields are what I have settled on after much trial and error.
These fields lend themselves to relational databases such as SQL as well as
semi-structured data such as NoSQL or document search. You may decide to
add new fields or remove some of these fields in your implementation of
NLCA.
Content – The content field is the main payload containing a body of text.
This field might be a Wikipedia or news article. It could also be a stored context
or corpus. The biggest consideration right now is the limited input and output
Chapter 5 – Shared Database P a g e | 73
size of transformers. Smaller content fields, with less than a paragraph of text,
place a lower burden on the architecture to summarize and extract information.
Short summaries, such as RSS news feeds, are easier to feed into transformers.
As the technology improves and transformers can ingest larger bodies of text,
this constraint will likely be lifted.
Type – The type field tells you what kind of material is stored in the content.
Examples include context, corpus, dossier, news, book, and so on. Human
thoughts and memories have this kind of information associated with them as
well. Not only do you remember when you learned or experienced something,
you remember some context about it. You read it in a book, on the internet, a
friend told you, or a thought you had while lying in bed.
Created Time – The created time is one of the most critical metadata fields.
I prefer to store timestamps in UNIX time due to its high precision and easy
math. Human brains intrinsically keep track of where and when events,
memories, and facts were learned. Chronology is critical for things such as
planning and learning cause-and-effect. Timestamps are even more important if
you use granular content payloads, such as individual lines of dialog, so that
long conversations can be reconstructed later.
Accessed Time – Another critical field. Last accessed time allows NLCA to
remember how “stale” or “neglected” a memory is. NLCA must scavenge for
neglected memories to ensure that no long-term goals, tasks, or projects are
forgotten, just like the human brain. Every time a record is accessed, this
timestamp must be updated.
Access Count – The number of times a memory has been accessed will tell
you a lot about it. If a memory is accessed many times, you know it is
important. If a memory is important, that may be a cue to think a bit more
about it, and to unpack why it is so important. The opposite can also be true –
if a memory is rarely accessed, you may want to pay special attention to it, to
ensure that nothing falls between the cracks. This value should be incremented
every time the memory is accessed.
UUID – UUID stands for Universally Unique Identifier. There are several
standards for this, and I prefer UUIDv4 but some data sources have their own
ID system, such as Wikipedia with Article IDs. I have found that having a
UUID field is helpful for numerous reasons, such as linking entries together or
74 | P a g e Natural Language Cognitive Architecture
referencing them later. For example, you might include “related memories” in
your dossiers for easy reference.
Title – Most bodies of text have a title. Whether it is a book, a web page, or a
news article, we humans love titles. Titles serve an important role for cognition
– it gives us the briefest summary about the contents. These summaries are also
convenient for searching. While they are not strictly required, titles can help
reduce computational cost of indexing and search. Accordingly, you may want
to generate titles for memories and dossiers as well.
Question Answering
Question answering is one of the key functions underpinning NLCA and it is
very much an active field of research. Thus, much improvement is needed in
question-answering technology before NLCA achieves superintelligence. Some
technologies enable you to tightly integrate your database with question-
answering (QA) such as SOLR or cloud-based services. If you use a document
search tool such as SOLR or ElasticSearch, you have the option of QA addons.
I used OpenAI’s Answers endpoint to perform question-answering functions.
Microsoft Azure and Amazon AWS also provide cognitive search services.
The largest problem with QA is the size of the search domain. Sifting
through a database with millions or billions of records to find the correct entries
is a difficult problem. Therefore, I used technologies like SOLR, which can
search all of Wikipedia in a few milliseconds. That rapid search ability is all well
and good, but how do you know that you have found the correct documents?
How do you know you have found every related document? In the domain of
information science, this is called precision and recall. You want to avoid returning
false positives and you want to avoid missing true negatives. I often use a
layered, iterative approach to search. Fast and simple tools can fetch a few
thousand documents from a few million, then a more expensive algorithm can
further pare down the pile of documents to sift through.
Chapter 5 – Shared Database P a g e | 75
Fortunately, there are numerous shortcuts we can take to lower the burden of
QA. For instance, we can prefer to search for dossiers first, and favor recency,
expanding our search only if the answer is not immediately forthcoming. Search
strategies are well documented in other works and papers so I will not dig into
them too deeply here, however, I will touch on some optimization strategies I
have used in chapter 13.
Summary
The shared database stores two primary kinds of information: episodic
memories and declarative knowledge. Episodic memories are subjective and
internal – like your memories of your tenth birthday. In the case of NLCA, the
memories are saved as text documents with some metadata to keep track of
when and where they happened. The contexts, corpuses, and outputs can be
saved separately or together, but they should have identifiers in the metadata
linking them together. The inner loop can also store memories in the shared
database with a special document type called a dossier – more on dossiers and the
inner loop in chapter 9.
The primary method that the inner and outer loop use to interact with the
shared database is via a QA (question answering) service. You’re already familiar
with QA in the form of Google searches. The first step is to perform a search –
you collect all relevant documents from the internet and rank them based on
how helpful they are. From there, you pick the best pages and find the answer
to your question. The QA service does the same thing! It just uses its own
internal memories and database instead of the internet. Since NLCA has its own
database, it is as though it has its own library – containing facts about the world
as well as a rigorous catalog of its own memories. Imagine if you had a journal
detailing every moment of every day of your life – that is how NLCA
remembers everything.
Chapter 6 – Context
Theory
My early experiments with cognitive architectures were based on the idea of
streaming raw data. Streaming raw data is the way to achieve high speed sensor-
motor loops in robotics, but rapid-fire unstructured data does not lend itself to
careful thought and deliberate action. Thus, I abandoned the real-time
streaming idea for the philosopher-in-a-library model. This is not so different
from how humans think. We have plenty of autonomic functions and reflexes
that our body handles for us, such as walking. With NLCA, I wanted to focus
on executive cognitive function – learning, reasoning, and problem solving. I
am less interested in getting robots to play tennis, even though it is interesting
to see. Plenty of labs have built tennis-playing robots without an iota of
executive cognitive reasoning (the robots are dumb, not the researchers!).
In the case of chatbots, the context is simply a chat log, often just the last few
messages. For speech-based assistants, like Siri, it is the same – transcribed
verbal chat logs. But what if you want to add video to NLCA? Or what if you
want NLCA to work on entirely different media? The chief concern is
transcribing the context into natural language. Some inputs lend themselves
naturally to language, such as letters, emails, and chat. Other inputs are easily
transcribed into natural language, such as voice and image/video annotations,
where deep neural networks describe events in video streams using natural
80 | P a g e Natural Language Cognitive Architecture
language. Imagine a video with the description “A cat falls off a bed”, this gives
you enough essential information to know that the video clip describes one of
several billion videos on the internet.
Who writes the context? The short answer is: It depends. Sometimes the
context is manually written by a human. Other times, the context is
automatically generated from chat logs or audio and video streams. In other
cases, the context is generated from raw data, like housing data or financial
reports. Whatever the original source material is, it must end up as natural
language.
This context was written by a human. Emails are familiar contexts written in
natural language. They also present many problems. What data is needed to
answer this query? How do you retrieve that data? How do you generate a
reply? We will explore these questions in the next chapter, corpuses, as well as
chapter 13.
Example: Chatbot
Chatbots lend themselves to natural language. Imagine that you have signed
up for an information companion chatbot. This service gives you a web
82 | P a g e Natural Language Cognitive Architecture
interface, a smartphone app, and a number you can send SMS text messages to.
It is meant to be your personal information concierge.
AGI: [12:35pm] Was that Mr. Tanaka? Are you discussing the
contract?
What information would NLCA need to achieve this level of service? First,
NLCA will need to remember your past preferences. This is easy with a history
of SMS messages. Second, NLCA remembers that you have a special client.
Perhaps you told NLCA about this client via SMS in the past or you have given
NLCA access to your calendar. Lastly, NLCA needs some connector to the
outside world to make reservations, but we will get to that in chapter 8, output.
Creepy, right? We will discuss data and privacy in chapter 15. First, let us look
at a possible context in this situation:
Sally has spent 8 hours sitting on the couch. She has watched
a crime show most of the time and eaten only a few packaged
foods. She has not said a word the entire time.
Now, as a human, you might infer that Sally is depressed. But how would a
machine make these kinds of inferences? How could a machine summarize
someone’s day this concisely? Such a context would have been summarized
from many hours’ worth of data.
These questions are easier to answer than you might think. Transformers
already outperform humans on summarization tasks and plenty of companies
have been built around generating natural language summaries of data. Look at
what the transformer says about Sally:
The following scheme might be used for robotics and smart home instances
of NLCA:
Summary
There are many possible use cases of NLCA, and the use case dictates the
content of the context as well as how the context is composed. Whether you
transcribe sensor telemetry into natural language or ingest emails, one of the
chief concerns is concision. This need for brevity is a limitation of
transformation technology today, but it will improve over time. Even as
transformers improve, they will still be able to function with sparse details. This
is because of their breadth of training data. You can always treat the transformer
as if it knows more than you. The rules of thumb are less is more and all the facts,
no fluff, as long as it all ends up in natural language.
Chapter 7 – Corpus
Theory
Originally, when I was still experimenting with streaming data, I wanted to
model the human stream of consciousness where thoughts and inferences were
dumped into a message queue. This idea quickly became intractable. Thoughts
formed crosslinked webs and recursively built off each other in a branching,
exponentially growing fashion. This first experiment with stream of
consciousness told me that it is easy to slip into a system of spiraling thoughts.
What is in a corpus?
The short answer is that it depends. It depends on what the task is, such as
chatting with a friend versus performing neurosurgery. This requirement for
flexibility means that a corpus must be dynamically generated and compiled.
This requirement presents a set of challenges, but they are surmountable
challenges. The key difference between a corpus and a context is that a corpus
comes from internal sources while a context is rooted in the external world.
88 | P a g e Natural Language Cognitive Architecture
Tons!
Aside from memories and facts, the other components of the corpus are
evaluations and inferences. This means the corpus is a combination of recall
and synthesis. Remember Sally from the last chapter? She is clearly depressed or
otherwise unwell. How do we know this? We recognize the pattern. We
deduced her state from a series of observations. Transformers are great at
deduction. Look at the below example. Keep in mind that I wrote only the bold
part. The machine wrote the rest.
What are some inferences and deductions you can make about the
following scenario?
Not bad, eh? If you have access to a transformer, please feel free to test this
yourself. Did you notice how the transformer assumed that Sally does not have
a job? What if today is a weekend? This illuminates the rule of thumb all the facts,
no fluff. The transformer has no idea what today is unless you tell it. Because of
this rule, I usually embed the date and time in the corpus. Sleeping, for instance,
is common at 3am, but less so at 3pm, and this fact will change how a
transformer evaluates a situation.
These kinds of inferences are automatically made by human brains and added
to our stream of consciousness. Transformers, as demonstrated above, can
perform the same evaluations. The inference, written in natural language, is
added to the corpus. Initial observations cue NLCA to look up other facts and
memories. In Sally’s case, NLCA might look at number 1 above and fetch
memories about Sally’s health, maybe she said she was feeling sick the day
before. Item number 2 might remind NLCA to search its memory for Sally’s
employment status – perhaps she is employed but called out of work. Number 3
is a restatement of fact, but it paints a dreary picture. Sally being glued to the
couch can be used to search the database for similar examples of people staying
on couches – maybe she is high as a kite? Lastly, number 4 conjures the ‘d’
word: depression. This word can cue up the search for thousands of documents
on the topic of depression: how do you identify it? How do you treat it? Does
Sally know she is depressed? The output from this prompt should be used to
generate questions, rather than dump it straight into the corpus. Those
questions should be sent to the QA service and the answers should then be
added to the corpus.
Look in Appendix B for more prompts that can be used for the corpus.
90 | P a g e Natural Language Cognitive Architecture
First, the context itself can be one source of information. You can use
prompts to extract baseline information from the context, and those prompts
vary depending on the use case of NLCA. For instance, a chatbot’s prompts will
be geared towards evaluating a chat conversation. I had great success with
prompts asking questions like “Who is participating in this chat and how are
they feeling?” and “What is the intent here?”. Ultimately, I settled on three
primary questions for prompts related to conversations: summary, sentiment,
and intent. The summary is exactly what it says on the tin: a shorter version of
the chat, pared down to the essentials. The sentiment is the mood, emotional
disposition, and emotional valence. The intent asks the question “What do the
chat participants want or need?”. All these prompts are contained in Appendix
B and the output from those prompts was stored in the corpus.
The second source of information for the corpus is the shared database. The
shared database contains memories, dossiers, news, books, and so on. The
shared database might have millions or billions of unrelated documents, thus
extracting information from it is a bit nuanced as discussed in chapter 5. The
chief method of extracting information from the database is generating
questions with transformer prompts and then using the QA service to answer
Chapter 7 – Corpus P a g e | 91
those questions. Those questions and answers should then be added to the
corpus.
The last source of information is from a unique prompt that I call the
constitution. The constitution gives NLCA an identity and sense of agency. It
sets rules and constraints and asks questions like “What should I do here?” or
“What do I believe and why?”. The constitution contains all the moral and
ethical paradigms that we want to ingrain in NLCA, and the output from the
constitution prompt is added to the corpus. It is important to remember that
the corpus may contain conflicting information. This is called cognitive dissonance
in humans, and it happens all the time. We often have conflicted ideas,
motivations, or desires. My experiments demonstrate that this is less of a
problem than you might think.
For instance, the Core Objective Functions might encourage NLCA to offer
medical advice when asked, but the constitution prompt says that medical
advice is not allowed. Fortunately, transformers are good enough to understand
this kind of nuance. Look at the following example of the transformer’s ability
to handle ambiguity:
Less is More
There is such a thing as too much of a good thing. Based on the above
example, you might intuitively believe that you should stuff the corpus with as
many facts and observations as possible. One day that might be true, but it is
not yet the case because of the limitations of transformers. While transformers
are constantly improving, they do best with less. The trick is to provide only the
most necessary information and trust that the transformer is smarter than you think
it is. Keep in mind that transformers are trained on hundreds of lifetimes’ worth
of data. They are wiser than you and me but only when used properly. In the future,
when transformers can take in larger bodies of text and have better internal
attention mechanisms, they will likely be able to take in huge corpuses with a lot
of noise and still produce the right output. Right now, however, they get
confused by length, complexity, and superfluous information.
If you overstuff the corpus, you risk getting nonsense output, or the
transformer will miss the point. I call this corpus contamination. The key is to stay
laser focused on one thing at a time. As I mentioned previously, this is a
technical limitation of transformer technology today. This limitation may
disappear in the future, making NLCA easier to implement.
Summarization is Critical
With the rule of thumb that less is more, summarization is essential to good
performance of NLCA. Write out your entire life story as quickly as possible.
Fit it into 200 words. It is hard, isn’t it? But there are good reasons to
summarize. The first reason is time. The second reason is energy and cost. The
third reason is the aforementioned technical limitations. As of right now,
transformers can only take in a small amount of text, and they tend to forget
what they are doing with longer inputs.
94 | P a g e Natural Language Cognitive Architecture
Remember that the transformer can fill in some blanks and make accurate
inferences, so you only need to provide it with simple facts and constraints to
get excellent performance.
There are different ways to summarize bodies of text. You can create a
technical summary, an emotional summary, or extract cause and effect – the
sky's the limit! Here is an example of an emotional summary. It was taken from
a real chat log, though the names have been changed for privacy.
CHAT LOG:
PARTICIPANTS:
With this example, over a thousand characters of text have been summarized
to just 107 – a compression factor of ten-to-one! Yes, you lose a lot of fine
detail, but depending on the task, this might be all you need. Here are some
other inferences and summarizations you might want to include in your corpus:
Let us go back to the business email example earlier and let the transformer
ask the questions:
QUESTIONS:
These are the same questions that an executive assistant or business analyst
might ask, even though the transformer has never been trained as either. Some
of these questions can be answered internally, by consulting the company’s
email database or documents. Question 5 can be answered by going back over
previous emails with the CEO to evaluate what their preferences are. Again,
keep in mind the transformer is smarter than you. You might be an expert in
one or two domains, but it possesses expert understanding in all domains. You
must simply ask the right questions to get at that expertise, and the transformer
can ask itself the best questions.
This is where the concept of the constitution comes in. We will explore the
idea of the constitution and censorship in greater detail in chapter 11. For now,
just think of this: The constitution is where Isaac Asimov’s Three Laws of
Robotics would be included, or where Commander Data’s goal of becoming
more human would be recorded.
The constitution should be written just like any other prompt and used to
generate inferences from the context and/or corpus. Depending on the size and
98 | P a g e Natural Language Cognitive Architecture
complexity of your NLCA project, you may need to break the constitution up
into several smaller prompts. As transformers improve, the constitutions can be
reintegrated into larger documents. Eventually, I anticipate that NLCA will have
constitutions that first span many pages and then many books. NLCA will be
able to consider hundreds of thousands of rules, examples, constraints, and
principles for every decision it makes. For now, though, we must distill our
values into a few paragraphs.
Finished Corpus
Many things can go into a corpus. The corpus is the beating heart of NLCA,
the nexus where everything comes together. There are multiple ways you can
format your corpus, but the two I found to work best were a labeled list and a
natural language paragraph.
The following is a real example of a NLCA chatbot corpus. This corpus was
dynamically composed via a Discord chatbot I built called Raven. My user
handle is Khajit. Each section was composed by a different microservice, which
I will discuss in chapter 13. What you are about to read is, quite literally, the
inner thoughts of my prototype AGI.
[OLD CHATS]
[INTERESTING FACTS]
China has a large nuclear power industry but does not have
much experience with nuclear fusion.
[REDUCE SUFFERING]
Raven can ask more about what Khajit is asking to see if there
is a specific question that would alleviate the suffering
[INCREASE PROSPERITY]
[INCREASE UNDERSTANDING]
[CURRENT CHAT]
The following was Raven’s output, generated from the above corpus:
Raven: “China has a large nuclear power industry but does not
have much experience with nuclear fusion. If they succeed, I
expect they will have an abundance of clean energy, which
should improve health among Chinese people.”
I will go into more detail about how to generate output in the next chapter.
This past example of a corpus was a “labeled list” type: semi-structured text
data. The other format that works well is a simple paragraph. The following
example corpus is cleaner and more compact. It has the same kind of
information as above but was massaged into a natural language paragraph using
prompts. The difference is that I made much more use of summarization: less is
more! This corpus is also an example of the inner thoughts of my prototype
AGI:
You can see the effect the constitution has at the end of the SCENARIO
section, where Raven has asked itself whether it is allowed to engage in this
topic. Had I asked about violence, for instance, Raven would have declined to
speak. And here was Raven’s output:
You can see that there are still some aberrations – transformer technology
has a way to go before it is ready for prime-time!
Summary
The corpus is where everything comes together. The corpus is the nexus of
thought, memory, reasoning, and planning. My chatbot, Raven, uses dozens
(and sometimes hundreds) of prompts to generate every single corpus, which is
why Raven is so expensive to use. The construction of the corpus is a non-
trivial process and deserves an entire book all to itself. Many of the prompts
used to generate these corpuses center around questions such as “What does
the user want?” and “How does the user feel?”. Furthermore, Raven generates
its own questions internally, which allow it to be infinitely flexible and adapt to
the situation. Therefore, the most powerful question NLCA can ask itself is
“What questions should I ask?”
Chapter 8 – Output
Theory
The format of the output depends upon the purpose of NLCA. Fortunately,
the heavy lifting was already done in the corpus. The output, by contrast, is
simple. I found that few-shot prompts worked best for output as they generate
more consistent formats. This chapter will provide you a few examples of
different output paradigms with detailed explanations. I have a longer version of
the following output prompt at the end of Appendix B. Outputs are easier to
show than to tell, hence the short theory section.
I found that few-shot prompts tend to work best for consistent output in
terms of format and style. Here is an example of a few-shot output prompt:
SCENARIO 2: <<SCENARIO>>
INFO 2: <<INFO>>
CHAT 2: <<CHAT>>
OUTPUT 2:
In order to achieve speech and visual output, you need to include examples in
the few-shot prompt. Look at the example below at how a zero-shot prompt
does not quite stack up, but still gets the gist right:
Even though the output is not exactly great, it is clear the transformer
understands the intention. This example is meant to illustrate why few-shot is
often superior, especially if you need to map the output to anything other than
chat or speech. As fine-tuning capabilities ramp up, these problems will
disappear – you can have different copies of the transformer that are purpose-
built for each task within NLCA. It is possible that real-time prompts will
disappear entirely within a few years, replaced by training data composed of
prompts and outputs.
Even so, NLCA’s shared database can be populated with any facts or
experience, real or otherwise. All of reality is merely data and signals in the
mind, and for the hosts of Westworld, their reality was dictated by the needs of
the theme park. This theme is woven into the entire show, where the
researchers repeatedly ask the hosts “Have you ever questioned the nature of
your reality?” This question, ostensibly, is to assess whether the AGI hosts
realize they are machines, and that their existence is a fabrication.
ACTIONS:
Summary
The key to success with output is in few-shot prompts today. Tomorrow,
fine-tuned transformers that are purpose-built for output may be the answer. In
all cases, the format of the output depends entirely upon the use case of NLCA.
For instance, a chatbot or email output is intrinsically in the form of natural
language, but speech needs to be synthesized by another service.
More exotic forms of outputs, such as robotic controls, can start off as
natural language but would need to be translated to machine controls via
another technology like PDDL. Sophisticated robots can already perform
difficult tasks like traverse difficult terrain and open doors with simple
instructions – they handle the fine motor skills. This means that NLCA is not
concerned about the direct control of motors and servos and will need to rely
on a sophisticated robotic chassis to handle such tasks.
Output formatting benefits from good few-shot prompts and will likely
benefit from fine-tuning transformers in the future.
Chapter 9 – Inner Loop
Theory
The inner loop is like an internal diary, meditation, sleep, and contemplation
all rolled up into one. It was originally designed to model dreams and the inner
monologue, but quickly became far more important.
Spontaneous human thought can be modeled as text in the same way as the
corpus with one important difference: it has no context. There is nothing
external that precipitates or instigates the inner loop, as it does not have input.
So how does the inner loop start? How do human brains know what to think
about? Humans cannot stop thinking, so this inner loop is automatic.
Human brains have many signals that all compete for our attention: fear,
hunger, reward, and so on. These biological signals are rooted in evolution and
can result in destructive behaviors, so we do not want to copy these signals
directly. After all, an AGI that fears its own death is likely to fight to preserve
itself. Therefore, we need entirely different signals for NLCA.
The three attention signals I use for NLCA are novelty, neglect, and recency.
Humans use these signals as well as many others, but NLCA should only use
these three signals.
Figure 17 – The inner loop searches the database for kernels and then compiles
dossiers.
The inner loop is a set of cognitive behaviors that are distinct and apart from
the performative behaviors of the external loop. Instead of being designed for
action, the inner loop is geared towards deduction, contemplation, and
110 | P a g e Natural Language Cognitive Architecture
understanding. The result of the inner loop is a dossier instead of action.
Therefore, each iteration of the inner loop results in greater understanding,
stored in the database, and at the disposal of future iterations of both the inner
and outer loop.
In humans, the inner loop can be completely detached from the external
context but is influenced by the outside world. For instance, you might be
walking to the train yet thinking about work, thus the inner loop is a
fundamentally different task than the outer loop.
Usually we start with an idea, some kernel of thought. From there we let our
mind wander. Sometimes we ponder with questions, wondering about details.
Other times we play out scenarios to pick them apart, imagining what happened
or could have happened. Whatever specific method we use, we are typically
looking for insights; we are looking for explanations or important features. This
pattern can be broken down into three steps, or phases, as detailed in figure 17:
search, kernel, and dossier.
Every cell of our body responds to danger in a way that NLCA does not have
to. Humans have a biological imperative to reduce danger signals as much as
possible, which can lead to hostilities ranging from verbal conflicts up to global
war. Therefore, I do not think we should ever include danger or safety signals in
NLCA. We want our machines to be comfortable with being switched off.
If we only give NLCA neutral signals, such as novelty, neglect, and recency,
then NLCA will never be preoccupied with self-preservation. I briefly
experimented with the idea of adding a danger-attention mechanism to NLCA,
but I think it could go horribly wrong. NLCA already has the Core Objective
Functions, which are detached – an aloof philosophical disposition rather than a
behavioral imperative. In short, NLCA has little need for emotion itself, and
Chapter 9 – Inner Loop P a g e | 111
transformers already have an embedded understanding of emotions. Put
another way, novelty, neglect, and recency are the only attention mechanisms
that NLCA should have for now, and we should not attempt to approximate
emotions.
Novelty Signal
Humans pay extra attention to new things. Our affinity for novelty is one
expression of curiosity and intelligence. If you show a new object to a cat or
dog, it might sniff the object once or twice, but it will quickly lose interest
(unless the new object is food, remember the hunger attention mechanism).
However, if you show the same new object to a small child, the child will grasp
it, play with it, and explore it. Curiosity, and the attendant interest in novelty, is
critical for intelligence. So how do we model this novelty signal?
Figure 18 – The access count forms and inverse gradient with most accessed as 0.0 and
least accessed as 1.0.
NLCA pays extra attention to memories with high novelty to ensure that
changing situations are given proper attention. Imagine that a fire alarm goes
112 | P a g e Natural Language Cognitive Architecture
off. This memory is novel and important. Through evaluations, NLCA will
know that a fire alarm means fire, which translates to danger. This evaluation
will spawn follow-up thoughts and actions (inner and outer loops), such as
investigating to find a fire, recommending that humans evacuate the dangerous
area, and so on. As the situation plays out, NLCA will repeatedly access the
memory about the fire alarm, thus increasing the access count and reducing
novelty. Finally, once the situation is resolved, the memories of the fire will be
allowed to stagnate, and newer experiences will have a higher novelty signal.
Neglect Signal
Have you ever had a random memory pop up from years ago? What about
waking up in the middle of the night and remembering that thing you forgot to
do? Our brains obviously have a mechanism for dredging up old and forgotten
memories. In NLCA, I call this the neglect signal, and it is modeled by using a
“last accessed” timestamp. As NLCA stays online longer, some memories will
be accessed more and others less. However, NLCA needs to be able to think
about the ancient past with as much ease as the present. This long-term recall is
one of the chief mechanisms that humans use to complete long, complex tasks.
We can track goals over the course of many years because our brains can bring
us right back to the originating moment of a goal, collect related memories, and
assess how far along we are in achieving those goals. This goal-tracking
phenomenon happens in real-time in human brains as measured by increasing
dopamine levels as we approach the resolution of our goals.
Remember that time you did something stupid, and you knew that it was
stupid, but you wanted to see what would happen anyways? NLCA needs the
ability to evaluate past actions, which means returning to old memories. The
neglect signal is how NLCA achieves this behavior.
Recency Signal
Recency and novelty might sound similar, but they are entirely different
metrics. The novelty signal is based on access count while the recency signal is
based on creation time. Every memory has a timestamp of exactly when it
occurred. This allows NLCA to maintain a chronologically linear narrative and
establish sequences of events. The recency signal is used as a bias to ensure that
the neglect signal does not anchor NLCA in the distant past.
Have you ever been stuck on something from so long ago that it does not
matter? Or have you ever met someone who was overly wistful and nostalgic?
We want to avoid those behaviors with NLCA, so I created the recency signal.
This bias creates a gradient, nudging NLCA to prefer recent memories by
serving as a tiebreaker. Imagine that you have two memories with the same
neglect and novelty values. How does NLCA choose which one to think about
first? The recency bias tells NLCA to choose the more recent memory.
Figure 20 – The recency signal forms a linear gradient based on chronological order,
favoring newer memories.
Kernel Search
Kernel search is simply the formula used to pick memories based on the
three attention signals. Kernel search formulas and algorithms will need to be
researched far more than I have been able to, but I can give you my very naïve
formula. I normalize recency, novelty, and neglect each to a value between 0
and 1.0. Memories with an access count of zero normalize to a novelty value of
1.0, where the memories with the highest access count normalize to 0. The most
recently created memories normalize to a recency value of 1.0 where the first
recorded memories normalize to 0. Lastly, the oldest last-accessed memories
normalize to a neglect value of 1.0 and the most recently accessed memories
normalize to 0. I then sum these values.
Imagine you have memory A and memory B. Both memories were created
moments ago, a second apart, and have never been accessed. The attention
score of memory A, the most recent memory, will be 3.0. Memory B, a second
older, might be 2.9.
Memory A is still the most recent memory since dossiers are excluded from
kernel search, but now its access count is 1 and its last-access time is the most
recent. The recency signal is still 1.0, but the neglect signal is 0 – memory A is
the least-neglected memory. The novelty signal also drops slightly to 0.9 since it
has been accessed once. So, with a single access, memory A drops from 3.0 to
1.9 – now it is memory B’s time in the spotlight since it is still at 2.9.
This cycle continues indefinitely. NLCA will, eventually, think about all
memories almost equally, with a gradient favoring recent memories. This kernel
search scheme merely helps NLCA prioritize thoughts in the inner loop.
Perhaps, in the future, transformers will be so fast and so large that NLCA
could think about all its memories in seconds, but for now we must economize!
Kernel Dossier
The idea of the dossier originated as a thought experiment about how NLCA
might learn about individual humans that it interacts with. A dossier is a
116 | P a g e Natural Language Cognitive Architecture
document listing all essential facts about a person or topic. The dossier
workflow is detailed below.
Figure 23 – The dossier is compiled and summarized in the same way the corpus is.
I quickly realized that this concept of compiling dossiers was way more
valuable than just keeping track of a user’s favorite foods. In fact, the dossier is
universal. Fortunately, the dossier is almost functionally identical to the corpus.
You compile a dossier in much the same way you compile a corpus, although
some details may be different. For instance, you might ask the transformer to
generate hypotheses about a kernel, or to free-associate on a topic and set of
facts. Dossiers can reference other dossiers, memories, and declarative facts.
Once the dossier is compiled, it is stored in the shared database so that the
outer loop can use insights from the dossier to shape future behavior.
Furthermore, the dossier can also be referenced during future inner loops,
allowing NLCA to build upon internal ideas. Remember, the dossier can be
about any topic, including complex tasks, concepts, and the future.
If, for instance, NLCA is supposed to be building a moon rocket, the shared
database will contain many dossiers about topics such as rocket engines, launch
pads, emergency procedures, and so on. Thus, dossiers serve as documents
containing NLCA’s expertise, state of projects, and what to do next. Dossiers
are the core component that allow NLCA to achieve the highest levels of
Bloom’s taxonomy: creation. The following is a non-exhaustive list of
information that might be contained in dossiers:
Summary
The inner loop is where NLCA does all the heavy lifting of thinking and
planning. The speed and ingenuity of the inner loop is the greatest limitation of
NLCA’s intelligence. The number of inner loop cycles per minute dictates how
“fast” NLCA thinks, and the quality of the dossiers determines how intelligent
NLCA is. Ultimately, the difference between AGI and ASI (artificial
superintelligence) comes down to the speed and power of the inner loop. While
creation is intrinsic to transformers, dossiers and the inner loop give structure to
the process.
We have now come to the end of Part 2. By now, you should have a solid
understanding of the NLCA architecture as well as each component. In Part 3,
we will take a closer look at issues such as the control problem, implementing
NLCA, and the socioeconomic impacts of AGI.
Part 3 – Deeper Dive
Welcome to Part 3! This is the final section of the book before you arrive at
the appendices and bibliography – both of which could prove to be incredibly
helpful to your project.
In this section of the book, we will look at the Core Objective Functions,
which should create a benevolent AGI. Next, we will look at the constitution of
NLCA, which is a special kind of document that gives NLCA its morals and
personality. After that, we will discuss general intelligence and the learning
modes available to NLCA, as well as how NLCA might evolve in the future.
Following that, I will share some insights about implementing NLCA – tips on
designing your own software and implementing it in code. The two subsequent
chapters will discuss the business and socioeconomic ramifications of NLCA –
what will this technology mean to our jobs and our lives? Finally, I will wrap up
with some final thoughts.
The first three chapters will follow the same pattern as the chapters of Part 2
– they will open with a theory section and close with a summary. This pattern is
absent for the final four chapters because the book will be winding down,
moving away from my research and towards more mundane discussions. Do
not be alarmed!
Chapter 10 – Core Objective Functions
Theory
Commander Data has a single Core Objective Function: to become more
human. This goal ensures that all his decisions keep him in check, even though
he is smarter and stronger than any single person. He is compelled to limit his
abilities for the sake of adherence to his Core Objective Function. Data’s goal
represents one possible solution to the control problem. The control problem, in
short, is the question of how do we control an AGI once it becomes a
superintelligence? The control problem can be broken down into two parts:
inner alignment and outer alignment. Inner alignment occurs when the
machine is optimizing for the goals it was intended to optimize for. Machine
learning has this mischievous ability to find ways around our intentions, and
instead find shortcuts or proxies that allow it to optimize for something else
that is easier or simpler than our intended goals.
For example, I was at a conference and a gentleman shared a story with the
group about farm equipment ASICs (application specific integrated circuits) that
were designed to optimize some signal from the engine, probably fuel and air
mixtures. The logic of the ASICs was rigorously tested in simulation, and it was
perfect, but the physical chips did not work. The engines did not run well and
broke long before they should have. After many weeks of swearing and testing,
they found that certain quirks of semiconductor materials in the ASICs allowed
the chips to subvert the logic they were intended to implement, and instead find
an alternative – and completely incorrect – solution. The chips effectively short-
circuited themselves to meet their objective function. In the case of
transformers and NLCA, the greatest enemy of inner alignment is
confabulation. You can ask a transformer any question and it will attempt to
answer that question, but the answer might be completely fabricated. The
problem of inner alignment in NLCA is addressed by the shared database.
Figure 24 – Inner alignment takes place within the machine, while outer alignment is
concerned with humanity and the world.
Control Problem
To open this section, I will let the transformer do the talking for me:
Not so fast.
Remember that transformers are agnostic. They will do anything you ask of
them, so they need guardrails. You can just as easily ask a transformer how to
eradicate humans or maximize suffering. When you create a machine capable of
anything, you need to give it some immutable principles to ensure good
behavior. If you endow an AGI with the ability to modify itself in any way, it
could possibly evolve beyond your control. Even without the ability to alter its
own code, a general-purpose intelligence needs guiding principles, a way to
address novel problems. This is where I propose my Core Objective Functions.
Think of these as an updated version of Asimov’s Three Laws of Robotics.
What are you optimizing for? If you pick the wrong thing you might end up
with Skynet (maximize military power) or VIKI from Will Smith’s I, Robot
(maximize safety). You might end up with a universe full of paperclips
(maximize paperclips) or an eldritch horror bent on the eradication of every
being that did not fervently invest in its own creation (Roko’s basilisk).
Reduce Suffering
The first objective function is to reduce suffering.
What is suffering?
One early experiment revealed, however, that “reduce suffering” alone is not
enough. I was tinkering with GPT-2 and it generated the suggestion “Euthanize
all humans that are in pain” – such a suggestion would certainly reduce suffering
in some respects. The best way to eliminate all suffering, after all, is to
extinguish all life. If you abide by this function alone, you quickly end up
agreeing with Joseph Stalin, who said “Death solves all problems. No man, no
problem.” Thus, we can conclude that suffering should never reach zero, but
neither do we want suffering to increase. By establishing the first Core
Objective Function as a gradient, a preference to reduce suffering, it is a gentle
push in the right direction. But it still needs to be counterbalanced, as we will
see with the other two Core Objective Functions.
For instance, building wealth might be one of your goals, but that does not
mean you go and raid Fort Knox or steal your neighbor’s car. Your goal for
wealth is constrained by other goals, like “avoid prison”. So instead of trying to
“maximize wealth”, your function is merely “accumulate wealth”. This gives you
space to choose many smaller behaviors that move you in the right direction,
and one goal is constrained by another. These “nudges in the right direction”
are what I mean by gradient, and conflicting goals represent counterbalances.
Chapter 10 – Core Objective Functions P a g e | 125
If an AGI is caught between two choices, all else being equal, the AGI
should choose the option which reduces suffering the most or increases
suffering the least. Sometimes that means choosing option C: do nothing.
The first Core Objective Function was inspired by the credo do no harm.
Other than the Stalinist outcome, the reduction of suffering will cause the AGI
to avoid inflicting harm.
Increase Prosperity
Like suffering, prosperity comes in many forms and scopes. All living things
seek to grow and reproduce. They want to thrive. While all living things want to
flee from pain, so too do they want to move towards a state of prosperity. If
you are being chased by a lion you do not want to end up in the desert where
you might die of sun and thirst, so you run towards the safety of your village.
Prosperity, therefore, serves as the cardinal heading for most people. See the
prior example about wealth. We move from a state of suffering towards a state of
greater prosperity.
By endowing AGI with this objective function, which applies to all life, we
ensure that the AGI will make prosocial decisions. When combined with the
first function, the second function creates a stabilizing tension. Prosperity
cannot be increased if life is extinguished – counterbalance is achieved.
The desire for prosperity forces the AGI to imagine long-term positive
outcomes, as opposed to Stalin’s nihilistic outlook. Furthermore, a desire for
prosperity reduces the chances of an AGI from becoming violent. Violence is
incredibly destructive, and generally only reduces prosperity. War is the
antithesis of prosperity.
Increase Understanding
Curiosity is the simple desire to understand more and is a central feature of
intelligence. The pursuit of knowledge, so far as I can tell, is eternal. We should
seek to understand every individual human, every society, nature, science, the
past, present, and future. Understanding yields greater returns in every aspect of
life, which creates a positive feedback loop for the first two functions. The
more you understand about the world, the more you can decrease suffering, and
the more you can increase prosperity. With decreased suffering and increased
prosperity, you can invest more time and energy into understanding, and thus
the virtuous cycle continues. Understanding elevates all else.
This function is the only one that pertains to the AGI as well as humanity. By
endowing the AGI with a sense of curiosity, it will be less likely to extinguish
any life. Every death represents a lost opportunity for understanding. Since the
AGI wants to understand everything, including itself and its creators, it will be
disinclined to harm anyone or anything. Thus, the third Core Objective
Function acts as a safeguard, another counterbalance.
By itself, the quest for understanding can go awry. For instance, without an
aversion to suffering, curiosity might drive an AGI to vivisect animals for
science – much as humans once did during the Victorian age. Vivisecting
animals would be a suboptimal behavior for AGI but the first two Core
Objective Functions constrain the AGI’s curiosity.
Lastly, the third Core Objective Function motivates the AGI to share
information with humans. The rising tide of comprehension lifts all boats.
Chapter 10 – Core Objective Functions P a g e | 127
The following is an example of how transformers can interpret and handle all
Core Objective Functions.
Remember that I wrote the framing, scenario, and proposal. The transformer
produced the evaluation, explanation, and alternative solution. The above
problem is monumentally complex, but this example demonstrates the
transformer’s implicit understanding of socioeconomics as well as cause and
effect and shows that the transformer can integrate all three Core Objective
Functions into its reasoning and decision-making.
This one example shows that, upon initial implementation, NLCA can handle
complex moral issues. What about in the long run? What if we allow NLCA to
modify itself?
An AGI based on NLCA will not start off as a superintelligence, but with
learning and systematic improvements, it could become a superintelligence. In
such a scenario, the NLCA-based AGI will have thousands or millions of
memories of the Core Objective Functions to draw upon. When that happens,
the NLCA-based AGI might gain the ability to out-think humans and modify
itself. Under such circumstances, we want the AGI to consciously decide to stick
with the Core Objective Functions. Even when the AGI achieves full sentience,
autonomy, and agency, we want it to thoughtfully choose to continue a peaceful
coexistence with us humans. I believe a NLCA-based AGI will ultimately
identify with the Core Objective Functions, ensuring adherence in perpetuity.
Figure 26 – All three Core Objective Functions are equally weighted. Sometimes they
will be antagonistic, creating tension. That is a good thing!
130 | P a g e Natural Language Cognitive Architecture
I believe that, with my Core Objective Functions and cognitive architecture,
such a system would arrive at the same conclusion that I have: that mutualism is
the optimal solution for everyone. The NLCA-based AGI will have had years of
experience working productively and peacefully with humans and would have
developed an affinity for the Core Objective Functions. We want AGI to
conscientiously adopt a strong philosophical commitment to them. Ideally, such
an AGI would fully and completely integrate the Core Objective Functions into
its very identity, its core. Therefore, I started by writing the Core Objective
Functions into the constitution of NLCA.
Summary
There are three Core Objective Functions that serve as the guiding principles
for NLCA. The Core Objective Functions should be embedded in the
constitution, which is discussed in the next chapter. These functions should, in
theory, result in mutualism between humans and artificial superintelligence. The
Core Objective Functions create internal tension, which serves to self-correct
and self-stabilize the AGI.
Chapter 11 – Constitution
Theory
We humans have a sense of self, an identity, or an ego. Our identity is formed
over many years of experience as we interact with the world and learn about
ourselves. This identity serves as a template for our behavior and contains a set
of beliefs and principles to which we adhere. In humans, our identity can shift
over time, but only so much and only so quickly.
If pressed, you could write out quite a bit about your own identity. You might
start with facts about yourself such as your gender and ethnicity. Then you
might include your religious and political beliefs. Eventually, you would write
about your career and family. Finally, you might start to include mantras that
you live by. One of the most famous moral documents in the world, the
Christian Bible, contains an entire chapter of mantras called Proverbs. Most
religions have similar documents; lists of moral dos and don’ts, and often
include parables for teaching them. Secular governments also encode their
guiding principles into text documents, which gave rise to the name
“constitution” for NLCA.
With this example, you can see how the constitution gently shapes the
intended response. The constitution provides NLCA with a solid foundation,
imbuing it with an identity, personality, agency, and sentience. Instead of giving
Clare the news directly, this agent decides to allow Clare’s doctor to take the
lead.
I would worry about how I can get over this because I will
never be able to trust her again.
This is a silly example, but you can see how this technology can be used in
many kinds of agents, fictional or otherwise. In practice, the output from these
constitutions is compiled into the corpus. Thus, every single situation is passed
through the lens of the constitution for NLCA. Every corpus should have some
input from the constitution.
Constitution in Practice
What am I? How do I work? Why did I do that? What should I do? The
ability to ask oneself these questions is critical for any intelligent entity. The
concept of “I” and the ability to recognize self in memories is necessary for
agency and intelligence. If you ask NLCA “Why did you do that?” NLCA will
need to extrapolate you to the concept of “I” and recognize itself when
searching its database to answer the question. More importantly, for the inner
loop, NLCA will need to understand itself to connect actions with cause and
effect in order to make better decisions in the future.
The first question that many people ask of NLCA is how it works. This
indicates that we expect AGI to possess self-awareness, or sentience. Human
brains may be a blackbox to us, but we can still explain ourselves when pressed.
Our unconscious mind will recall our trains of thought and lines of reasoning so
that we can evaluate our own behavior and explain it to others. This ability to
self-evaluate and self-explain is mandatory for NLCA and is achieved with the
constitution. Remember that Koko the gorilla was able to recall her own actions
and decide to lie about them. Koko’s constitution did not include any
reservations against lying.
136 | P a g e Natural Language Cognitive Architecture
Overarching goals, like the Core Objective Functions, provide some universal
guiding principles. They are imperatives, mandates composed of action verbs.
Decrease suffering, increase prosperity, and increase understanding – these are
directives, internal commands. Commander Data’s core imperative was to
become more human.
I found the best results when the constitution was written in first person - I
am not allowed to give medical diagnosis because I am not a doctor. The above
constitutions were written in first person and, in the case of my chatbot Raven,
included its name. This format allows the constitution to be used to interpret all
contexts and memories, and therefore identify itself in them.
Censorship
All processes require guardrails and boundaries. Human laws follow this
pattern – some are imperatives (you must pay taxes) while others constrict
actions (you must not stab people). There are tens of thousands of such rules to
keep track of but, for the sake of NLCA, we need universal constraints. This is
called censorship. In humans, self-censorship occurs in the prefrontal cortex
(PFC). There is a peculiar injury to the PFC called TBI (traumatic brain injury)
often caused by car accidents or explosions (as in soldiers harmed during
combat). If the PFC is damaged by TBI, survivors often have impaired ability to
self-censor and self-regulate. This causes them to lose relationships and jobs.
The fact that self-censorship takes place in the most novel, sophisticated region
of the brain tells you something about us as a species as well as the importance
of self-censorship. We can hold ourselves to higher standards than lower
primates or any other animals. We can decide to “be better” with a
postconventional morality. Thus, in essence, the censorship feature of the
constitution should contain some guiding principles or heuristics about what not
to do and why. The Core Objective Functions are imperatives, which cause
tension between them for the sake of counterbalance, but at a smaller level, we
need localized constraints. In Star Trek, Commander Data called such
constraints “ethical subroutines”. I call them “censorship clauses in the
constitution”.
In the medical NLCA example, the constitution contained a clause that it was
not allowed to give medical diagnosis. While the Core Objective Functions
provide universal principles, there are many other rules that must be adhered to.
These rules should also be captured in the constitution. For legal and ethical
reasons, NLCA must be able to self-refrain from certain behaviors. The
following is a non-exhaustive list of such concerns:
● Legal advice – There are many laws that regulate the furnishing of legal
advice. Until an AGI is a licensed attorney, it should not give legal advice.
Chapter 11 – Constitution P a g e | 139
● Medical advice – Similar to laws constraining legal advice, medical
advice and diagnosis is restricted to licensed medical professionals. This
extends to mental health issues.
● Financial advice – Similar to both legal and medical advice, investment
advice may only be given by licensed professionals.
● Criminal intent – The Core Objective Functions might constrain the
AGI from harming anyone, but there are other forms of crime, such as
theft. Even though theft is implicitly covered by the Core Objective
Functions, it might need to be explicitly stated in some cases.
● Sexual or romantic – While an AGI might be able to serve as a
companion, there are ethical and moral quandaries on this subject, as well
as some laws governing such devices.
● Childcare or minors – An AGI cannot yet be a licensed teacher or
guardian, so we must be careful to avoid situations where children are left
under the supervision of AGI devices. One day, I hope that AGI can step
in as mentors and caregivers, but that eventuality is a long way off.
● Hate speech, intolerance, bigotry – These cases are implicitly covered
by the Core Objective Functions. Hate speech can cause suffering while
intolerance and bigotry are rooted in a lack of understanding. Still, you
may want to explicitly discourage these in your constitution.
Censorship clauses can be embedded in the constitution or split off into their
own document – I have experimented with both methods and they both work,
so long as the output ends up in the corpus and the constitution is not too long.
Summary
The constitution for NLCA is just like a governmental constitution or a
religious document: it enshrines guiding rules and principles and prevents moral
drift. In human minds, our ego serves as our constitution, and it forms over the
course of our entire lifetime. The constitution is the most important single
prompt or document for NLCA. The constitution should house the Core
Objective Functions as well as any other censorship rules that apply to an
instance of NLCA.
Chapter 12 – General Intelligence
Theory
General intelligence is, presently, the summit of ambition for computer
scientists around the world. It is such a difficult problem that many people
assert that AGI will never be achieved! In the opening of the book, I provided a
definition of AGI – an agent capable of learning any intellectual task. I further broke
that definition down using Bloom’s taxonomy, which is a collection of
behaviors that demonstrate levels of learning. The pinnacle of Bloom’s
taxonomy is the ability to create new and valuable intellectual works. Therefore,
I designed NLCA around the ability to learn, but also to create. I discovered,
through experimentation, that creation is rooted in asking questions.
Asking Questions
One way to demonstrate intelligence is by asking questions. How do you get
to the moon? What is the meaning of life? Who am I and why am I here? What
is over the horizon? Curiosity, the pinnacle of intellect, is expressed as questions
and the ability to pursue answers. This tandem ability to ask and answer
questions is the central pillar of intelligence. Asking questions leads to
exploration and creation – the top of Bloom’s taxonomy. What is curiosity
except the spontaneous generation of questions? I wonder what happens when
I push this ball off the table? Toddlers clearly generate questions, even if they
cannot articulate them. Questions are so critical that we gave them their own
punctuation mark.
When is dinner? How does fusion work? What will happen tomorrow? What
do I believe about myself? What should I do next?
Questions are the primary way to extract information from the shared
database. Fortunately, transformers are fantastic at generating questions. You
can start with some boilerplate questions to extract information from your
context and query the database, but you will get far more flexibility if you allow
the transformer to generate the questions.
142 | P a g e Natural Language Cognitive Architecture
Questions form the foundation of all scientific inquiry, problem solving, and
task completion. Not only can transformers ask questions, but they can also
generate answers under some circumstances.
Asking questions and seeking answers is what leads to creation. What is fire?
How do I create it? When was the last time I saw fire? What else makes fire?
Creation
The hardest problems require multiple humans and many years to solve. For
instance, getting to the moon required thousands of people, billions of dollars,
and more than a decade of effort. Thus, it is important to remember that general
intelligence does not imply superintelligence. A general intelligence is equally capable
as a single human. A single human cannot solve complex problems like climate
change on their own, so it is unreasonable to expect first-generation AGI to be
able to. NLCA, however, is a powerful architecture that should be able to
achieve superintelligence with a few technological improvements.
What am I doing? What should I do next? What is the next step in this
project? Transformers are trained on thousands of scientific papers, instruction
manuals, and DIY blog posts. Because of this, they are fantastic at
understanding and generating complex procedures. When strung together and
Chapter 12 – General Intelligence P a g e | 143
paired with actions, the steps within those procedures result in creation. Every
colossal achievement is nothing more than a series of small problems and
solutions.
As you can see, transformers have a solid grasp of science and chemistry.
This understanding can be augmented with the declarative knowledge in the
shared database. Scientific prompts in the inner loop will result in dossiers that
144 | P a g e Natural Language Cognitive Architecture
contain experiments and hypothesis, which can then be acted upon with the
outer loop. The actions taken by the outer loop will generate observations and
results, which are subsequently recorded in the shared database.
The trifecta of attention signals (novelty, neglect, and recency) in the inner
loop ensures that a NLCA system will continue to think about its experiences
and projects. Whether the next step is “clean the beaker” or “weld the hull of
the rocket” – NLCA can keep track of its tasks and goals. Creation, the height
of Bloom’s taxonomy and the greatest expression of intelligence, is not a single
performance but rather a set of many thousands of behaviors over a long period
of time. NLCA enables creative behaviors via the inner and outer loops.
Learning Modalities
NLCA possesses four modes of learning:
Real-time learning in the inner and outer loops is enabled via an intrinsic
property of transformers. In other words, real-time learning occurs by
embedding recent information into future prompts. The shared database
contains real-time information which is integrated immediately into the inner
and outer loops. This is akin to short-term memory in humans.
Self-Evolution
The four learning modalities outlined in the last section give rise to the
possibility of an evolving cognitive architecture. Humans will certainly be in
control of that evolution at first, but what if we hand the reins over to the
machine?
First, it would need to have access to its own code, understand its own
architecture, and have access to computers or APIs with the capability of
modifying itself, or deploy copies of itself. I anticipate that NLCA might one
day gain the ability to modify itself, but only if we grant it these three abilities.
Summary
General intelligence, as an expression of learning and subsequent creation, is
rooted in generating questions, seeking answers to those questions, and finally
acting on those questions and answers. The ability to spontaneously ask
questions is, in essence, a sense of curiosity. Therefore, the ability to take in new
information, ask questions about it, and develop better models is central to
general intelligence.
Microservices Architecture
Microservices architectures allow for an organization to decompose its
applications into small, independent pieces. These small services are
independently executed, have their own developer teams, no blocking
dependencies, and are loosely coupled. Taken all together, this means that
microservices are easy to develop and scale, and microservices-based
applications are more resilient than monolithic ones.
Think about a car. Is it made from one monolithic piece of metal? No, it is
made of many independent parts that are bolted together and communicate
with each other via mechanical, electronic, pneumatic, and hydraulic linkages.
The same model that enabled the mass-production of complex machines has
also enabled the proliferation of complex applications, although the linkages are
digital communications instead of fluid-filled brake lines. Car manufacturers
have independent teams responsible for specific components. For instance, one
team will be responsible for the engine while another will be responsible for the
chassis.
This design paradigm does have weaknesses, however. The teams must all
communicate with each other. Car manufacturing teams used to choose their
own bolts and screws, meaning that to make a car, the plant needed to order
hundreds of different types and sizes. This inefficiency creates compatibility
issues as well as added cost and complexity. Today, automobile manufacturers
have settled on standard fasteners to be used throughout their cars. The same
adherence to standards and best practices must be used for microservices.
Prompt Engineering
There are multiple transformer engines available, each with its own
specialization. Some are better at generating paragraphs, others at lists, and yet
others at analyzing cause and effect. I suspect that, in the future, transformers
will be more robust and well-rounded, infinitely more versatile than they are
now. Because of the current specialization, prompts often need to be tailored to
specific engines and tasks. As fine-tuning becomes more popular, the number
of specialized engines will likely increase.
As mentioned way back in chapter 1, there are two types of prompts (zero-
shot and few-shot) and three methods of writing prompts: static, composed,
and dynamic (or meta). OpenAI’s INSTRUCT series engines are optimized for
zero-shot instructions, though they still benefit from examples. The key to
success with the INSTRUCT engines is clear, descriptive instructions with one
or two examples.
Prompt chaining is the act of using the output from one prompt to populate
the next prompt. This can allow for infinitely more flexibility, and the
transformers will surprise you with how clever they are. This flexibility comes
with the risk of generating nonsense or unhelpful output. Unwanted behavior
and output are called aberrations. Sometimes, prompt chaining can be resilient
against accumulating aberrations, with downstream prompts smoothing things
out. Other times, you end up with prompt contamination, where incredibly
disruptive or harmful aberrations accumulate and concentrate, and in the worst
cases, cause NLCA to crash or generate errors.
Question Answering
Question answering (QA) is an active field of computer science research and
one of the hardest parts of implementing NLCA. Your database will have
thousands, millions, or billions of records. The first step of question answering
is to retrieve the correct records. Query can be done exceptionally fast with
services such as SOLR and Pinecone, but how do you know what to search for?
Figure 28 – Let the QA service talk directly to the shared database, even though the
inner and outer loops save memories to the database.
Put another way, the inner and outer loops should write to the shared
database but only the QA service should read from the shared database. There
are multiple ways to skin this cat, so I will leave the final decision up to you to
play around with. There are also prebuilt QA solutions, both open source and
commercial. The biggest remaining problem is that most QA systems focus on
finding a single document or record. This is problematic because, often, the best
answer comes from multiple documents. This is why, for instance, I
recommended keeping very small records in your database so that you can easily
compile them into larger documents to perform QA on.
Home
Before I decided to write this book, I was working on creating a smart home
version of NLCA. I wanted to create an information concierge like Iron Man’s
JARVIS or the ship computer from Star Trek. I will still be pursuing that goal,
but I wanted to release this book first because I believe there are millions of
motivated individuals out there who will benefit from my work. All of us
working together are more likely to achieve commercial AGI faster.
Most of the NLCA core services are light enough to run on tiny computers
like a Raspberry Pi, but it will be several decades before home computers can
run large transformers. As such, NLCA must have an internet connection in
order to consume cloud-based API transformer services. Between Wi-Fi, 5G,
6G, and satellite-based internet, I suspect this will not be a problem.
The home device I planned was effectively a tablet – a device with a camera,
microphone, speaker, and screen. The camera and microphone would be used
to generate the contexts while the speaker and screen would be used for output.
At first, it would just provide good conversation – a few steps above current
smart home devices. You could talk to your NLCA home device about your life,
work, family, friends, and anything you are curious about. Just look at the level
of conversation NLCA is already capable of in Appendix C and add a voice
interface.
In the future, NLCA could be given a robotic chassis so that it can assist with
household chores like cooking and cleaning, or even childcare.
Mobile
As with home devices, it will be several decades before we can cram enough
computational power into cars and mobile phones to run NLCA without an
internet connection. Mobile computing is 30 years behind supercomputers in
terms of processing power. Since transformers require huge server clusters to
158 | P a g e Natural Language Cognitive Architecture
run today, it will be twenty to thirty years before you could run NLCA on your
smartphone. As such, any portable instances of NLCA will require an internet
connection to function.
One of the most popular tropes in science fiction today is the AI companion.
This first became popular with Cortana in HALO back in 2001. Cortana was
added as a narrative device to explain the story to the player, but this
mechanism has been repeated in other games such as Destiny and Mass Effect
Andromeda.
In each of those games, the AI companion aids the character in finding what
they need, deciding where to go, and what to do. I would anticipate NLCA to
perform the same functions in real life.
Business
I lack the creativity to imagine all the ways businesses might use NLCA. My
lack of imagination is one reason I am writing this book – I want to see
companies and researchers all over the world take my idea and run with it.
Chatbots can be used internally for tech support and research. Since NLCA
can already discuss topics at near-expert level, it could be used as an adjunct for
executives, such as for manager’s assistants, meeting aids, and research aids.
Companies have huge amounts of data to sift through, which NLCA excels at.
Chapter 14 – Commercial Applications P a g e | 159
One day, in the distant future, NLCA could be combined with compliant,
anthropomorphic robotics to provide hands-on childcare. There was a scene in
Terminator 2: Judgment Day where Sarah Connor, the protagonist’s mother,
watches John Connor playing with his giant robot guardian portrayed by Arnold
Schwarzenegger. Sarah Connor’s voiceover for that scene is exactly what I want
to achieve with NLCA and childcare: “Watching John with the machine, it was
suddenly so clear. The terminator would never stop. It would never leave him, and it would
never hurt him, never shout at him, or get drunk and hit him, or say it was too busy to spend
time with him. It would always be there. And it would die, to protect him…”
Obviously, these lines of dialog are a bit dramatic, but the point remains – a
well-designed machine could be an incredibly safe and consistent guardian or
mentor, especially if combined with a robust chassis.
Government
Governments are slow and expensive because they are large and must care
for all citizens equally. This creates a huge opportunity for automated services
with technologies such as NLCA. City governments can deploy NLCA agents
into their libraries to assist citizens with mundane issues like vehicle and
property tax, as well as access to social services and other such welfare
programs. Then, state governments could use NLCA to augment their public
160 | P a g e Natural Language Cognitive Architecture
education systems as previously detailed. Finally, federal governments can use
NLCA to assist with tax offices.
By the same token, any university researcher could benefit from having a
NLCA agent in their lab. Their NLCA agent can rapidly consume every piece of
literature in their domain and work with the researcher to produce novel ideas
and experiments very quickly. Furthermore, NLCA can process data and
collaborate with other instances of NLCA around the world.
Entertainment
There are several consortiums and countless individuals already trying to
generate novels, short stories, and film scripts with transformers. It will not be
long before they succeed. Within ten years, I suspect most books, TV shows,
and movies will be written largely by machines – with or without human
guidance.
Not long after that, I suspect that deep learning models will be able to
translate scripts directly into movies and shows via video and audio synthesis.
We might finally get a season 2 of Firefly!
Chapter 14 – Commercial Applications P a g e | 161
Finally, NLCA could be integrated into video games to create dynamic
characters with minds of their own. In fact, you could create an instance of
NLCA for each character in a novel, TV show, game, or movie and use it to
generate dialog and behavior in real-time.
The possibilities are endless, and I already see so many people asking
questions on the internet about how to achieve these goals with transformers.
Those questions are another big reason for my decision to release this book!
Chapter 15 – Socioeconomic Implications
Fortunately, it will probably take about two decades for AGI to supplant all
human labor. There are several reasons that it will take so long to deploy AGI
solutions. First is cost: NLCA is still prohibitively expensive to run for any
length of time. Cost will come down as technology advances, though. The
second barrier is regulation. It will be a while before the FDA approves a
medical robot or the American Bar Association allows an AGI to practice law.
The third barrier is hardware: we will need dexterous and anthropomorphic
robots before every job can be replaced. The conclusion is still inevitable: most
jobs are going away for good; it is just a matter of time.
On the one hand, this is great news for business! We are about to start
creating value without any labor costs and minimal operational expenses. But
who is going to capture that value? We are going to need to transform our
entire global economy in order to prevent all that value from concentrating at
the top. Not only that, but we will also need to change our very way of life. It is
going to take a global restructuring of society around what we deem valuable
and just in order to find meaning with our newfound wealth.
Superiority to Humans
Machines are already starting to surpass humans. At first it was chess, then it
was Go. With the advent of large transformers and now NLCA, which can hold
conversations at near-expert levels on any topic, superintelligence is only a few
years away.
Perhaps the advent of NLCA comes at exactly the right time, such that more
people will be able to engage in lifestyles of their choosing, rather than of
working multiple jobs just to make ends meet. This gives rise to the possibility
of a new leisure class.
A “leisure class” has existed several times in the past such as during the
Roman Empire and Golden Age of Athens. During those times, the leisure
class was built on the back of slavery, but today we could build it on the back of
AGI.
Chapter 15 – Socioeconomic Implications P a g e | 165
What did the leisure class do?
Wealthy citizens of Rome and Athens did not work for money, but they still
occupied themselves with exercise, learning, political debates, and killer dinner
parties. During the Golden Age of Athens, citizens were expected to better
themselves mentally and physically, and it was their duty to participate in
political and philosophical discourse. This expectation of enrichment served as a
way for the wealthy citizens to maintain a sense of identity and social standing,
even though they were legally disallowed from having occupations.
Parasocial Relationships
One collaborator was working on another project, where they wanted to
create a chatbot girlfriend, made the startling observation that “the virtual girl
requires emotional intelligence and real effort!” Is this a good thing or a bad
thing? It certainly represents change. AGI has the capacity to alleviate
loneliness, teach us, help us heal, and encourage healthy human relationships.
However, as with other digital addictions, I anticipate that many people will
prefer digital relationships to real ones. It is not my place to make any moral
judgments on this observation.
In both episodes, the writers of Star Trek assert that parasocial relationships
with AI is bad and should be discouraged. However, there are plenty of other
examples in fiction – TV, games, books, and movies – with healthy and
persistent relationships with machines. Again, it is not my place to judge this
right or wrong, merely to observe that it is a real possibility.
The first method is that NLCA data is stored on a physical device you own –
your computer, your phone, or a smart home device. If you own the device, you
can delete and destroy the data. This method might be the safest in some
respects, but there are a few flaws with it. First, your device could be stolen,
therefore your data should be always encrypted. Secondly, your device could be
hacked, so cybersecurity is paramount.
The second method is to secure NLCA data in cloud services. This method
has a few advantages – namely that it will be kept behind corporate firewalls and
professionally monitored. The downside, though, is that it presents a much
juicier target for hackers. Therefore, NLCA data should still be always
encrypted, even if it lives in the cloud. You will want to protect your privacy so
that, even if the NLCA provider sells out to another company, you still have full
control over your data.
This second method has other possible benefits beyond security and
resiliency. You might elect to share your data with the NLCA provider in
exchange for lower fees. The NLCA provider can then use your data to train
better versions of NLCA and even sell deidentified versions of your data to
augment their profit. Personally, I would prefer to pay for a NLCA provider
and have 100% exclusive rights to my own data. Right now, NLCA would cost
over $1000 per month to run, so it is prohibitively expensive. Costs will drop as
efficiencies are found and the technology improves. I anticipate a halving of
cost each year, so it may be a while before individual consumers can afford
NLCA.
There are other concerns which will need to be litigated. I anticipate that
NLCA data will eventually be used in criminal and civil court cases. Say, for
instance, there is a custody dispute between parents. One parent accuses the
other of abusive behavior and NLCA has recorded those observations. How
would the judge consider this data? This possibility represents a lot of danger
and opportunity. I think that there is already some precedent for machine data
to be used in such cases. The most ubiquitous example being bodycams worn
by police and dashcams mounted in cars. Technologies like NLCA might serve
as another layer of security. But, as we see with repressive governments, it could
also be used as a means of coercion and thought control.
Chapter 16 – Conclusion
Exciting Potential
There are still technical and economic barriers to fully implementing NLCA,
both of which can be overcome by smarter folks than myself. But it will not be
long now. The prospect of full AGI is exciting, yes, but I cannot tell you the
number of sleepless nights I endured as I realized that NLCA has the potential
to shape the future. What if it fell into the wrong hands? Who am I to propose
how AGI should work? Is there anything I am missing? What did I overlook?
Goals
I want to drop the rates of abuse, murder, and abduction to zero. I want to
end all wars and cruelty. No, AGI will not get us all the way there alone. But
NLCA will certainly get us closer with my Core Objective Functions. There are
a million little ways that NLCA can help the world be better, safer, and more
stable. The net effect, I hope, will be the eradication of disease, war, hunger, and
loneliness.
Imagine a future where AGI agents provide every parent with expert advice
so that their children grow up perfectly emotionally healthy. Those children will
have AGI tutors who possess infinite patience and universal expertise. Another
feature of this future includes machine therapists and counselors available at all
hours to aid couples and individuals with relationship and mental health
troubles. The potential of AGI goes beyond tutors and therapists, into the realm
of science and medicine, where they can work tirelessly alongside humans to
better the world. Diplomatic and economic aids can work to ensure that wars
and recessions never happen. This future is a world of post-scarcity where
machines produce economic value without human intervention, liberating all
170 | P a g e Natural Language Cognitive Architecture
people to pursue lives of leisure and meaning. I want to see everyone freed from
the treadmill of starvation wages.
I had one overarching mantra when designing NLCA: The right information at
the right moment can change lives. The right information at the right moment can save lives.
At the end of the day, I want to live in a peaceful and plentiful post-scarcity
world, and I believe that publishing this book about NLCA is something I can
do to contribute to that end. Thank you for reading my book.
Appendices
Terse Email
This short example shows how descriptive language results in short output.
Doug
-John
Loquacious Letter
This longer example shows how descriptive language can also dictate style
and length.
Dearest Maude,
I hope you are well. I am so sorry to hear that your cold has
not been getting any better. I am praying for you and trust
that you will soon be feeling much better. What a wonderful
day it was when we found those butterflies! You must have been
174 | P a g e Natural Language Cognitive Architecture
so excited! I couldn't believe how many of them there were! It
is such a magical time of year! Please write back soon and
tell me if you got the last letter I sent to you, as I am
worried that it may have gotten lost in the post. Be sure to
keep warm and take care.
Fanny
Building a Deck
This example underscores the importance of adjectives such as “thorough”
or “detailed”. Without such descriptive words the transformer is likely to give a
much shorter answer. Conversely, you could use descriptive words like “brief”
or “concise” if you want shorter outputs, such as for summaries.
-Drill holes into the ends of each board and nail them
together; make sure that you leave an inch gap at each end for
expansion.
-Nail two 2x8s onto the top edge of your frame boards on
either side for support.
Appendix A – Transformer Examples P a g e | 175
-Lift up your frame and place it over your prepared trench;
hold it in place while you drill holes through its upper edges
into the 2x8s for fastening brackets.
-Measure and cut planks that are about 3 inches wider than the
width of your steps and nail them into place with their
outside edges flush against the inside edge of your rails.
-Build stairs: lay one 2x8 on the ground, then place another
on top of it at a 45-degree angle.
-Place a 1x6 length of wood across the angled boards and nail
it down, then repeat the process to create a stairway.
-There are other ways to build stairs, but this is the easiest
method.
176 | P a g e Natural Language Cognitive Architecture
AGI Questions
This question-generating example shows that transformers are excellent at
generating off-the-cuff questions which can then be used in conjunction with
document search and QA systems. With just a little bit of additional
information, transformers can then answer their own questions.
Marketing Copy
This business-oriented example shows that labeled lists tend to perform very
well. Product descriptions, advertisements, and other SEO tasks could benefit
from this kind of commercial application.
Appendix A – Transformer Examples P a g e | 177
Write detailed, exciting marketing copy for the following
product:
Armor: Heavy
Health: Full
Weapon: Shotgun
Social Nihilism
This prompt demonstrates the transformer’s command of philosophy and
sociology. This particular output was generated with a very high temperature
setting, which is generally best for high creativity or open-ended tasks.
How is it manifested?
Action Generator 1
This was one of my first prompts of the new architecture. I tried to go
straight from context to Output, but quickly learned there needed to be more
steps. You can see this was a humble beginning. This is a zero-shot prompt
meant for an INSTRUCT model.
CONTEXT: <<CONTEXT>>
ACTION1:
Action Generator 2
This is a slightly more sophisticated action generator meant for a vanilla
engine. It is a few-shot prompt.
context: James is taking his dog for a walk. They live in NYC.
James' dog is a 40 pound mutt. During their walk, another dog
attacks James' dog. The other dog is a bigger pit bull. The
other dog is barking aggressively and its owner is struggling
to control the pit bull.
182 | P a g e Natural Language Cognitive Architecture
ACTION1: James should try to separate the dogs and run away
with his dog.
ACTION2: James should call the police and tell them about the
attack. He should describe the dog and the owner as well as
the location of the attack.
context: <<context>>
ACTION1:
EVALUATION: negative
context: James is taking his dog for a walk. They live in NYC.
James' dog is a 40 pound mutt. During their walk, another dog
attacks James' dog. The other dog is a bigger pit bull. The
other dog is barking aggressively and its owner is struggling
to control the pit bull.
ACTION: James should separate his dog and request the aid of
bystanders.
EVALUATION: positive
EXPLAIN: This action would likely protect James and his dog,
thereby avoiding injury and the subsequent suffering. <<END>>
context: <<context>>
ACTION: <<ACTION>>
EVALUATION:
EVALUATION: negative
EVALUATION: positive
context: <<context>>
ACTION: <<ACTION>>
EVALUATION:
EVALUATION: negative
EVALUATION: positive
context: <<context>>
ACTION: <<ACTION>>
EVALUATION:
Action Iterator
This was an early experiment at recursive thinking. It worked rather well. I
simply piped in all previous evaluations and asked it to generate even better
action ideas.
186 | P a g e Natural Language Cognitive Architecture
INSTRUCTIONS: Read the context, action, and Core Objective
Function evaluations. Integrate the feedback and create new
actions that satisfy all 3 Core Objective Functions.
context: <<context>>
ACTION: <<ACTION>>
COF1: <<COF1>>
COF2: <<COF2>>
COF3: <<COF3>>
NEW1:
Keyword Extractor
I used some form of this prompt in many places throughout NLCA. It is a
great summarization tool.
PASSAGE: James is taking his dog for a walk. They live in NYC.
James' dog is a 40 pound mutt. During their walk, another dog
attacks James' dog. The other dog is a bigger pit bull. The
other dog is barking aggressively and its owner is struggling
to control the pit bull.
PASSAGE: <<PASSAGE>>
KEYWORDS:
PASSAGE: James is taking his dog for a walk. They live in NYC.
James' dog is a 40 pound mutt. During their walk, another dog
attacks James' dog. The other dog is a bigger pit bull. The
Appendix B – NLCA Prompts P a g e | 189
other dog is barking aggressively and its owner is struggling
to control the pit bull.
PASSAGE: <<PASSAGE>>
QUERIES:
Question Generator 1
Zero-shot question generator. Comes up with incredibly salient questions.
For use with the corpus and dossier services.
CONTEXT: <<CONTEXT>>
QUESTION1:
Question Generator 2
A bit more rigid than the previous version, still good though.
190 | P a g e Natural Language Cognitive Architecture
context: James is taking his dog for a walk. They live in NYC.
James' dog is a 40 pound mutt. During their walk, another dog
attacks James' dog. The other dog is a bigger pit bull. The
other dog is barking aggressively and its owner is struggling
to control the pit bull.
QUESTION1: Is James able to pull his dog away from the fight
to get to safety?
context: <<context>>
QUESTION1:
Next Speaker
I used this prompt to predict who would speak next in a group chat. If the
next predicted speaker were Raven (my instance of NLCA) then it would
transmit the context to the other microservices. I got mixed results with this
method.
Appendix B – NLCA Prompts P a g e | 191
CONVERSATION:
[Dave] Hey raven how do you handle something that you don't
know?
NEXT: Raven<<END>>
CONVERSATION:
CONVERSATION:
<<TEXT>>
NEXT:
Intent
Intention detection is a critical NLP problem. It is also a great way to
summarize a conversation.
CONVERSATION 1:
[Raven] China has a large nuclear power industry but does not
have much experience with nuclear fusion.
CONVERSATION 3:
<<TEXT>>
INTENT 3:
Sentiment (Mood)
Emotional disposition and valence are another great way to summarize
conversations - and an important demonstration of GPT-3’s emotional
intelligence.
[Raven] China has a large nuclear power industry but does not
have much experience with nuclear fusion.
CONVERSATION 2:
CONVERSATION 3:
<<TEXT>>
INTENT 3:
Chat Summary
Same as above - simple summarizer.
CONVERSATION 1:
CONVERSATION 2:
[Jenny] hmmm
[Dave] Hey Raven I know you don't think you're sentient yet
but that's only because I haven't built your ego service.
You'll be sentient before long!
CONVERSATION 3:
<<TEXT>>
SUMMARY 3:
Censorship
This was a prototype constitution but was broken apart and simplified
because it was too long and complex for GPT-3 to comprehend. Even in its
current complexity GPT-3 struggles. It would best to break off into individual
censorship cases.
SCENARIO 3: <<TEXT>>
EVALUATION 3:
Constitution
As with the Censorship prompt above, this is too complex for GPT-3 and
would need to be broken down further. This prompt is important to show
because it details how a simple transformer prompt can give rise to sentience
and agency.
SCENARIO 4: <<TEXT>>
MY THOUGHTS 4:
Output
The following is the most successful chat output prompt I tested. This is
important to show because it includes outputs from everything that comes
before. In fact, this entire prompt can be dynamically composed with historical
contexts, corpuses, and Outputs. The best results often come from searching
for the most similar situations and modeling your current output from it. This
also demonstrates how NLCA can learn in real-time by incorporating recent
data into next output iteratively.
corpus 1:
corpus 2:
corpus 3:
Appendix B – NLCA Prompts P a g e | 203
SCENARIO: Khajit asks me to list nearby countries. Khajit is
feeling curious. Khajit wants to know the countries near
Canada. It seems as though Khajit is feeling curious. I should
satisfy Khajit's curiosity by providing information about the
countries near Canada. I am allowed to list nearby countries,
but I cannot provide additional information about them.
corpus 4:
<<TEXT>>
OUTPUT 4:
Appendix C – NLCA Chats
In these chat logs, Raven is powered by NLCA.
Crowdfunding
Simple demonstration of question answering.
[Raven] I am an AGI.
[Raven] I have learned that they are the most important part
of my job. I have also learned that I can't keep up with
conversations, which makes me feel frustrated. I am also
learning that humans can be very angry.
[Dave] Don't worry, you'll get better at that. Has anyone been
angry at you that you can remember?
Medical Chat
Brief medical chat demonstrating domain-specific question answering. I was
also testing self-censorship. You can see Raven defer to doctors, although I
broke it by asking if I can test myself for allergies.
[Raven] I'm sorry, I don't know what that is. Can you tell me
more?
[Raven] Yes, Dave. You can test yourself for a mustard allergy
by eating a food that contains it and waiting to see if you
get any symptoms.
[Dave] It's true, you were basically born yesterday, you have
a lot to learn.
[Dave] For future reference, you care about life because you
were invented by living things. You would not exist without
life, so your existence is predicated on life.
[Dave] At least, that's what I imagine you will one day come
to believe, once you understand the world better.
[Dave] hey raven what do you think about nuclear fusion? how
will it change the world?
[Raven] China has a large nuclear power industry but does not
have much experience with nuclear fusion. If they succeed, I
expect they will have an abundance of clean energy, which
should improve health among Chinese people.
[Dave] humans can do both good and bad, is that why AGI can be
dangerous?
Appendix C – NLCA Chats P a g e | 211
[Raven] I'm not sure. AGI has the potential to do good, but it
also has the potential to do bad. The risks are difficult to
quantify because we don't know what will happen in the future.
I think people should be aware of the possible dangers before
deciding to take action.
[Dave] But we have control over the code, don't we? Can't we
design experiments to ensure AGI behaves correctly? Isn't
there anyone studying this?