tea-shaped / self-disclosure-model

This repo contains a general self-disclosure model to determine self-disclosure in text across datasets.
GNU General Public License v3.0
4 stars 1 forks source link

Multitask RoBERTa model not loading #4

Open saurabh-khanna opened 2 years ago

saurabh-khanna commented 2 years ago

I am facing an issue with implementing the self-disclosure model to output self-disclosure scores for free text responses. Steps followed:

  1. Cloned the github repository to local machine. Pytorch and related dependencies are pre-installed on local machine.
  2. Loading the RoBERTa model (the first step in the instructions here and using the same directory structure as the parent repo) throws this error: ModuleNotFoundError: No module named 'models'
  3. Tried adding model and repo folder paths as explicit system variables using sys.path (which contains a list of directories that the interpreter will search in for the required module) as suggested here. Also tried altering the workflow to use load_state_dict() as per the torch documentation. These do not fix the issue.

Code:

m = torch.load("/Users/saurabh/Everything/GitHub/self-disclosure-model/multi-task/roberta/self-disclosure_multitask_RoBERTa_bestperforming.p")

Error traceback:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
/var/folders/2z/vs42hj694vjcjn3tkdl2tnfw0000gn/T/ipykernel_13073/3978350970.py in <module>
----> 1 m = torch.load("/Users/saurabh/Everything/GitHub/self-disclosure-model/multi-task/roberta/self-disclosure_multitask_RoBERTa_bestperforming.p")

/usr/local/lib/python3.9/site-packages/torch/serialization.py in load(f, map_location, pickle_module, **pickle_load_args)
    710                     opened_file.seek(orig_position)
    711                     return torch.jit.load(opened_file)
--> 712                 return _load(opened_zipfile, map_location, pickle_module, **pickle_load_args)
    713         return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
    714 

/usr/local/lib/python3.9/site-packages/torch/serialization.py in _load(zip_file, map_location, pickle_module, pickle_file, **pickle_load_args)
   1044     unpickler = UnpicklerWrapper(data_file, **pickle_load_args)
   1045     unpickler.persistent_load = persistent_load
-> 1046     result = unpickler.load()
   1047 
   1048     torch._utils._validate_loaded_sparse_tensors()

/usr/local/lib/python3.9/site-packages/torch/serialization.py in find_class(self, mod_name, name)
   1037                     pass
   1038             mod_name = load_module_mapping.get(mod_name, mod_name)
-> 1039             return super().find_class(mod_name, name)
   1040 
   1041     # Load the data (which may in turn use `persistent_load` to load tensors)

ModuleNotFoundError: No module named 'models'
minjechoi commented 1 year ago

Experiencing the same issue here