Skip to main content

No project description provided

Project description

clipscope

Github Repo

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.7.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

clipscope-0.1.7-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file clipscope-0.1.7.tar.gz.

File metadata

  • Download URL: clipscope-0.1.7.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for clipscope-0.1.7.tar.gz
Algorithm Hash digest
SHA256 06304791b53660bdb0229d09bbd15fab40b25591f795d26141171d2b2fdc65ad
MD5 117bafe3e56fdaecec40aa854611b597
BLAKE2b-256 71ff2d08bc81c39bf9b8a09311f9330062e3ad0fb967a042f52b39bba3ee7809

See more details on using hashes here.

File details

Details for the file clipscope-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: clipscope-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.8

File hashes

Hashes for clipscope-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 14d48ff25bf1b6f031ee6c3c8e32fb2c0fc3a59119911df975db7e89bedbc20b
MD5 c00d05c874466527d4a3210daa9a7ae2
BLAKE2b-256 abc585a26af9111d7e45af162f1be6b0c1b1fea8d623864aa6061acd9368057a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page