TransformerLensOrg / TransformerLens

A library for mechanistic interpretability of GPT-style language models
https://transformerlensorg.github.io/TransformerLens/
MIT License
1.17k stars 241 forks source link

Add skip_verbose_naming in add_hook to give an option for skipping the naming #635

Open verlocks opened 3 weeks ago

verlocks commented 3 weeks ago

Description

Like the proposal mentioned in issue, running full_hook._name_ = (hook._repr_()) in add_hook may cause large overhead in some situation. This PR add a new parameter skip_verbose_naming that allows user to skip this line.

Fixes #631

Type of change

Please delete options that are not relevant.

Screenshots

The overhead caused by naming being removed by adding skip_verbose_naming=True in with model.hooks(fwd_hooks=fwd_hooks, skip_verbose_naming=True):.

Before
image
After
image

Checklist:

There is some problem with the current unit test here: image After my changes, the parameter would be different for add_hook. Should I do anything about it?