No project description provided
Project description
clipscope
usage
import PIL
from clipscope import ConfiguredViT, TopKSAE
device='cpu'
filename_in_hf_repo = "22_resid/1200013184.pt"
sae = TopKSAE.from_pretrained(checkpoint=filename_in_hf_repo, device=device)
locations = [(22, 'resid')]
transformer = ConfiguredViT(locations, device=device)
input = PIL.Image.new("RGB", (224, 224), (0, 0, 0)) # black image for testing
activations = transformer.all_activations(input)[locations[0]] # (1, 257, 1024)
assert activations.shape == (1, 257, 1024)
activations = activations[:, 0] # just the cls token
# alternatively flatten the activations
# activations = activations.flatten(1)
print('activations shape', activations.shape)
output = sae.forward_verbose(activations)
print('output keys', output.keys())
print('latent shape', output['latent'].shape) # (1, 65536)
print('reconstruction shape', output['reconstruction'].shape) # (1, 1024)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
clipscope-0.1.6.tar.gz
(3.9 kB
view hashes)
Built Distribution
Close
Hashes for clipscope-0.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 799225b48d877c4b4dbec2df272c5d2b6ff67d946baae768ea29db1608effe53 |
|
MD5 | 1f83e3a20f05a6af72b7dae49901e500 |
|
BLAKE2b-256 | 08cb8c1932426d23a4afea02491431889e13c2e520e4685543fd9e8e0898be77 |