microsoft / CodeXGLUE

CodeXGLUE
MIT License
1.51k stars 363 forks source link

TypeError: tuple indices must be integers or slices, not tuple - downgrading transformers doesn't work #126

Open JaeWorld opened 2 years ago

JaeWorld commented 2 years ago

Hi. I'm trying to train a CodeGPT model for the Text-Code task. The error message I encountered is as follows.

Traceback (most recent call last) :
  File "run.py", line 613, in <module>
    main()
  File "run.py", line 586, in main
    train(args, train_dataset, model, tokenizer)
  File "run.py" line 217, in train
    loss,code_vec,nl_vec = model(code_inputs,nl_inputs)
  File "/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py", line 1130, in_call_impl
    return forward_call(*input, **kwargs)
  File "/content/drive/MyDrive/CodeXGLUE-main/Text-Code/NL-code-search-Adv/code/model.py", line 33, in forward
    scores=(nl_vec[:,None,:]*code_vec[None,:,:]).sum(-1)
TypeError: tuple indices must be integers or slices, not tuple

I already checked the issue #60, which was told to downgrade the transformers library to 3.3.0 version. However it still doesn't work even after I downgraded it.

My version numbers are as follows. python=3.7.13 torch=1.12.0+cu113 transformers=3.3.0

Many thanks.