Downloads · 30 days
0
sashay/linear-shortcut
linear-shortcut is a machine learning model from sashay. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains some of the matrices as described in
Downloads · 30 days
0
Access
Public
Updated Apr 24, 2023
Repo size
11 GB
Likes
0
Public
Click a slice to open those files.
.pickle11 GB · 100%
From the Hugging Face model README
This repository contains some of the matrices as described in
please cite the paper as:
@article{din2023jump,
title={Jump to Conclusions: Short-Cutting Transformers With Linear Transformations},
author={Yom Din, Alexander and Karidi, Taelin and Choshen, Leshem and Geva, Mor},
journal={arXiv preprint arXiv:2303.09435},
year={2023},
}
For example, the file in gpt2-medium/wikipedia/6_9.pickle contains the matrix trained, on the wikipedia dataset, to transform 6th-layer hidden representations of tokens into 9th-layer hidden representations, for the Huggingface transformers gpt2-medium model. One loads and multiplies as follows:
import pickle
import torch
with open(file_name, 'rb') as f:
mat = pickle.load(f)
assert(isinstance(mat, torch.Tensor))
assert(len(mat.shape) == 2)
assert(mat.shape[0] == mat.shape[1])
v = torch.rand(mat.shape[1])
w = mat @ v
assert(w.shape == v.shape)
Some more information is in https://github.com/sashayd/mat.