Skip to content

Repository files navigation

Exploring the Impact of a Transformer's Latent Space Geometry on Downstream Task Performance

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

Overview

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.

Repository Structure

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

Reproducing Results

  1. Build samples and compute metrics: python sample_build_and_metrics.py
  2. Run GLUE evaluation: python run_glue.py
  3. Parse results: python glue_parse.py

Experiments were run on a SLURM HPC cluster; adapt resource requests as needed for your environment.

Key Dependencies

transformers
torch
faiss
sklearn
numpy
pandas

Citation

@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}
}

About

Code for 'Exploring the Impact of a Transformer's Latent Space Geometry on Downstream Task Performance' (arXiv:2406.12159)

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages