LLM-Microscope

LLM-Microscope

None

Stars: 60

Visit
 screenshot

This repository contains the official implementation of the code for the paper 'Your Transformer is Secretly Linear'. It provides functions for calculating anisotropy score, intrinsic dimension, linearity score, and centered linearity score based on pseudo-random features. Additionally, a pip package is available for easy installation. Users can also download the dataset used in the paper for further analysis.

README:

Your Transformer is Secretly Linear

This repository contains the official implementation of the code for the paper Your Transformer is Secretly Linear.

Linearity Profiles

We've also created a pip package containing the functions from notebook.

Use pip install llm-microscope to install it.

Example

import torch
from llm_microscope import  (
  calculate_anisotropy_torch,
  intrinsic_dimension,
  procrustes_similarity,
  procrustes_similarity_centered,
  load_enwiki_text
)

device = 'cpu'

X = torch.randn((1000, 10)) # pseudo-random "features", 1000 vectors with dim=10.
Y = torch.randn((1000, 10)) # pseudo-random "features", 1000 vectors with dim=10.

anisotropy = calculate_anisotropy_torch(X) # anisotropy score
int_dim = intrinsic_dimension(X, device) # intrinsic dimension
linearity_score = procrustes_similarity(X, Y) # linearity score from the paper
centered_linearity_score = procrustes_similarity_centered(X, Y) # the same as linearity between X and Y - X


# You can also download the dataset that we used in the paper using load_enwiki_text function:
text = llm_microscope.load_enwiki_text()

For Tasks:

Click tags to check more tools for each tasks

For Jobs:

Alternative AI tools for LLM-Microscope

Similar Open Source Tools

For similar tasks

For similar jobs