Transformers: cannot import name 'RobertaForTokenClassification'

Created on 25 Oct 2019  路  5Comments  路  Source: huggingface/transformers

馃悰 Bug

Model I am using (Bert, XLNet....): BERT

Language I am using the model on (English, Chinese....): English

The problem arise when using:

  • [x] the official example scripts: (give details) examples/run_ner.py
  • [ ] my own modified scripts: (give details)

The tasks I am working on is:

  • [x] an official GLUE/SQUaD task: (give the name) NER on CoNLL2003 ENG
  • [ ] my own task or dataset: (give details)

To Reproduce

Steps to reproduce the behavior:

  1. $ pip install transformers
  2. $ python
  3. > from transformers import RobertaConfig, RobertaForTokenClassification, RobertaTokenizer
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: cannot import name 'RobertaForTokenClassification'

Expected behavior

Environment

  • OS: Ubuntu 18.04.3
  • Python version: 3.6
  • PyTorch version: 1.2.0
  • PyTorch Transformers version (or branch): pip install transformers
  • Using GPU ? Yes, CUDA 10
  • Distributed of parallel setup ? No
  • Any other relevant information:

Additional context

wontfix

Most helpful comment

  • update

    • using pip3 install git+https://github.com/huggingface/transformers.git --upgrade command, the first bug got away.

All 5 comments

  • other bug

    • with '--evaluate_during_training'

File "/path-to/run_ner.py", line 167, in train
    results, _ = evaluate(args, model, tokenizer, labels, pad_token_label_id)
TypeError: evaluate() missing 1 required positional argument: 'mode'
  • update

    • using pip3 install git+https://github.com/huggingface/transformers.git --upgrade command, the first bug got away.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I am also facing the same issue, but even installing from git (as stated by dsindex) did not help.

It could be because torch is not installed. transformers doesn't install torch automatically but needs the same to load the models. try pip install torch and import again!

Was this page helpful?
0 / 5 - 0 ratings