All models

yoso

A Transformer encoder whose self-attention is approximated by LSH-based Bernoulli sampling at linear cost.

Language · 678 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (29 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
127.4M
Operations
678
Framework
PyTorch
Recurrent
No
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m11557
Graph hash
a25d63604aeabf40d7de58e5e1fc76d5453ca463b359b19caa3a41c7629e1ff7
Skeleton hash
d3c2ce84d34a522e96444804388e9f0fe91b0647820de11a4982ea8065e41962
Architecture hash
08f5a7ccbd20429065a0e6fe7e561d1c7e533643b844b391246cf3aa2c714d6b
Diagram SHA-256
8bf3b5425fc6a6a85c370ef4885f1cd0c28c982cca74fd342ac9d3939a97f686
TorchLens version
2.35.3
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

How this diagram was made

transformers.AutoModelForMaskedLM.from_config()

What it is

YOSO is a Transformer model that approximates standard softmax self-attention at a cost linear in sequence length. It was proposed in the paper You Only Sample (Almost) Once: Linear Cost Self-Attention Via Bernoulli Sampling. Standard self-attention captures the interactions of token pairs and depends quadratically on the sequence length, which makes training on longer sequences expensive. YOSO instead uses a Bernoulli sampling scheme based on Locality Sensitive Hashing (LSH), in which, in principle, all the Bernoulli random variables can be sampled with a single hash.

The paper reports favorable performance relative to a standard pretrained Transformer on the GLUE benchmark at the standard 512 sequence length, and on the Long Range Arena benchmark results consistent with softmax self-attention with speed-ups and memory savings. The attention algorithm is implemented through custom CUDA kernels, but the default YOSO-E setting does not require compiling them.

Key idea. The paper shows that a Bernoulli sampling attention mechanism based on Locality Sensitive Hashing decreases the quadratic complexity of self-attention to linear.

  • yoso
  • you only sample (almost) once
  • linear cost self-attention
  • bernoulli sampling attention
  • locality sensitive hashing
  • lsh attention
  • efficient transformer
  • yoso-e
  • masked language modeling

AI-written summary, based on the model's documentation and checked automatically against it; not reviewed by a person. Corrections welcome.