stanfordnlp / pyvene

Stanford NLP Python Library for Understanding and Improving PyTorch Models via Interventions
http://pyvene.ai
Apache License 2.0
608 stars 59 forks source link

[Major] Update with string access and code refactory (#83) #93

Closed frankaging closed 8 months ago

frankaging commented 8 months ago

Descriptions: We add in string access of model component in the config for quick intervention without config. We now allow intervention instance to be initialized outside the config. We remove some dependency between a couple of util files and the config mapping.

Testing Done:

WARNING:root:The key is provided in the config. Assuming this is loaded from a pretrained module.
WARNING:root:Loading trainable intervention from intkey_layer.0.repr.block_output.unit.pos.nunit.1#0.bin.
WARNING:root:Loading trainable intervention from intkey_layer.1.repr.block_output.unit.pos.nunit.1#0.bin.
.Directory './test_output_dir_prefix-c8e990' created successfully.
.Directory './test_output_dir_prefix-890a9d' created successfully.
WARNING:root:Saving trainable intervention to intkey_layer.0.repr.block_output.unit.pos.nunit.1#0.bin.
WARNING:root:Saving trainable intervention to intkey_layer.1.repr.block_output.unit.pos.nunit.1#0.bin.
.Removing testing dir ./test_output_dir_prefix-25c2db
Removing testing dir ./test_output_dir_prefix-e57317
Removing testing dir ./test_output_dir_prefix-a8f096
Removing testing dir ./test_output_dir_prefix-c8e990
Removing testing dir ./test_output_dir_prefix-890a9d
......
----------------------------------------------------------------------
Ran 42 tests in 43.378s

OK