> For the complete documentation index, see [llms.txt](https://doraemonzzz.gitbook.io/transformer_evolution_paper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doraemonzzz.gitbook.io/transformer_evolution_paper/rnn/005.md).

# Quasi-recurrent neural networks

论文地址：

* <https://arxiv.org/abs/1611.01576>

## 整体思路以及计算方式

利用卷积+linear rnn的思路进行token mixing。

第一步，卷积进行local mixing：

$$
\begin{aligned} & \mathbf{Z}=\tanh \left(\mathbf{W}\_z \* \mathbf{X}\right) \ & \mathbf{F}=\sigma\left(\mathbf{W}\_f \* \mathbf{X}\right) \ & \mathbf{O}=\sigma\left(\mathbf{W}\_o \* \mathbf{X}\right) \end{aligned}
$$

第二步，linear rnn进行global mixing：

$$
\mathbf{h}\_t=\mathbf{f}*t \odot \mathbf{h}*{t-1}+\left(1-\mathbf{f}\_t\right) \odot \mathbf{z}\_t
$$

注意这个形式展开后写成long conv的形式。

## 代码

* <https://github.com/salesforce/pytorch-qrnn>

## 简评

不错的思路，本质上还是local conv + global conv。
