facebookresearch / EmpatheticDialogues

Dialogue model that produces empathetic responses when trained on the EmpatheticDialogues dataset.
Other
450 stars 63 forks source link

RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation. #46

Closed nizish closed 2 years ago

nizish commented 3 years ago

In google colab this command raises exception.

!python retrieval_train.py --batch-size 32 --bert-dim 300 --cuda --dataset-name empchat --dict-max-words 250000 --display-iter 100 --embeddings None --empchat-folder ./empatheticdialogues/ --max-hist-len 4 --model bert --model-dir ./test1 --model-name model --optimizer adamax --pretrained bert_finetuned_emoprepend1.mdl --reactonly

Traceback (most recent call last):
  File "retrieval_train.py", line 297, in <module>
    main(opt)
  File "retrieval_train.py", line 254, in main
    net, dictionary = load_model(opt_.pretrained, opt_)
  File "/content/EmpatheticDialogues/empchat/models.py", line 74, in load
    net = create(saved_opt, word_dict["words"])
  File "/content/EmpatheticDialogues/empchat/models.py", line 81, in create
    return BertAdapter(opt, dict_words)
  File "/content/EmpatheticDialogues/empchat/bert_local.py", line 61, in __init__
    embeddings.weight[token_idx] = rand_embedding
RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation.

Found fix at https://stackoverflow.com/questions/49161652/how-to-get-around-in-place-operation-error-if-index-leaf-variable-for-gradient-u

Notebook is here gist

EricMichaelSmith commented 3 years ago

hmm which version of PyTorch are you using? I wonder if this is version-dependent - the README states that the code uses PyTorch 1.0.1.post2

nizish commented 3 years ago

torch 1.10.0+cu111

EricMichaelSmith commented 2 years ago

Hmm, yeah, I'm guessing it's a version-dependent thing. If you're able to get this code to run on modern PyTorch, I'd welcome a PR :)

ramish987 commented 2 years ago

hello, I have issue in loading these model files in parlai.When i have to load these models to parlai it shows errors to read mdl file docreadertagent is used in some codes but this is used in old versions Please can you help me with it

ramish987 commented 2 years ago

I run the code given belowthe models with retrival file in the end it save .txt model file how can we load it to parlai chatbot

EricMichaelSmith commented 2 years ago

Hi @ramish987 ! Unfortunately these model files cannot be loaded natively in ParlAI without mapping the weights into a ParlAI-friendly format, since it was not trained in ParlAI.

ramish987 commented 2 years ago

So what I have to do for that I have tried to load the code you have given below in the link but it save txt file .So what I should do? what you suggest?

On Fri, Dec 10, 2021, 1:52 AM Eric Smith @.***> wrote:

Hi @ramish987 https://github.com/ramish987 ! Unfortunately these model files cannot be loaded natively in ParlAI without mapping the weights into a ParlAI-friendly format, since it was not trained in ParlAI.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebookresearch/EmpatheticDialogues/issues/46#issuecomment-990241981, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLGYKJHFHIIVIRZN2IHHA3UQEJJBANCNFSM5HYN6FJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

EricMichaelSmith commented 2 years ago

@ramish987 Is your goal to load the retrieval model in ParlAI? If so, I'd take a look at parlai/core/torch_ranker_agent.py to see how weights there map onto the ones in the model in this repo in order to get this model to work in ParlAI.

ramish987 commented 2 years ago

thanks

On Tue, Dec 14, 2021, 1:33 AM Eric Smith @.***> wrote:

@ramish987 https://github.com/ramish987 Is your goal to load the retrieval model in ParlAI? If so, I'd take a look at parlai/core/torch_ranker_agent.py to see how weights there map onto the ones in the model in this repo in order to get this model to work in ParlAI.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/facebookresearch/EmpatheticDialogues/issues/46#issuecomment-992871132, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVLGYKIOSBMPRO6ZJC4KNE3UQZKBXANCNFSM5HYN6FJQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.