Skip to content

RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding) #1

Description

@lukemao

Thanks for developing sent2vec

I just installed it.

I was trying to run the example and the getting the errors:

vectors = vectorizer.sent2vec_bert()
HBox(children=(FloatProgress(value=0.0, description='Downloading', max=231508.0, style=ProgressStyle(descripti…

HBox(children=(FloatProgress(value=0.0, description='Downloading', max=442.0, style=ProgressStyle(description_…

HBox(children=(FloatProgress(value=0.0, description='Downloading', max=267967963.0, style=ProgressStyle(descri…

Traceback (most recent call last):

  File "<ipython-input-7-d7f140e4a0b3>", line 1, in <module>
    vectors = vectorizer.sent2vec_bert()

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\sent2vec\vectorizer.py", line 34, in sent2vec_bert
    last_hidden_states = model(input_ids)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\transformers\modeling_distilbert.py", line 463, in forward
    inputs_embeds = self.embeddings(input_ids)  # (bs, seq_length, dim)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\transformers\modeling_distilbert.py", line 93, in forward
    word_embeddings = self.word_embeddings(input_ids)  # (bs, max_seq_length, dim)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\torch\nn\modules\module.py", line 532, in __call__
    result = self.forward(*input, **kwargs)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\torch\nn\modules\sparse.py", line 114, in forward
    self.norm_type, self.scale_grad_by_freq, self.sparse)

  File "C:\Users\User\anaconda3\envs\py376\lib\site-packages\torch\nn\functional.py", line 1484, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)

RuntimeError: Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.IntTensor instead (while checking arguments for embedding)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions