Perceiver AR 是對像 GPT - 2 這樣的純僅解碼器 Transformer 的簡單擴展。兩者的核心構建塊都是 解碼器層,它由一個自注意力層和一個逐位置的多層感知機(MLP)組成。自注意力使用因果注意力掩碼。
Perceiver AR 在其第一個注意力層中還會對輸入序列的較長前綴進行交叉注意力操作。這一層是一個混合的自注意力和交叉注意力層。自注意力作用於輸入序列的最後 n 個位置,並使用因果注意力掩碼;交叉注意力從最後 n 個位置指向前 m 個位置。輸入序列的長度為 m + n。這使得 Perceiver AR 能夠處理比僅基於自注意力的解碼器 Transformer 大得多的上下文。
圖 1. Perceiver AR 中 m = 8 個前綴標記和 n = 3 個潛在標記的注意力機制。
混合注意力層的輸出是與輸入序列的最後 n 個標記相對應的 n 個潛在數組。這些數組會被一個由 L - 1 個解碼器層組成的棧進一步處理,其中注意力層的總數為 L。最後一層(圖 1 中未顯示)會為每個潛在位置預測目標標記。最後一層的權重與輸入嵌入層共享。除了對前綴序列的初始交叉注意力之外,Perceiver AR 在架構上與僅解碼器的 Transformer 相同。
krasserm/perceiver - ar - sam - giant - midi 模型是從訓練檢查點創建的,代碼如下:
from perceiver.model.audio.symbolic import convert_checkpoint
convert_checkpoint(
save_dir="krasserm/perceiver-ar-sam-giant-midi",
ckpt_url="https://martin-krasser.com/perceiver/logs-0.8.0/sam/version_1/checkpoints/epoch=027-val_loss=1.944.ckpt",
push_to_hub=True,
)
📄 許可證
本項目採用 Apache - 2.0 許可證。
📚 引用
@inproceedings{hawthorne2022general,
title={General-purpose, long-context autoregressive modeling with perceiver ar},
author={Hawthorne, Curtis and Jaegle, Andrew and Cangea, C{\u{a}}t{\u{a}}lina and Borgeaud, Sebastian and Nash, Charlie and Malinowski, Mateusz and Dieleman, Sander and Vinyals, Oriol and Botvinick, Matthew and Simon, Ian and others},
booktitle={International Conference on Machine Learning},
pages={8535--8558},
year={2022},
organization={PMLR}
}