I am trying to run the AllenNLP demo https://demo.allennlp.org/semantic-role-labeling. When I run the command line or the Python version via Juptyer I get the error mentioned below.
I have installed the required libraries?
pip install allennlp==1.0.0 allennlp-models==1.0.0
Running this gives me an error:
from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.11.19.tar.gz")
predictor.predict(
sentence="Did Uriah honestly think he could beat the game in under three hours?"
)
Update: If I use an older gz download I do not get the error
I grabbed this one from their public models site bert-base-srl-2020.09.03.tar.gz
from allennlp.predictors.predictor import Predictor
predictor = Predictor.from_path("https://storage.googleapis.com/allennlp-public-models/bert-base-srl-2020.09.03.tar.gz")
text = "Did Uriah honestly think he could beat the game in under three hours?"
predictor.predict(sentence=text)
Error:
RuntimeError: Error(s) in loading state_dict for SrlBert:
Unexpected key(s) in state_dict: "bert_model.embeddings.position_ids".
OS & versions:
Python: 3.8.6
pip: 20.2.1
Mac OS: Catalina 10.15.7
Are there some dependencies I am maybe missing for BERT? I haven't had any issues with the other AllenNLP examples.
I added an answer but they deleted it. This is how you resolve this:
After posting on github, found out from the AllenNLP folks that it is a version issue. I needed to be using allennlp=1.3.0 and the latest model. Now it works as expected.
This should be fixed in the latest allennlp 1.3 release. Also, the latest archive file is structured-prediction-srl-bert.2020.12.15.tar.gz.
https://github.com/allenai/allennlp/issues/4876
Related
I am trying to train my model using Tokenizer,Keras and TensorFlow.
Code where I'm getting the error.
from transformers import TFXLNetModel, XLNetTokenizer
xlnet_model = 'xlnet-large-cased'
xlnet_tokenizer = XLNetTokenizer.from_pretrained(xlnet_model)
Error:
If you run the code you will first get this error:
ImportError:
XLNetTokenizer requires the SentencePiece library but it was not found in your environment. Checkout the instructions on the
installation page of its repo: https://github.com/google/sentencepiece#installation and follow the ones
that match your environment
After running !pip install sentencepiece and restarting the cell the TypeError happens.
To fix this you need to restart your runtime. Click "Runtime -> Restart Runtime", then run your cells again.
I found this solution on the transformers repo in this issue report.
Looking to convert "FastSeg-large" public model from the OpenModelZoo to use with the "image segmentation" demo. I was able to use the download.py utility to get the original model files downloaded. Now i'm running the following command:
python3 converter.py --name fastseg-large
I'm getting the following error:
Module fastseg_large in C:\Users\david\Desktop\Neural Zoo\open_model_zoo\models\public\fastseg-large;C:\Users\david\Desktop\Neural Zoo\open_model_zoo\tools\downloader\public\fastseg-large/model doesn't exist. Check import path and name
cannot import name 'container_abcs' from 'torch._six' (C:\Users\david\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\torch\_six.py)
Looks like i'm getting 2 different errors with the first having trouble finding the path to the original torch model files. I confirmed my path down to the "/model" directory exists. In that directory is another subdirectory "fastseg\model" where the torch model files exist.
The second error i'm not sure about - i double checked that i installed Torch from pip.
Any suggestions?
I’ve validated that running converter.py for FastSeg-large public model is working fine in OpenVINO™ 2021.4.752.
Make sure you run the install_prerequisites_onnx.bat batch file to configure the Model Optimizer for ONNX:
cd “C:\Program Files (x86)\Intel\openvino_2021.4.752\deployment_tools\model_optimizer\install_prerequisites”
then
install_prerequisites_onnx.bat
Doing some more web searches i see the error can be due to a newer version of Torch. So i uninstalled Torch and reinstalled version 1.8. That actually failed and i went back to the "pip install torch" without specifying the version. Then i saw torchvision was also mentioned so i "pip install torchvision".
Somewhere along the way i must have cleaned up something related to my torch libraries. Either way that got this to work.
I am trying to use LDA MAllet model. but I am facing with "No module named 'gensim.models.wrappers'" error.
I have gensim installed and ' gensim.models.LdaMulticore' works properly.
Java developer’s kit is installed
I have already downloaded mallet-2.0.8.zip and unzipped it on c:\ drive.
This is the code I am trying to use:
import os
from gensim.models.wrappers import LdaMallet
os.environ.update({'MALLET_HOME':r'C:/mallet-2.0.8/'})
mallet_path = r'C:/mallet-2.0.8/bin/mallet'
Does anyone know what is wrong here? Many thanks!
If you've installed the latest Gensim, 4.0.0 (as of late March, 2021), the LdaMallet model has been removed, along with a number of other tools which simply wrapped external tools/APIs.
You can see the note in the Gensim migration guide at:
https://github.com/RaRe-Technologies/gensim/wiki/Migrating-from-Gensim-3.x-to-4#15-removed-third-party-wrappers
If the use of that tool is essential to your project, you may be able to:
install an older version of Gensim, such as 3.8.3 - though of course you'd then be missing the latest fixes & optimizations on any other Gensim models you're using
extract the ldamallet.py source code from that older version & update/move it to your own code for private use - dealing with whatever issues arise
I had the same issue with Gensim's wrapper for MALLET but didn't want to downgrade. There is this new wrapper that seems to do the job pretty well.
https://github.com/maria-antoniak/little-mallet-wrapper/blob/master/demo.ipynb
I have trained xgboost model with GPU('gpu_tree'). Then saved my model using pickle. Now, I'm trying to load that model in Non-GPU machine, but it throwing this error.
raise XGBoostError(py_str(_LIB.XGBGetLastError()))
xgboost.core.XGBoostError: [16:36:57] /tmp/pip-install-
mqijktew/xgboost/build/temp.linux-x86_64-3.6/xgboost/src/tree/
tree_updater.cc:20:
Unknown tree updater grow_gpu_hist
Any help would be appreciated.
I encounter the same error the other day, and the problem was that I installed xgboost using conda, and that package does not include GPU components (Have a look at the xgboost.dll, it's only a few MBs).
I then installed xgboost using pip (pip install xgboost), check the size of xgboost.dll, it's now 300+ MB, and this error "Unknown tree updater grow_gpu_hist" disappeared. (xgboost version is 1.5.1)
Not sure whether this would be helpful as I notice the path in your description contains "pip-install"...
I am installing Theano and Keras follwing the How do I install Keras and Theano in Anaconda Python on Windows?, which worked fine for me with an older release before. Now I have upgraded to the latest Theano version and when validating its functionality using this command:
Python:
from theano import function, config, shared, sandbox
it resulted in really long error log containing:
g++.exe: error: C:\Users\John: No such file or directory
g++.exe: error: Dow\AppData\Local\Theano\compiledir_Windows-10-10.0.10240-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-2.7.12-64\lazylinker_ext\mod.cpp: No such file or directory
It seems the path to user directory "John Dow" was splitted by g++ to two file paths, since there is space in the name.
Is there any way how to tell python to not to use the "C:\Users\John Dow" directory but e.g. "C:\mytempdir". Setting the USERPROFILE windows variable didn't help.
NOTE: I managed to fix the g++ command, where it failed (by adding quotes to the output), which successfully compiled the sources. Unfortunately it didnt solve my problem, since when started again, it fails on this step.
It seems also to be an issue of Theano, since swithcing to different Python version didnt help.
Answer is from here:
Theano: change `base_compiledir` to save compiled files in another directory
i.e. in ~/.theanorc file (or create it) add this line :
[global]
base_compiledir=/some/path