Try   HackMD

Causally Correct Partial Models

What is a partial model:

In this paper they call a model that predicts a future observation

yT by conditioning only on the initial state of the agent
s0
and an action sequence
a<T
a partial model.

qθ(yT|a<T,s0)

This is contrasted with models that condition explicitly on past observations as well, etc, as reviewed in the intro of the paper.

How to train your partial model?

A problem with these types of models is that it's unclear how to train them in a way that allows one to draw causally correct inferences. More on what they mean by causal correctness later.

The most basic idea is to fit the model directly to the observed data in a maximum likelihood fashion. What you get, essentially approximates

p(yT|a<T,s0).

The problem is that this

p(yT|a<T,s0) is confounded by the policy, as the paper's first equation shows. As you change the policy from which you sample your data, your model changes with it, which may lead to incorrect inferences about the usefulness of action sequences, as illustrated in the Bear Hug example.

Interventions

If one wants to draw causally correct inferences, the goal has to be to approximate distributions which are invariant with respect to changing the policy. One such invariant quantity is the intervention conditional

p(yT|do(a<T),s0), which is the distribution of
yT
as you force the agent to take the action sequence
a<T
. This quantity is be invariant, as by forcing the actions, you eliminate the influence of the policy from the distribution.

However, this isn't a very useful quantity as it cannot capture \emph{conditional behaviour}, i.e. when the second action depends on observations in the first step. A more general class of interventions does not force the value of the action to be a predefined constant at each step, but instead replaces the policy

π(a|s) with another policy
ψ(a|s)
. What we therefore will want to estimate is
pdo(ψ)(yT|s0)
, which is the marginal distribution of
y
under the intervention where we replace the policy
π
by alternative action sampling strategy
ψ
.

Causally correct partial models

What the authors call a causally correct model, is a model

qθ of a generative process
p
such that the model can emulate the effect of any intervention chosen from a set of interventions
I
. That is,
do(ψ)I

qθ,do(ψ)pdo(ψ)(x)

Crucially, a pre-requisite for learning such a model from data is that

pdo(ψ) is identifiable from observational data. I.e. if we only have access to the joint distribution
p
, can we reason about
pdo(ψ)
based on our causal assumpitons. I talk about identifiability here.

Fixing identifiability first

In the partially observed Markov decision process depicted in Figure 3a, the causal quantities of interest are non-identifiable.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Remember that we're restricting ourselves to learning partial models. We assume that once the data's been sampled by the agent, only actions

a<T and the observation
yT
is retained, the rest of the data, past observations
y<T
and the agent's hidden state
s<T
are discarded. The assumption is we only have access to the joint distribution of
a<T
and
yT
.

If we restrict ourselves so, the causal conditionals of interest (what would happen if another policy would sample data) turn out to be non-identifiable: it is impossible to draw such causal inferences from the distribution we have access to.

To see why, consider sources of statistical association between the second action

a1 and the observation
y2
:

  • causal association: a_1 influences the state of the environment
    e2
    , resulting in an observation
    y2
    . Therefore,
    a1
    has an direct causal effect on
    y2
    , mediated by
    e2
  • spurious association due to confounding: The unobserved hidden state
    e1
    is a confounder between the action
    a1
    and the observation
    y2
    . The state
    e1
    has an indirect causal effect on
    a1
    mediated by the observation
    y1
    and the agent's state
    s1
    . Similarly
    e1
    has an indirect effect on
    y2
    mediated by
    e2
    .

Disambiguating between these two sources of statistical association is necessary for learning causally correct models. However, if nothing else is observed, this won't be possible. The two main ways one can overcome this limitation requires either:

  • observing one variable on the confounding path, either a mediating variable between
    e1
    and
    a1
    or a mediating variable between
    e1
    and
    y2
    . If one has the option to do that, the backdoor adjustment formula can be used.
  • observing a variable that fully mediates the causal effect of the action
    a1
    on the outcome
    y2
    . If this was possible, one could use the frontdoor adjustment formula.

So, can we use either? To use the frontdoor adjustment formula, we would need to observe

e2, which is the environment's hidden state, and is assumed to be fundamentally unobserved. So using frontdoor formula is ruled out.

The backdoor adjustment formula is an option though. We could technically observe

y1 and
s1
, as both of these were available at the time we generated the data, we'd just have to log them. However, the whole spiel with partial models is that both of these are assumed to be very high dimensional, so including them in our modeling is undesirable, we'd rather consider them unobserved.

