Pages and contents
Pages
Object Thought Learner
Introduction
This is the original version of Thought Learner 1. I have decided it best to abandon the slot framework.
Motivation
I seek to create an AI agent capable of general and efficient learning. I propose a framework of dynamics inspired by human cognition. That I will summarize here.
Z
A human thinks in terms of objects and their transitions through time. This seems to necessitate some form of object like structure within the latent space rather than representations that are purely distributed through layers of weights. Our object centric latent space will be denoted as . We should also form beliefs about the future, .
C
A βconsciousβ thought space where the agent is able to plan and process the subconscious beliefs, object encodings, memories, etc. This is a recurrent system (possibly a state space model) that takes previous thoughts as well as present beliefs and experience to produce thoughts capable of triggering actions. I originally was going to include a βworking memoryβ component but the thought space itself should serve as a working memory. Given the current experience and belief context, it could attend to previous thoughts in the series.
M
An explicit long term memory that is queried by the thoughts. This is to be included later. It should likely persist . and should have a mutual influence on the representation space to form a βwell structuredβ latent space. This could perhaps be done in a Hebbian fashion.
A
The action set is to be denoted while an action at time is .
Continuity
In order to preserve a sense of continuity between latent transitions, whether it be the thought space , or the latent object space , we should implement a residual-like property among each component of the network state. Let represent a state at time . A Bayesian update would take the prior belief and adjust it by some gated value. The structural continuity equation is as follows.
The Space
Encoding
Given an environment state , we encode this into dense features by some sub-quadratic attention mechanism, likely FMA or a variant thereof.
Where are the dense encoded features and is the encoding mechanism. We then form slots from these dense features through binding and priors, which will be detailed below. A slot is simply a vector that represents encoded features, meaning is a set of vectors
There are some desirable properties we would like to achieve with this set. For one, it should bind to properties of the environment . Furthermore, it should obey structural continuity, with smooth transitions between frames rather than complete reconstructions at every step. Now we need to determine how beliefs are to influence the latent representation of . We must be careful to not remove all information from that can not predict future states. Factors that are not useful for predicting itself will likely still be useful for the thought space.
Priors
Let represent the prior belief about the state of .
Where can be a slot-former SlotFormer. Then can be written in terms of the prior
Where is a gate term detailed in a later section. This equation means that must be initialized to something. We can sample from a learned Gaussian.
World Model Prediction Loss
We want to contain information that allows the agent to predict how objects will evolve through time. Given the posterior object state and action , the dynamics model predicts the prior object state
Which can be recursively propagated to predict multiple steps into the future.
We compare these predicted states against the posterior object states obtained after actually observing the future environment.
Where is a batch of encodings. For each future timestep , the term
measures the prediction error for object slot . Here is the predicted state of object using information available at time , while is the posterior state produced after observing the environment at . The stop-gradient prevents this loss from directly moving the future posterior representation toward the prediction.
Finally, the outer sum trains the model to predict across multiple future horizons, where controls the relative importance of predictions steps into the future.
Binding and Formation of
We want the posterior object representation to preserve continuity with the prior while incorporating new information from the current observation. We therefore use the prior object vectors as queries into the dense visual features . For each prior object and dense feature , we calculate a competitive binding weight
where the softmax is taken across objects , causing the object slots to compete for each visual feature. We then aggregate the features assigned to each object
where represents the sensory evidence associated with object . We use this evidence to correct the prior representation according to the structural continuity equation
where is a learned gate controlling how strongly new sensory evidence modifies the prior. Therefore provides temporal continuity and object identity, while introduces information from the current observation. This gives the overall transition
For the initial model, should project the visual features into the same dimensional latent space as . If directly adding proves too restrictive, the correction can later be generalized to a learned function .
can be an ,
The and Space
The space is where planning occurs and I attempt to try and mimic a human-like sequence of thoughts. Thoughts can produce their own reward as the space is capable of evaluating its progress towards a goal. It maintains beliefs and refines them according to sensory evidence in a Bayesian manner. It also acts as working memory because depends on previous steps in the time series in a recurrent fashion. This may be done with SSMs. The space can be written in terms of
For the first simplified version, we will defer the function and instead focus on . The current thought should depend on previous thoughts in the sequence in a Mamba-like fashion. There may also be multiple thoughts per time step , but multiple thoughts will be deferred as well.
Where is an attention mechanism deciding which objects in are relevant to the current thought and .
and
Thoughts can produce conscious actions while can produce reflexive actions.
RL Loss
The reinforcement learning loss terms are more difficult conceptually. We can use an actor-critic model to begin. Let the actor describe the actions as a policy with a critic We can define total reward as follows.
The advantage is
The RL loss is then the sum of the critic loss and the actor loss with an included entropy term to encourage environment exploration
\mathcal{L}_{\text{RL}} = \lambda_{A} \mathcal{L}_\text{actor} + \lambda_C \mathcal{L}_\text{critic} - \lambda_H \mathcal{H}(\pi) \\ \mathcal{L}_{\text{RL}} = -\lambda_A\text{sg}[\hat{A}_t] \log (\pi_\theta(A_t \ | \ C_t, Z_t)) + \frac{1}{2}\lambda_C \hat{A}^2 - \lambda_H \mathcal{H}(\pi)
Which backpropagates through all the layers.
Training
An initial training objective could be to use MiniGrid. We donβt want policy gradients to flow to or because this may cause destabilization of the slot encodings.
V2 - Things To Add
Existence Probability
We want to oversupply the number of available slots but not enforce the binding of every slot to some feature.
Rather than having a dynamic cardinality (which creates unwanted complexity), we attach each vector an existence probability . This changes the definition of
Each slot has an existence probability . Rather than updating the probability directly, we maintain an existence logit such that
The dynamics model predicts the prior existence of each object alongside its latent state
After binding the prior slot to the current sensory features, we can measure the amount of evidence assigned to the slot as The posterior existence belief is then updated according to
With . Thus represents whether the object is expected to exist, while the binding evidence from can increase or decrease its posterior existence probability. Inactive slots should still be allowed to compete for unexplained sensory features so that new objects can activate previously unused slots.
We must also change to be weighted by existence probability
as well as adjust attention mechanisms that query to value objects with high existence probability more
Mamba Think Function
Rather than using a simple gated recurrence for the thought space, we can use a Mamba-like state space model to maintain information across a sequence of thoughts. First, the current thought queries the object set to extract relevant information
We then use as the input to a recurrent state space model with hidden state
and produce the current thought from the resulting hidden state
Thus acts as the recurrent memory of the thought sequence, while represents the current explicit thought exposed to the policy. This allows information from earlier thoughts to persist without explicitly attending over the entire previous thought sequence. The overall Think function can therefore be written as
with the transition
OCRL Term For Slots
OCRL introduces a loss term that ensures to prohibit overlapping attention for slots within a VAE.
Explicit Memory
We would like to store thoughts, their associated actions, and associated rewards to query at any given moment. We can call this czar-memory because the variables spell out the word.
Intrinsic Reward for Thoughts
I did not describe a mechanism for thoughts to produce a reinforcement learning reward when the agent βthinksβ it is a step closer to achieving an objective. To do this, the memory query can play a role, as well as somehow representing beliefs of achieving a goal. External reinforcement learning should always be stronger than this.
The belief portion is nice, because once the model understands language, it can interpret negative interactions through beliefs and punish them.