# Why soft actor critic uses exponential of Q when updating policy? and what is a partition function?

Soft Actor-Critic paper proposes $$\pi_{new}=\arg\min_{\pi'\in \prod}D_{KL}\left(\pi'(\cdot|s_t)\big|\big| \frac{\exp(Q^{\pi_{old}}(s_t,\cdot))}{Z^{\pi_{old}}(s_t)}\right)$$

Paper says, we update the policy towards the exponential of the new Q-function(is it really a new Q function when it is $$Q^{\pi_{old}}$$..?) because it guarantees to result in an imporved policy in terms of its soft value.

1. Does it mean, Q is exponential by just a modeling/analytical reason, as it allows us to proof the soft policy improvement theorem? There is no intuitive explanation about it?

2. It says $$Z^{\pi_{old}}(s_t)$$ is a partition function which normalizes the distribution. I understand that its usage is to normalize the distribution. However, what does it mean by partition function? Can someone provide a descriptive explanation/example about it to better understand what is partition function and how it is used to normalize the distribution of $$exp(Q^{\pi_{old}}(s_t,\cdot))$$?

• looking at energy based models might answer some of your questions. Commented Mar 29 at 16:46
• The idea comes from physics. The exp(Q)/Z term is from the Boltzmann equation. Large language models do the same thing, though they call this the "softmax" (which is likely where the name "soft actor-critic" comes from). I'd do some reading up on statistical mechanics, information theory, and evolutionary game theory if you want to understand this on a deeper level. Commented Mar 30 at 1:10

Regarding "we update the policy towards the exponential of the new Q-function", it's correct that the Q-function $$Q(s_t,·)$$ being exponentiated in the policy improvement step is new (latest) at timestep $$t$$, though under the old policy $$\pi_{old}$$. And it's the consideration of energy based ML models rooted in statistical mechanics to motivate taking exponential of the Q-function since intuitively the soft (stochastic) policy as a probability distribution can be regarded as the Boltzmann distribution and the learnable Q-function interpreted as energy can be flexibly arbitrary so long as you have a normalizing partition function.
In all references you could see the partition function involves summation or integral of many or infinite inputs, thus it's usually intractable. And here for SAC policy improvement with continuous action space defined earlier, the inputs are just all actions in the action space $$\mathcal{A}$$, therefore the partition function is $$Z^{\pi_{old}}(s_t)=\int_\mathcal{A} \exp Q^{\pi_{old}}(s_t,a)da$$.