Skim-Attention: Learning to Focus via Document Layout
Paper • 2109.01078 • Published
How to use nglaura/skimformer with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("fill-mask", model="nglaura/skimformer") # Load model directly
from transformers import AutoModelForMaskedLM
model = AutoModelForMaskedLM.from_pretrained("nglaura/skimformer", dtype="auto")# Load model directly
from transformers import AutoModelForMaskedLM
model = AutoModelForMaskedLM.from_pretrained("nglaura/skimformer", dtype="auto")A collaboration between reciTAL & MLIA (ISIR, Sorbonne Université)
Skimformer is a two-stage Transformer that replaces self-attention with Skim-Attention, a self-attention module that computes attention solely based on the 2D positions of tokens in the page. The model adopts a two-step approach: first, the skim-attention scores are computed once and only once using layout information alone; then, these attentions are used in every layer of a text-based Transformer encoder. For more details, please refer to our paper:
Skim-Attention: Learning to Focus via Document Layout Laura Nguyen, Thomas Scialom, Jacopo Staiano, Benjamin Piwowarski, EMNLP 2021
@article{nguyen2021skimattention,
title={Skim-Attention: Learning to Focus via Document Layout},
author={Laura Nguyen and Thomas Scialom and Jacopo Staiano and Benjamin Piwowarski},
journal={arXiv preprint arXiv:2109.01078}
year={2021},
}
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("fill-mask", model="nglaura/skimformer")