Skip to main content

No project description provided

Project description

EasyRoutine

This is just a simple collection of routines that I use frequently. I have found that I often need to do the same things over and over again, so I have created this repository to store them. I hope you find them useful.

Installation

Interpretability

The interpretability module contains wrapper of huggingface LLM/VLM that help to perform interpretability tasks on the model. Currently, it supports:

  • Extract activations of any component of the model
  • Perform ablation study on the model during inference
  • Perform activation patching on the model during inference

Simple Tutorial

# First we need to import the HookedModel and the config classes
from easyroutine.interpretability import HookedModel,  ExtractionConfig

hooked_model = HookedModel.from_pretrained(
    model_name="mistral-community/pixtral-12b", # the model name
    device_map = "auto"
)

# Now let's define a simple dataset
dataset = [
    "This is a test",
    "This is another test"
]

tokenizer = hooked_model.get_tokenizer()

dataset = tokenizer(dataset, padding=True, truncation=True, return_tensors="pt") 

cache = hooked_model.extract_cache(
    dataset,
    target_token_positions = ["last"],
    extraction_config = ExtractionConfig(
        extract_resid_out = True
    )
)

Development

For publish the package push a commit with the flag:

  • [patch]: x.x.7 -> x.x.8
  • [minor]: x.7.x -> x.8.0
  • [major]: 2.x.x -> 3.0.0

Example commit: fix multiple bus [patch]

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

easyroutine-1.1.1.tar.gz (73.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

easyroutine-1.1.1-py3-none-any.whl (89.7 kB view details)

Uploaded Python 3

File details

Details for the file easyroutine-1.1.1.tar.gz.

File metadata

  • Download URL: easyroutine-1.1.1.tar.gz
  • Upload date:
  • Size: 73.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for easyroutine-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8e6ca3c7d95fb34a2e4330f02ac38ad69e58936764187edc4da06de426972d0b
MD5 f954f0413f60e35170037f560b65c7a2
BLAKE2b-256 a95e07c384b85307407c4a14f419f5915e59c89410664aac2c35918ba0a3ddf1

See more details on using hashes here.

File details

Details for the file easyroutine-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: easyroutine-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 89.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for easyroutine-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 67861db22d8c2df97d59be666e5e496dce2349aa9de0780b20fff0032026892e
MD5 c772fe2bb2251c5b6b721cdc68073cfe
BLAKE2b-256 05eedaee0bdb4937a86c85c5087e6b49c00e0da1577c78ce1ce2c1ff45c3b723

See more details on using hashes here.

Supported by

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