Skip to content

Commit

Permalink
Merge pull request #48 from stanfordnlp/zen/cachepath
Browse files Browse the repository at this point in the history
Remove default cache directory
  • Loading branch information
frankaging authored Jan 13, 2024
2 parents 306ff0d + 76fd589 commit 7a58255
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion pyvene/models/blip/modelings_intervenable_blip.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
blip_wrapper_type_to_dimension_mapping = blip_type_to_dimension_mapping


def create_blip(name="Salesforce/blip-vqa-base", cache_dir="../../.huggingface_cache"):
def create_blip(name="Salesforce/blip-vqa-base", cache_dir=None):
"""Creates a GPT2 model, config, and tokenizer from the given name and revision"""
from transformers import BlipConfig, BlipProcessor, BlipForQuestionAnswering

Expand Down
4 changes: 2 additions & 2 deletions pyvene/models/gpt2/modelings_intervenable_gpt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
gpt2_lm_type_to_dimension_mapping = gpt2_type_to_dimension_mapping


def create_gpt2(name="gpt2", cache_dir="../../.huggingface_cache"):
def create_gpt2(name="gpt2", cache_dir=None):
"""Creates a GPT2 model, config, and tokenizer from the given name and revision"""
from transformers import GPT2Model, GPT2Tokenizer, GPT2Config

Expand All @@ -74,7 +74,7 @@ def create_gpt2(name="gpt2", cache_dir="../../.huggingface_cache"):
return config, tokenizer, gpt


def create_gpt2_lm(name="gpt2", config=None, cache_dir="../../.huggingface_cache"):
def create_gpt2_lm(name="gpt2", config=None, cache_dir=None):
"""Creates a GPT2 LM, config, and tokenizer from the given name and revision"""
from transformers import GPT2LMHeadModel, GPT2Tokenizer, GPT2Config

Expand Down
2 changes: 1 addition & 1 deletion pyvene/models/gpt_neo/modelings_intervenable_gpt_neo.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@


def create_gpt_neo(
name="roneneldan/TinyStories-33M", cache_dir="../../.huggingface_cache"
name="roneneldan/TinyStories-33M", cache_dir=None
):
"""Creates a GPT2 model, config, and tokenizer from the given name and revision"""
from transformers import GPTNeoForCausalLM, GPT2Tokenizer, GPTNeoConfig
Expand Down
2 changes: 1 addition & 1 deletion pyvene/models/gpt_neox/modelings_intervenable_gpt_neox.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
gpt_neox_lm_type_to_dimension_mapping = gpt_neox_type_to_dimension_mapping


def create_gpt_neox(name="EleutherAI/pythia-70m", cache_dir="../../.huggingface_cache"):
def create_gpt_neox(name="EleutherAI/pythia-70m", cache_dir=None):
"""Creates a GPT2 model, config, and tokenizer from the given name and revision"""
from transformers import GPTNeoXForCausalLM, AutoTokenizer, GPTNeoXConfig

Expand Down
6 changes: 3 additions & 3 deletions pyvene/models/gru/modelings_intervenable_gru.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
gru_lm_type_to_dimension_mapping = gru_type_to_dimension_mapping


def create_gru(config, tokenizer_name=None, cache_dir="../../.huggingface_cache"):
def create_gru(config, tokenizer_name=None, cache_dir=None):
"""Creates a GRU model, config, and tokenizer from the given name and revision"""
from transformers import AutoTokenizer
from models.gru.modelings_gru import GRUModel
Expand All @@ -82,7 +82,7 @@ def create_gru(config, tokenizer_name=None, cache_dir="../../.huggingface_cache"
return config, tokenizer, mlp


def create_gru_lm(config, tokenizer_name=None, cache_dir="../../.huggingface_cache"):
def create_gru_lm(config, tokenizer_name=None, cache_dir=None):
"""Creates a GRU model, config, and tokenizer from the given name and revision"""
from transformers import AutoTokenizer
from models.gru.modelings_gru import GRULMHeadModel
Expand All @@ -96,7 +96,7 @@ def create_gru_lm(config, tokenizer_name=None, cache_dir="../../.huggingface_cac


def create_gru_classifier(
config, tokenizer_name=None, cache_dir="../../.huggingface_cache"
config, tokenizer_name=None, cache_dir=None
):
"""Creates a GRU model, config, and tokenizer from the given name and revision"""
from transformers import AutoTokenizer
Expand Down
2 changes: 1 addition & 1 deletion pyvene/models/llama/modelings_intervenable_llama.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def split_heads(tensor, num_heads, attn_head_size):


def create_llama(
name="sharpbai/alpaca-7b-merged", cache_dir="../../.huggingface_cache"
name="sharpbai/alpaca-7b-merged", cache_dir=None
):
"""Creates a LLaMA Causal LM model, config, and tokenizer from the given name and revision"""
from transformers import LlamaForCausalLM, LlamaTokenizer, LlamaConfig
Expand Down
2 changes: 1 addition & 1 deletion pyvene/models/mlp/modelings_intervenable_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


def create_mlp_classifier(
config, tokenizer_name=None, cache_dir="../../.huggingface_cache"
config, tokenizer_name=None, cache_dir=None
):
"""Creates a MLP model, config, and tokenizer from the given name and revision"""
from transformers import AutoTokenizer
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="pyvene",
version="0.0.5",
version="0.0.6",
description="Use Activation Intervention to Interpret Causal Mechanism of Model",
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down
38 changes: 19 additions & 19 deletions tutorials/advanced_tutorials/IOI_with_DAS.ipynb

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
}
],
"source": [
"config, tokenizer, tinystory = create_gpt_neo(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, tinystory = create_gpt_neo()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions tutorials/basic_tutorials/Add_Activations_to_Streams.ipynb

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions tutorials/basic_tutorials/Add_New_Model_Type.ipynb

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions tutorials/basic_tutorials/Basic_Intervention.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tutorials/basic_tutorials/Complex_Intervention.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
" scale_y_log10,\n",
")\n",
"\n",
"config, tokenizer, gpt = create_gpt2(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, gpt = create_gpt2()"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions tutorials/basic_tutorials/Debug_Helper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "1b5fd935",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -71,7 +71,7 @@
"from pyvene.models.configuration_intervenable_model import (\n",
" IntervenableConfig, IntervenableRepresentationConfig, VanillaIntervention)\n",
"\n",
"config, tokenizer, gpt = create_gpt2(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, gpt = create_gpt2()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
" IntervenableConfig, IntervenableRepresentationConfig, VanillaIntervention\n",
")\n",
"\n",
"config, tokenizer, gpt = create_gpt2(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, gpt = create_gpt2()"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
" scale_y_log10,\n",
")\n",
"\n",
"config, tokenizer, gpt = create_gpt2(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, gpt = create_gpt2()"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions tutorials/basic_tutorials/Nested_Intervention.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tutorials/basic_tutorials/Probing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
" CollectIntervention,\n",
")\n",
"\n",
"config, tokenizer, gpt = create_gpt2(cache_dir=\"../../../.huggingface_cache\")"
"config, tokenizer, gpt = create_gpt2()"
]
},
{
Expand Down

Large diffs are not rendered by default.

0 comments on commit 7a58255

Please sign in to comment.