Nyströmformer
This model was released on 2021-02-07 and added to Hugging Face Transformers on 2022-01-11.
Nyströmformer
Section titled “Nyströmformer”
Overview
Section titled “Overview”The Nyströmformer model was proposed in Nyströmformer: A Nyström-Based Algorithm for Approximating Self-Attention by Yunyang Xiong, Zhanpeng Zeng, Rudrasis Chakraborty, Mingxing Tan, Glenn Fung, Yin Li, and Vikas Singh.
The abstract from the paper is the following:
Transformers have emerged as a powerful tool for a broad range of natural language processing tasks. A key component that drives the impressive performance of Transformers is the self-attention mechanism that encodes the influence or dependence of other tokens on each specific token. While beneficial, the quadratic complexity of self-attention on the input sequence length has limited its application to longer sequences — a topic being actively studied in the community. To address this limitation, we propose Nyströmformer — a model that exhibits favorable scalability as a function of sequence length. Our idea is based on adapting the Nyström method to approximate standard self-attention with O(n) complexity. The scalability of Nyströmformer enables application to longer sequences with thousands of tokens. We perform evaluations on multiple downstream tasks on the GLUE benchmark and IMDB reviews with standard sequence length, and find that our Nyströmformer performs comparably, or in a few cases, even slightly better, than standard self-attention. On longer sequence tasks in the Long Range Arena (LRA) benchmark, Nyströmformer performs favorably relative to other efficient self-attention methods. Our code is available at this https URL.
This model was contributed by novice03. The original code can be found here.
Resources
Section titled “Resources”- Text classification task guide
- Token classification task guide
- Question answering task guide
- Masked language modeling task guide
- Multiple choice task guide
NystromformerConfig
Section titled “NystromformerConfig”[[autodoc]] NystromformerConfig
NystromformerModel
Section titled “NystromformerModel”[[autodoc]] NystromformerModel - forward
NystromformerForMaskedLM
Section titled “NystromformerForMaskedLM”[[autodoc]] NystromformerForMaskedLM - forward
NystromformerForSequenceClassification
Section titled “NystromformerForSequenceClassification”[[autodoc]] NystromformerForSequenceClassification - forward
NystromformerForMultipleChoice
Section titled “NystromformerForMultipleChoice”[[autodoc]] NystromformerForMultipleChoice - forward
NystromformerForTokenClassification
Section titled “NystromformerForTokenClassification”[[autodoc]] NystromformerForTokenClassification - forward
NystromformerForQuestionAnswering
Section titled “NystromformerForQuestionAnswering”[[autodoc]] NystromformerForQuestionAnswering - forward