# Transforming myopic optimization to ordinary optimization - Do we want to seek convergence for myopic optimization problems?

While reading some papers, I found a way to take a [myopic](https://www.lesswrong.com/tag/myopia) optimization problem $\mathcal{L}$, and construct a non-myopic optimization problem $\mathcal{L^*}$ whose optima match the fixed points of the original problem $\mathcal{L}$. This seems potentially of interest for myopia research; it could provide a way to think about what optimization of $\mathcal{L}$ might give you, a tool for analyzing the trajectories of myopic optimization, and *maybe* also a better-behaved alternative to myopic optimization.

A common form for myopic optimization, TLDR
-------------------------------------------

In order to explain the transformation, I first need to introduce a common form to myopic optimization problems. The next section goes into detail with applying the common form, but I suspect many people here are sufficiently comfortable with myopic optimization problems that they might be able to do with the shorter explanation.

In ordinary optimization, we might minimize a loss function $\mathcal{L}(m)$. That is, the optimized model $m_n$ would be given by the equation $m_n = \arg\min_m \mathcal{L}(m)$.

This is non-myopic; every influence of m on the result of $\mathcal{L}$ gets optimized. To introduce a myopic equivalent, we need to distinguish between two influences of m; the parts that we want to optimize, and the parts that we want to be myopic about.

We can do that by introducing two separate parameters, $\mathcal{L}(x, y)$, with the first parameter being the parameter we optimize, and the second parameter being the parameter we are myopic about. Given a starting model $m_n$, we can then myopically update this model, yielding $m_{n+1} = \arg\min_m \mathcal{L}(m, m_n)$.

This process can be iterated, but it has many poor properties, e.g. it is not guaranteed to converge, and it is unclear what its results will be. This post is about providing an alternative to that process.

A common form for myopic optimization, long version
---------------------------------------------------

Let's consider an example of myopic optimization.

Suppose you have some predictive model m, which gets trained according to some loss function $L(m, x)$, requiring a distribution of data points $x\sim D$. Essentially, it's trained to minimize $\mathcal{L}(m) = E_{x\sim D}[L(m, x)]$.

If you deploy this model in the real world, then you would hope that it has some sort of real-world effect (if nothing else, then bringing you more ad money); otherwise, what's the point? But if it has a real-world effect, then in particular it might also have a real-world effect on the distribution $\mathcal{D}$ that it encounters.

This might mean that the distribution $D$ it was trained on is no longer good for getting it to optimal performance; we should train it on $\mathcal{D}$ instead. But since $\mathcal{D}$ happened as a result of the model, it is really a function $\mathcal{D}(m)$ of the model. So when we retrain on the data $\mathcal{D}(m_1)$ we got after deploying $m_0$, that yields a *new* model $m_1$ that might induce yet a new training dataset $\mathcal{D}(m_1)$.

If we consider iterating this endlessly, what will happen? Will it be like optimizing the following expression?

$\mathbb{L}(m) = E_{x\sim\mathcal{D(m)}}[L(m, x)]$

If it is like optimizing this expression, then that seems somewhat concerning. Because this expression includes the dependency of the dataset on the model, optimizing this expression would, as a side-effect, optimize the dataset to become more predictable. *How* one would go about making a the real world more predictable is a bit unclear, but considering all of the AI safety concerns for even seemingly innocuous loss functions, this is not something we want to get involved with.

So is this what would get optimized? No; this is where the myopia comes in. When optimizing the model, we don't "look ahead" and think about how the dataset will change in response to the new model. In machine learning terms, we don't propagate the gradients through $\mathcal{D}(m)$.

Rather, it makes more sense to specify the optimization problem using a bivariate loss function, taking as parameters both the model $m$ that is being optimized, and the model $d$ that is currently deployed:

$\mathcal{L}(m, d) = E_{x\sim\mathcal{D(d)}}[L(m, x)]$

In each iteration of optimization, we then change the deployed model to be optimized for the first parameter. This can be expressed as the equation:

$d_{new} = \arg \min_m \mathcal{L}(m, d_{old})$

This optimization method has a number of bad properties. For instance, it is not guaranteed to converge. With ordinary non-myopic optimization, $\mathcal{L}$ always decreases as you optimize it. As long as $\mathcal{L}$ is bounded, this means that you cannot keep coming up with new models that decrease it, and so you must eventually reach the best model.^1

However, in myopic optimization, while $\mathcal{L}(d_{new}, d_{old})$ is always guaranteed to be greater than $\mathcal{L}(d_{old}, d_{old})$, it might be that $\mathcal{L}(d_{new}, d_{new})$ is less than or equal to $\mathcal{L}(d_{old}, d_{old})$. This can happen in "rock-paper-scissors"-like situations, where the optimal solution always changes away from the deployed solution. Hence it might be nice to have an alternative approach.

Characterizing the convergent points
------------------------------------

So, the general form of myopic optimization can be considered to be:

$m_{n+1} = \arg\min_m \mathcal{L}(m, m_n)$

And this is a terrible equation.^2 So we want to improve it.

To make it easier to reason about, let's make an assumption: It has converged to a fixed point. More precisely, we have a value $m_\infty = \arg \min_m \mathcal{L}(m, m_\infty)$; that is, there is no way to change the deployed model to perform better on the training data that comes from the deployed model.

An immediate implication of this is that $\mathcal{L}(m_\infty, m_\infty) = \min_m \mathcal{L}(m, m_\infty)$, and so $\mathcal{L}(m_\infty, m_\infty) - \min_m \mathcal{L}(m, m_\infty) = 0$. But notice that since $\mathcal{L}(x, x) \ge \min_m \mathcal{L}(m, x)$, the left-hand-side in the previous equation is always nonnegative. So this means that the equation holds only when the function $\mathcal{L}^*(x) = \mathcal{L}(x, x) - \min_m \mathcal{L}(m, x)$ is minimized.

This $\mathcal{L}^*$ function is in some ways much better behaved. It tells us what the fixed point is, rather than just telling us a training procedure. However, in other ways it is less well-behaved:

*   The trajectory followed when doing myopic optimization on $\mathcal{L}$ won't actually be the same as the trajectory followed is optimizing $\mathcal{L}^*$ by gradient descent. In fact, often you might not be able to directly optimize on $\mathcal{L}^*$ at all; for instance, the part that you are myopic about is often an emergent property of the real world, rather than a clean math expression.
*   $\mathcal{L}^*$ contains an inner $\min$ expression, which is hard to evaluate, and whose general results might be hard to predict.
*   $\mathcal{L}^*$ does non-myopic optimization on $\mathcal{L}$, in the $\mathcal{L}(x, x)$ term, and simply hopes that this gets cancelled out by the $- \min_m \mathcal{L}(m, x)$ term. This is not necessarily the case; if the myopic optimization fails to converge, then optimization on $\mathcal{L}^*$ might converge to something that has very different consequences from what would happen if we directly optimized $\mathcal{L}$.

These limitations together seem like a good reason to not just apply this transformation for no reason. That said, it seems like there is often a good reason, at least when it comes to assessing the safety of $\mathcal{L}$: I would be concerned about a myopic optimization problem $\mathcal{L}$ whose transformed version $\mathcal{L}^*$ is unsafe; while we would not be guaranteed to reach the unsafe region, it seems like the optimization of $\mathcal{L}$ increases the likelihood of entering the unsafe optimum of $\mathcal{L}^*$ a lot.

Is this useful?
---------------

I got the concept from [this paper](https://arxiv.org/abs/2103.12685), where a basically-identical concept from game theory called "duality gap" is investigated for machine learning. In order to evaluate the usefulness about this transformation for myopic optimization in AI alignment and agency foundations, we need to know more about its properties. I have tried searching a bit around in the game theory literature, but I haven't immediately seen anything that is important for our purposes. Though I also haven't had time to search much, due to my day job.

Fundamentally, it seems to me that there are some potential use-cases for it:

*   Evaluate the likely convergence properties of a myopic optimization; if myopic optimization on $\mathcal{L}$ tends to decrease $\mathcal{L}^*$, then it seems likely to converge, otherwise it seems likely to diverge.
*   Evaluate the possible properties of myopic optimization - it seems reasonable to think about optima for $\mathcal{L}^*$ to get plausible answers for properties that myopic optimization on $\mathcal{L}$ could give (though *how* reasonable depends on things like whether the optimization will converge).
*   Replace myopic optimization with non-myopic optimization; $\mathcal{L}^*$ may possibly be nicer than $\mathcal{L}$. At least in some cases.

When I consider applying the transformation to some obscure myopic optimization problems that I have thought about, then it seems to have some nice properties, but also some potentially concerning ones. I will likely make a followup post where I explain them. But the myopic optimization problems that I am considering are kind of convoluted, so they don't really fit here.

I thought it might be a good idea to leave this open to LessWrong; are there some myopic optimization problems that you have been thinking about? And if so, what effects would this de-myopization transformation have on them?

(Should we call it "duality gap transformation", considering its origins? Or something else?)

* * *

1\. This is actually a lie. This is not sufficient to prove convergence, and this setup also doesn't resemble at all how optimization gets done in practice. In reality convergence is a messy issue even for non-myopic optimization. However, it's a useful simplification.

2\. It is terrible partly because in the limiting form, it is a fixpoint equation, which is hard to reason about. There are variants that are even more terrible; machine learning people might usually phrase it as $m_{n+1} = m_n - \nabla_{m_n} \mathcal{L}(m_n, stopgrad(m_n))$. This uses a mysterious function $stopgrad$ with the property that $stopgrad(x)=x$, but $\frac{d}{dx} stopgrad(x) = 0$ \- which of course cannot be a real function.

* * *

*Thanks to Justis Mills for proofreading.*