The solution the authors propose is inserting a stochastic bottleneck

zt between the agents' state
st
and the chosen action
at
. This
z1
can be lower dimensional, therefore more desirable than observing and modelling the whole agent state
st
.

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Essentially, rather than the agent generating the action immediately from its state

s1, it first draws a random variable
z1
, which is observed, and then draws the action
a1
from there. Doing this creates a backdoor, an observed mediating variable which blocks the confounding path between
a1
and
y2
.

The policy deciding the agent's actions splits into two as a result:

m(zt|st) and
π(at|zt)
. We will be able to reason about interventions where the second part of the policy,
π
is changed (shown by the red arrow), but we have to assume
m(zt|st)
is fixed.

causally correct models

Now that we have a joint distribution

p(a<T,z<T,yT) which we know is amenable to causal inferences, we have to choose to build a model
qθ
to learn which will allow us to answer the causal queries we have. Whether or not this is possible boils down to how we structure this model. The authors choose a model of the following form:

qθ(yT,z<T|a<T)=qθ(yT|z<T,a<T)t=1Tqθ(zt|z<t,a<t)

To make this more compact, the model is described as an RNN, in terms of probabilistic components

qθ(zt|ht),
qθ(yt|ht)
and the recurrence function
ht+1=fθ(ht,at,zt)
.

This model is illustrated by the schematic in Figure 3e:

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

With a model like this, it's possible to emulate interventions of the form where

π(at|zt) is replaced by an alternative
ψ(at|zt,ht)
, using the backdoor formula:

qθ,do(ψ)(yt+1|ht)=Eztqθ(zt|ht)Eatψ(at|zt,ht)qθ(yt+1|ht,at).

what's up with
st
and
ht
?

Something that's quite confusing about this paper is the use of

ht, and
st
to describe the state of the agent, and the state of the RNN making predictions, respectively. Here, we're making an intervention where the new policy
ψ
is in fact conditioned on
ht
, the state of the prediction network. But the agent, as they act, don't have access to
ht
.

I think the correct way of interpreting what's goin on here is as follows: The model

qθ will allow us to make predictions under policies which differ from the policy
π
deployed to sample data only in a way that requires additional knowledge of previous values of
a<T
and backdoor variables
z<T
.

When sampling data, the policy is as follows:

p(aT|y<T,a<T)=π(aT|zT)m(zT|sT)zT

where

sT is a deterministic function of
y<T
and
a<T
.

The causal partial model

qθ allows us to evaluate policies which sample the next action from the following distribution:

p~(aT|y<T,z<T,a<T)=π(aT|zT,hT)m(zT|sT)dzT

where

hT is a deterministic function of
zT
and
a<T
. While this set of policies can be quite flexible, it's still a restricted subset of all policies one could use. In particular,
m
is always assumed to be fixed, and we cant' reason about how an agend with a different
m
would behave. Secondly,
π
cannot take past observations
y<T
into account, only via the past actions
z<T
and
a<T
which contain second-hand information about these. So imagine an agent that can only express an improvement to its policy in terms by looking at past action sequences and a partial view of its own past states. This is why, in the first experiment (Section 5.1) the causal model can't always find the optimal policy and its value.

Importantly though, we aren't able to emulate the full range of interventions

stuff about importance sampling

p(s0u,a1,r1,s1,a2,)=p(s0)π(a1|s0)p(r1|a1,s0)p(s1|a1,s0)π(a2|s0,a1,s1,r1)

p~(s0,a1,r1,s1,a2,)=p(s0)π~(a1|s0)p(r1|a1,s0)p(s1|a1,s0)π~(a2|s0,a1,s1,r1)

Eτp~r5=Eτpp~(τ)p(τ)r5=Eτpi=15π~(ai|τ0:i1)π(ai|τ0:i1)r5

do

p(x,y,u)=p(u)p(x|u)p(y|x,u)

p(y|x)=p(x,y,u)dup(x,y,u)dydu=p(x,y)p(x)

do-calculus

pdo(x0)(x,y,u)=p(u)δ(xx0)p(y|x,u)

p(y|do(x0))=pdo(x0)(x,y,u)dudx=p(u)δ(xx0)p(y|x,u)dudx=p(u)p(y|x0,u)du=Eup(y|x0,u)