SandHouse
Pages and contents

CL1 — C

Reinforcement Head

The reinforcement head is responsible for converting the learned representations in Z, H, and M into action selection and value estimates. It should remain lightweight: Z provides dense perceptual state, H provides temporal context, and M provides relevant historical trajectories. The reinforcement head combines these representations but does not introduce another persistent latent space. Its outputs are

πϕ(At∣Zt,Ht,ℛt)

and

Vψ(Zt,Ht,ℛt)

where πϕ is the policy and Vψ estimates the expected future return.

State Representation

Because

Zt=[zt,1,...,zt,N]

is a dense perceptual representation, it must first be reduced into information relevant for the current decision.

The temporal state Ht can query Zt using attention

qt=QR(Ht)
αt,i=softmaxi(qt⊤KR(zt,i)d)
z‾t=∑iαt,iVR(zt,i)

The controller therefore receives a compact representation

ut=[Ht,z‾t]

Here ut is simply an intermediate neural-network activation rather than a new latent space. The actor and critic are then small neural heads:

πt=πϕ(ut)
Vt=Vψ(ut)

Thus the basic reinforcement path is

(Zt,Ht)→ut→(πt,Vt)

Actor-Critic Learning

The value head estimates the expected discounted future return

Vψ(ut)≈𝔼[∑k=0∞γkrt+k+1]

For sparse rewards, we want reward information to propagate backward through states that occurred well before the reward was observed. We can use bootstrapped λ -returns:

Gtλ=rt+1+γ[(1−λ)Vψ‾(ut+1)+λGt+1λ]

Here Vψ‾ may be a slowly updated target critic for additional training stability. The critic is trained with

ℒV=(Vψ(ut)−sg⁡(Gtλ))2

The corresponding advantage estimate is

At=Gtλ−Vψ(ut)

The policy can then be trained using a standard actor-critic objective such as PPO:

ρt=πϕ(At∣ut)πϕold(At∣ut)
ℒπ=−𝔼[min⁡(ρtAt,clip⁡(ρt,1−ϵ,1+ϵ)At)]

This provides the ordinary model-free reinforcement signal from trajectories actually experienced by the agent.

Retrieving Candidate Plans From M

The memory system provides an additional mechanism for making decisions when historical experience may be useful. Given the current state,

qtM=QM(Ht,Zt),

M retrieves memories whose contexts are similar to the current situation:

ℛt={ξf(1),ξf(2),…,ξf(K)}

Where ξf denotes the continuation component of a historical trajectory ξ. For planning, we are particularly interested in the historical action continuations

𝒜tM={A0:H−1(1),A0:H−1(2),…,A0:H−1(K)}

These sequences should not be interpreted as predictions that history will repeat. Instead, they are candidate strategies that were used in similar situations.

Adapting Retrieved Plans

A retrieved trajectory may originate from a similar but non-identical situation. It should therefore not necessarily be replayed exactly. Instead, each retrieved action sequence can define the center of a small local search:

A0:H−1(j)→{A~0:H−1(j,1),…,A~0:H−1(j,L)}

For continuous action spaces, candidate trajectories can initially be generated using small perturbations:

A~k(j,l)=Ak(j)+ϵk(j,l)

For discrete actions, individual actions can instead be replaced by nearby alternatives or actions sampled from the current policy:

A~k(j,l)∼πϕ(⋅∣ut+k)

The important principle is that M constrains the search toward historically plausible behaviors. Searching local variations of historically relevant trajectories is computationally efficient.

Novelty-Triggered Exploration

Memory retrieval also provides a natural measure of whether the current situation is familiar. Given the current memory query qt and memory keys ki, define the maximum historical similarity

st∗=maxi⁡qt⊤ki.

If no stored episode lies within a required similarity bound, st∗<δM the current state is treated as insufficiently represented in episodic memory. Define the novelty indicator

νt=𝟏[st∗<δM]

When νt=1 , memory-based trajectory proposals are considered unreliable and the controller increases exploration rather than exploiting weakly related historical experience.

Evaluating Candidate Plans With DZ

Each adapted trajectory is evaluated from the current latent state rather than from the historical state in which the memory was created. For candidate trajectory j , initialize Z^j=Zj. The world model then recursively predicts the consequences of the proposed actions:

Z^t+k+1(j)=DZ(Z^t+k(j),A~k(j),Ht)

For a short planning horizon, Ht may initially be held fixed to reduce computational complexity. A later model could recursively update an imagined temporal state as well.

The reward head predicts the reward associated with each imagined transition:

r^t+k+1(j)=RZ(Z^t+k(j),A~k(j),Z^t+k+1(j))

The cumulative predicted reward over the planning horizon is

G^t(j)=∑k=0H−1γkr^t+k+1(j)

Because long world-model rollouts accumulate prediction error, planning should remain relatively short. The critic can estimate the value beyond the final imagined state. First construct the terminal control representation

ut+H(j)=[Ht,Attend⁡(Z^t+H(j),Ht)]

The complete trajectory score is then

Jt(j)=∑k=0H−1γkr^t+k+1(j)+γHVψ(ut+H(j))

The first term evaluates consequences inside the world-model rollout, while the terminal value estimates consequences beyond the planning horizon.

Sparse Reward and Episodic Memory

Sparse reward creates two related problems:

1. Determining which previous states and actions contributed to a delayed reward.
2. Rediscovering rare successful action sequences in the future.

The critic primarily addresses the first problem. Through bootstrapped value learning, information about a delayed reward propagates backward through earlier states.M helps address the second problem.

Because reward is one of the triggers used to create episodic memory anchors, rare successful trajectories are explicitly preserved. When a similar context occurs again, the successful continuation can be retrieved and evaluated from the new state.

Surprise-based anchors are also useful because an important transition may occur without immediate reward. Large surprise indicates that something occurred which the current world model did not expect. Such experiences may be worth remembering even if their behavioral importance is not yet understood.

Distilling Planning Into the Policy

Memory retrieval and world-model rollouts are more computationally expensive than directly evaluating the policy. The agent should therefore learn from successful planning so that behaviors which initially require deliberation can eventually be produced directly by the actor.

Suppose the planner evaluates J candidate trajectories with scores Jt(1),Jt(2),…,Jt(J) These scores can be converted into a distribution over candidate plans:

pj=exp⁡(Jt(j)/τ)∑lexp⁡(Jt(l)/τ)

Each trajectory proposes an initial action A~0(j) . The actor can then be trained to assign greater probability to the initial actions of high-value plans:

ℒplan=−∑jpjlog⁡πϕ(A~0(j)∣ut)

The planner therefore acts as a teacher for the direct policy. This allows a useful behavior to transition from expensive deliberation to cheap habitual execution:

unfamiliar state→retrieve→adapt \& explore→simulate→act,

while later

familiar state→πϕ(At∣ut).

Planning therefore does not need to be performed at every timestep.

Reinforcement Objective

The complete reinforcement objective can combine policy learning, value learning, planner distillation, and entropy regularization:

ℒRL=λπℒπ+λVℒV+λPℒplan−λℋℋ(πϕ(⋅∣ut))

The entropy term encourages continued exploration, which is especially important before useful reward trajectories have been discovered.