# Margin Infused Relaxed Algorithm

This method is used by Watanabe et al., EMNLP 2007 to train an MT system a with a very large number of features of the order of millions. The training step was performed using a specific algorithm called the Margin Infused Relaxed Algorithm (MIRA) proposed by Crammer et al., 2006.

## Summary

MIRA is an online large-margin training algorithm which updates the weight vector according to certain margin constraints and loss function.

It is used to learn the weights of features after processing each training instance similar to the structured perceptron algorithm with an additional loss function and margin constraint in its update rule.

## General Definition

A general definition of online training algorithms can be written down as follows:

• ${\displaystyle \forall t,\quad (f^{t},\mathbf {e} ^{t})\in {\mathcal {T}}}$ and a list of ${\displaystyle m}$ -best oracles ${\displaystyle {\mathcal {O}}^{t}}$. A ${\displaystyle k}$ -best list of candidates is generated by ${\displaystyle best_{k}(\cdot )}$ using the current weight vector ${\displaystyle \mathbf {w} _{i}}$. Each training instance ${\displaystyle f_{t}}$ can have a multiple number of correct outputs or references, ${\displaystyle \mathbf {e} ^{t}}$, in this case, target translations.
• Using the ${\displaystyle k}$-best list, ${\displaystyle m}$-best oracle translations ${\displaystyle {\mathcal {O}}^{t}}$ is updated by ${\displaystyle oracle_{m}(\cdot )}$ in each iteration.
• New weight vector ${\displaystyle \mathbf {w} ^{i+1}}$ is computed using the ${\displaystyle k}$-list ${\displaystyle {\mathcal {C}}^{t}}$ with respect to the oracle ${\displaystyle {\mathcal {O}}^{t}}$.
• After ${\displaystyle N}$ iterations, the algorithm returns an averaged weight vector over ${\displaystyle T}$ training instances to avoid overfitting.

## MIRA

The difference in MIRA lies in the weight update rule which differs from one algorithm to the other. It has been widely used in structured classification tasks such as dependency parsing (McDonald et al., 2005) and joint-labeling/chunking (Shimizu and Haas, 2006).

• The basic idea is to keep the norm of the updates to the weight vector as small as possible,
• Considering a margin at least as large as the loss of the incorrect classification.
• The update rule in MIRA is given by:

${\displaystyle \mathbf {\hat {w}} ^{i+1}={\underset {w}{\operatorname {argmin} }}\quad ||\mathbf {w} ^{i+1}-\mathbf {w} ^{i}||^{2}+C\sum _{{\hat {e}},e^{\prime }}\xi ({\hat {e}},e^{\prime })}$

subject to

${\displaystyle s^{i+1}(f^{t},{\hat {e}})-s^{i+1}(f^{t},e^{\prime })+\xi ({\hat {e}},e^{\prime })\geq L({\hat {e}},e^{\prime };\mathbf {e} ^{t})}$

${\displaystyle \xi ({\hat {e}},e^{\prime })\geq 0}$

${\displaystyle \forall {\hat {e}}\in {\mathcal {O}}^{t},\quad \forall {\hat {e}}\in {\mathcal {C}}^{t}}$

where, ${\displaystyle s^{i}(f^{t},e)=\left\{\mathbf {w} ^{i}\right\}^{\mathrm {T} }\cdot \mathbf {h} (f^{t},e)}$.

${\displaystyle \xi (\cdot )}$ is a nonnegative slack variable and ${\displaystyle C\geq 0}$ is a constant to control the influence to the objective function. A larger C implies larger updates to the weight vector.

${\displaystyle L(\cdot )}$ is a loss function, that measures the "difference" between ${\displaystyle {\hat {e}}}$ and ${\displaystyle e^{\prime }}$ according to the set of references ${\displaystyle \mathbf {e} ^{t}}$.

A larger error means a larger distance between the scores of the predicted correct and incorrect outputs.

## Dual Form

The Langrage dual form for MIRA's objective function is given by:

${\displaystyle max_{\alpha (\cdot )\geq 0}\quad -{\frac {1}{2}}||\sum _{{\hat {e}},e^{\prime }}\alpha ({\hat {e}},e^{\prime })\left(\mathbf {h} (f^{t},{\hat {e}})-\mathbf {h} (f^{t},e^{\prime })\right)||^{2}\quad +\quad \sum _{{\hat {e}},e^{\prime }}\alpha ({\hat {e}},e^{\prime })L({\hat {e}},e^{\prime };\mathbf {e} ^{t})\quad -\quad \sum _{{\hat {e}},e^{\prime }}\alpha ({\hat {e}},e^{\prime })\left(s^{i}(f^{t},{\hat {e}})-s^{i}(f^{t},e^{\prime })\right)}$

subject to

${\displaystyle \sum _{{\hat {e}},e^{\prime }}\alpha ({\hat {e}},e^{\prime })\leq C}$

with the weight vector update,

${\displaystyle \mathbf {w} ^{i+1}=\mathbf {w} ^{i}\;+\;\sum _{{\hat {e}},e^{\prime }}\alpha ({\hat {e}},e^{\prime })\left(\mathbf {h} (f^{t},{\hat {e}})-\mathbf {h} (f^{t},e^{\prime })\right)}$

The dual form is solved using a QP-solver, such as a coordinate ascent algorithm, by heuristically selecting ${\displaystyle ({\hat {e}},e^{\prime })}$ and by updating ${\displaystyle \alpha (\cdot )}$ iteratively:

${\displaystyle \alpha ({\hat {e}},e^{\prime })=max\left\{0,\;(\alpha ({\hat {e}},e^{\prime })+\delta ({\hat {e}},e^{\prime }))\right\}}$

${\displaystyle \delta ({\hat {e}},e^{\prime })={\frac {L({\hat {e}},e^{\prime };\mathbf {e} ^{t})-\left(s^{i}(f^{t},{\hat {e}})-s^{i}(f^{t},e^{\prime })\right)}{||\mathbf {h} (f^{t},{\hat {e}})-\mathbf {h} (f^{t},e^{\prime })||^{2}}}}$

${\displaystyle C}$ is used to clip the amount of updates.