Closed cristinkers closed 3 months ago
Hi there! I'm not very familiar with R Studio, but I believe it expects code written in R, not Python. You could use VSCode or Jupyter to run the notebook, or if you haven't run Python code before, it might be easiest to use our online Colab notebook, which doesn't require you to download or install anything: https://colab.research.google.com/drive/19akZ2Qu7uva8jOsc49e_2HJmDo88WAXm?usp=sharing
Hi. Thank you for your response! I am using the reticulate package which allows R to read python code. I tried running the code in python with the same error, so I don’t think that’s the concern. I would like to avoid using colab.
I'm not familiar with R Studio, so I can't provide advice about that. I recommend VSCode for running Python scripts and notebooks. But the problem seems to be that your code cannot locate the riveter
directory shown in your screenshot. Where is your code located? It should be in the same directory level as the demo.ipynb
notebook shown in your screenshot.
Got it. I moved my R code to the same directory with no change in error codes.
Moved over to VSCode and I am getting the same error code as I was getting in R:
python test_riverter.py
/opt/anaconda3/envs/riveterEnv/lib/python3.9/site-packages/spacy_transformers/layers/hf_shim.py:118: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
self._model.load_state_dict(torch.load(filelike, map_location=device))
/opt/anaconda3/envs/riveterEnv/lib/python3.9/site-packages/thinc/shims/pytorch.py:253: FutureWarning: You are using torch.load
with weights_only=False
(the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for weights_only
will be flipped to True
. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via torch.serialization.add_safe_globals
. We recommend you start setting weights_only=True
for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
model.load_state_dict(torch.load(filelike, map_location=device))
Traceback (most recent call last):
File "/Users/cristinazito/riveter-nlp/test_riverter.py", line 1, in
I'm not sure if this helps provide any more information on what issue is popping up. Let me know.
Ah sorry, the screenshot confused me. Can you move your code inside the riveter
directory? Everything should be structured exactly as it is here on Github, with the demo notebooks inside of that directory. (Did you manually move them outside? Or did that somehow happen during your installation process?)
Yep! That was the issue! It must have happened during the installation process. I deleted everything and then redownloaded it manually and it is running. Thank you for your help!
Ok great to hear that it's working now! Let me know if you have other questions.
I am trying to set up riveter in Rstudio and continue to receieve the following error code: riveter <- import("riveter") Error in py_module_import(module, convert = convert) : ImportError: cannot import name 'load_rashkin_lexicon' from 'riveter.riveter' (/opt/anaconda3/envs/riveterEnv/lib/python3.9/site-packages/riveter/riveter.py) Run
reticulate::py_last_error()
for details.Here is the set up of riveter folder I downloaded from the git.
And here is my code: RStudio.pdf
Originally posted by @cristinkers in https://github.com/maartensap/riveter-nlp/issues/3#issuecomment-2274481712