{"url":"/method/mogrifier-lstm","slug":"mogrifier-lstm","name":"Mogrifier LSTM","full_name":"Mogrifier LSTM","full_name_withheld":false,"description_markdown":"The **Mogrifier LSTM** is an extension to the [LSTM](https://paperswithcode.com/method/lstm) where the LSTM’s input $\\mathbf{x}$ is gated conditioned on the output of the previous step $\\mathbf{h}\\_{prev}$. Next, the gated input is used in a similar manner to gate the output of the\r\nprevious time step. After a couple of rounds of this mutual gating, the last updated $\\mathbf{x}$ and $\\mathbf{h}\\_{prev}$ are fed to an LSTM.  \r\n\r\nIn detail, the Mogrifier is an LSTM where two inputs $\\mathbf{x}$ and $\\mathbf{h}\\_{prev}$ modulate one another in an alternating fashion before the usual LSTM computation takes place. That is: $ \\text{Mogrify}\\left(\\mathbf{x}, \\mathbf{c}\\_{prev}, \\mathbf{h}\\_{prev}\\right) = \\text{LSTM}\\left(\\mathbf{x}^{↑}, \\mathbf{c}\\_{prev}, \\mathbf{h}^{↑}\\_{prev}\\right)$ where the modulated inputs $\\mathbf{x}^{↑}$ and $\\mathbf{h}^{↑}\\_{prev}$ are defined as the highest indexed $\\mathbf{x}^{i}$ and $\\mathbf{h}^{i}\\_{prev}$, respectively, from the interleaved sequences:\r\n\r\n$$ \\mathbf{x}^{i} = 2\\sigma\\left(\\mathbf{Q}^{i}\\mathbf{h}^{i−1}\\_{prev}\\right) \\odot x^{i-2} \\text{ for odd } i \\in \\left[1 \\dots r\\right] $$\r\n\r\n$$ \\mathbf{h}^{i}\\_{prev}  = 2\\sigma\\left(\\mathbf{R}^{i}\\mathbf{x}^{i-1}\\right) \\odot \\mathbf{h}^{i-2}\\_{prev} \\text{ for even } i \\in \\left[1 \\dots r\\right] $$\r\n\r\nwith $\\mathbf{x}^{-1} = \\mathbf{x}$ and $\\mathbf{h}^{0}\\_{prev} = \\mathbf{h}\\_{prev}$. The number of \"rounds\", $r \\in \\mathbb{N}$, is a hyperparameter; $r = 0$ recovers the LSTM. Multiplication with the constant 2 ensures that randomly initialized $\\mathbf{Q}^{i}$, $\\mathbf{R}^{i}$ matrices result in transformations close to identity. To reduce the number of additional model parameters, we typically factorize the $\\mathbf{Q}^{i}$, $\\mathbf{R}^{i}$ matrices as products of low-rank matrices: $\\mathbf{Q}^{i}$ =\r\n$\\mathbf{Q}^{i}\\_{left}\\mathbf{Q}^{i}\\_{right}$ with $\\mathbf{Q}^{i} \\in \\mathbb{R}^{m\\times{n}}$, $\\mathbf{Q}^{i}\\_{left} \\in \\mathbb{R}^{m\\times{k}}$, $\\mathbf{Q}^{i}\\_{right} \\in \\mathbb{R}^{k\\times{n}}$, where $k < \\min\\left(m, n\\right)$ is the rank.","description_state":"present","introduced_year":null,"introduced_by":{"title":"Mogrifier LSTM","paper":"/paper/mogrifier-lstm","first_author":"Gábor Melis","n_authors":3,"url_abs":null,"archive_paper_url":"https://paperswithcode.com/paper/mogrifier-lstm"},"source":{"url":"https://arxiv.org/abs/1909.01792v2","title":"Mogrifier LSTM","url_on_a_paper_host":true},"code_snippet_url":null,"code_snippet_url_on_a_code_host":false,"categories":[{"area":"Sequential","area_id":"sequential","collection":"Recurrent Neural Networks","url":"/methods/category/recurrent-neural-networks","pwc_aliases":[]}],"n_papers_tagged":2,"archive_num_papers":2,"papers_newest_first":[{"paper":"/paper/gates-are-not-what-you-need-in-rnns","title":"Gates Are Not What You Need in RNNs","date":"2021-08-01","arxiv_id":"2108.00527","n_code_links":1,"syntology":null},{"paper":"/paper/mogrifier-lstm","title":"Mogrifier LSTM","date":"2019-09-04","arxiv_id":"1909.01792","n_code_links":3,"syntology":null}],"papers_shown":2,"tasks":[{"task":"/task/language-modelling","name":"Language Modelling","papers":2},{"task":"/task/language-modeling","name":"Language Modeling","papers":1},{"task":"/task/music-modeling","name":"Music Modeling","papers":1},{"task":"/task/sentiment-analysis","name":"Sentiment Analysis","papers":1}],"tasks_shown":4,"n_tasks":4,"usage_by_year":[{"year":"2019","papers":1},{"year":"2021","papers":1}],"row_source":"methods_table","archive":{"source":"pwc-archive (Hugging Face), CC BY-SA 4.0","snapshot":"2025-07-28","archive_url":"https://paperswithcode.com/method/mogrifier-lstm"},"syntology_read_at":"2026-09-24T18:15:14+00:00"}