# Poster 29736

- Kind: Poster
- Talk page and recording: https://iclr.cc/virtual/2025/poster/29736

> Transcript of the talk's recording (session_asr), made by speech recognition or taken from the host's captions. It may contain errors. The words are the speakers'; listen to the recording on the talk's page before quoting it.

Hi, thanks for checking out our paper. I'm Zhiti Wang. I'm happy to present our work Transformers Can Learn Temporal Difference Methods for In -Context Reinforcement Learning, done with my co-first author Ethan Blazer, our collaborator Hadi Daneshman, and our advisor Xiangtong Zhang. I will begin with a brief intuition of In-Context Reinforcement Learning. In-Context RL is RL in inference time. Taking policy evaluation as an example,
We see at the top is an illustration of the workflow of in-weight policy evaluation, where we employ some parametric function f-theta, training it with a trajectory of interaction history as a sequence of states and rewards, and produce an optimized parameter theta star. We then freeze this theta star and apply it to approximate the value of a query state s.
On the contrary, in a context policy evaluation, we call this interaction history as context and concatenate it with a query state s and fit everything into a model g theta star. g theta star may never encounter this trajectory before, however it will learn from the context during the inference time and will output a reasonable approximation for the query state s.
So one may wonder what model possesses such a powerful mechanism that it can bake a policy evaluation algorithm into its forward propagation. It turns out that transformers can do such amazing things, and here is a motivating example in our paper where we show that there exists some transformer with fixed weights that improves its policy evaluation performance as the context length increases.
And the improvement is confirmed by the decrease of the mean square value error, as shown in the figure. And we argue that it cannot be the case that a transformer is hard coding the value approximation because the performance wouldn't change otherwise. So it must have learned some policy evaluation algorithm in context.
Okay, now we are ready to present our first contribution, which is proof by construction that linear transformers can implement linear TD in context. If we construct the input matrix as in the left and passes it through transformer layers with some special weights.
The bottom right value of the output embeddings represents some value approximations, and we proved that this value estimation is equivalent to as if one did some weights, W, for linear function approximation using semi-gradient TD update on the context data, and specifically Vk here equals to the inner product of the feature of the query state, phi s.
m_wk which is the weight produced by td allocate step. An expression in the brackets is the td error and phi_si is the gradient with respect to wk.
And having known that transformers are expressive enough to implement in-context TD, we then show what training gives in -context TD. We found that if we train the transformers also using the principles of TD, the pattern of in-context TD would emerge naturally. And here C is a context and theta denotes the transformer's learnable weights. And we update theta using the same spirit of TD.
And we call our algorithm multitask TD because we train the transformer on a diverse set of tasks and features. And here is a visualization of the convergence of multitask TD. And this converged weight is very close to what we have proved in part one of our work. So our conclusion is that transformers learn to implement TD by training with multitask TD, which is very impressive.
So I only expanded on our main contributions made in this work due to time limits, and in summary, we proved by construction that linear transformers can implement linear TD as well as TD lambda and average reward TD.
The second leap at training with a multitask TD in context TD emerges and we also justified why our multitask TD converges to in context TD by showing that the weight construction of in context TD in the single layer case is an invariant set for multitask TD in expectation. That concludes my presentation. Thank you so much for your attention.
