SeqPool
Pytorch library implementing pooling methods for sequences of embedding vectors.
Installation
pip install seqpool
..or build from source ~
Usage
Import a sequence pooling layer and apply it to a (batch, length, embedding) shaped tensor:
from seqpool import CVTSeqPool
f = CVTSeqPool(128)
x = torch.randn(4, 1024, 128) # for example, take x from a transformer's output
y = f(x) # (4, 1024, 128) -> (4, 128)
Typical use-case is in the training of a smaller model using a pretrained model's embeddings, for example a BERT-style model.
Variants
Escaping the Big Data Paradigm with Compact Transformers arXiv
from seqpool import CVTSeqPool
f = CVTSeqPool(in_dim=128)
This paper proposes a number of improvements on Vision Transformers to improve performance on low-data tasks. One improvement was a "SeqPool" mechanism. A single linear layer produces a weighting for each sequence element, then softmax is applied. This is then used to compute the weighted sum of all embedding vectors. The intuition is that each sequence element does not contain the same amount of entropy, and so allowing the model to construct its own weighting on importance helps improve performance on the downstream task.
References
Escaping the Big Data Paradigm with Compact Transformers
Ali Hassani, Steven Walton, Nikhil Shah, Abulikemu Abuduweili, Jiachen Li, Humphrey Shi
@article{hassani2021escaping,
title={Escaping the big data paradigm with compact transformers},
author={Hassani, Ali and Walton, Steven and Shah, Nikhil and Abuduweili, Abulikemu and Li, Jiachen and Shi, Humphrey},
journal={arXiv preprint arXiv:2104.05704},
year={2021}
}
Release files for seqpool 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| seqpool-0.0.1.tar.gz | 3.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| seqpool-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.1 kB
Release files / seqpool-0.0.1.tar.gz
| Download URL | seqpool-0.0.1.tar.gz |
|---|---|
| Size | 3.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7811d4014c46a5b46cb8c28a11a8284d95e85b35dc0324d6e9099e9ee52aa9e
|
|
BLAKE2b-256 checksum How to use checksums |
7e74e25d90986c232ad1083dbcf54697d99015830e7cc3ee1e2caec2e28ce1a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5
|
Release files / seqpool-0.0.1-py3-none-any.whl
| Download URL | seqpool-0.0.1-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f650284d765fa324f657c314a819db0f35b35ac62ad51eaf85600974f506508d
|
|
BLAKE2b-256 checksum How to use checksums |
296d67111fd365cac60ff9f403a7dcda4e87c48a91ebe376892c0a1fd8532ead
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/3.10.5
|