rome icon indicating copy to clipboard operation
rome copied to clipboard

TypeError when running causal_trace.ipynb locally

Open Xiaoxi-Luo-CL opened this issue 1 year ago • 0 comments

Hello, thank you for your code. When I was running the notebook causal_trace.ipynb locally, I met the following error in the fourth cell (the cell for imports).

Cell In[4], line 7
      5 sys.path.append(os.path.abspath("D://postgraduate//research//model_editing//rome"))
      6 from util import nethook
----> 7 from util.globals import DATA_DIR
      8 from experiments.causal_trace import (
      9     ModelAndTokenizer,
     10     layername,
     11     guess_subject,
     12     plot_trace_heatmap,
     13 )
     14 from experiments.causal_trace import (
     15     make_inputs,
     16     decode_tokens,
   (...)
     20     collect_embedding_std,
     21 )

File D:\postgraduate\research\model_editing\rome\util\globals.py:12
      5 with open("globals.yml", "r") as stream:
      6     data = yaml.safe_load(stream)
      9 (RESULTS_DIR, DATA_DIR, STATS_DIR, HPARAMS_DIR,) = (
     10     Path(z)
     11     for z in [
---> 12         data["RESULTS_DIR"],
     13         data["DATA_DIR"],
     14         data["STATS_DIR"],
     15         data["HPARAMS_DIR"],
     16     ]
     17 )
     19 REMOTE_ROOT_URL = data["REMOTE_ROOT_URL"]

TypeError: string indices must be integers

It seems that globals.yml is not read successfully. However, I notice that variables like RESULTS_DIR, DATA_DIR, and STATS_DIR are constant strings, can I just change them into the values in globals.yml?

Xiaoxi-Luo-CL avatar Oct 08 '24 12:10 Xiaoxi-Luo-CL