Code for the paper:
Exploring the Impact of a Transformer's Latent Space Geometry on Downstream Task Performance
Anna C. Marbut, J. Chandler, Travis J. Wheeler
arXiv preprint arXiv:2406.12159
arXiv
How does the spatial structure of a transformer's contextual representations relate to what it can do on downstream tasks? We apply a suite of geometric measures to the latent spaces of synthetically perturbed BERT-family models and find that quantized point patchiness, a cell density measure borrowed from ecology, predicts GLUE benchmark performance with r = 0.9.
sample_build_and_metrics.py Build representation samples and compute geometric metrics
model_perturb.py Perturb model representations for controlled experiments
run_glue.py Run GLUE fine-tuning and evaluation
glue_parse.py Parse and aggregate GLUE evaluation outputs
sample_sequences.pkl Pre-built sample token sequences
- Build samples and compute metrics:
python sample_build_and_metrics.py - Run GLUE evaluation:
python run_glue.py - Parse results:
python glue_parse.py
Experiments were run on a SLURM HPC cluster; adapt resource requests as needed for your environment.
transformers
torch
faiss
sklearn
numpy
pandas
@article{marbut2024exploring,
title = {Exploring the Impact of a Transformer's Latent Space Geometry on Downstream Task Performance},
author = {Marbut, Anna C. and Chandler, J. and Wheeler, Travis J.},
journal = {arXiv preprint arXiv:2406.12159},
year = {2024}
}