question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError ' '- run_ner.py - Transformers 2.8.0

See original GitHub issue

🐛 Bug

Information

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

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

The problem arises when using:

  • [ X ] the official example scripts: (give details below)
  • my own modified scripts: (give details below)

The tasks I am working on is:

  • an official GLUE/SQUaD task: (give the name)
  • [ X ] my own task or dataset: (give details below)

To reproduce

Steps to reproduce the behavior:

I’m having trouble running a dataset in Portuguese. It is in the conll pattern

Traceback (most recent call last): File “/home/lucasrodrigues/code/transformers-2.8.0/examples/ner/run_ner.py”, line 292, in <module> main() File “/home/lucasrodrigues/code/transformers-2.8.0/examples/ner/run_ner.py”, line 170, in main if training_args.do_train File “/home/lucasrodrigues/code/transformers-2.8.0/examples/ner/utils_ner.py”, line 124, in init pad_token_label_id=self.pad_token_label_id, File “/home/lucasrodrigues/code/transformers-2.8.0/examples/ner/utils_ner.py”, line 207, in convert_examples_to_features print([label_map[label]] + [pad_token_label_id] * (len(word_tokens) - 1)) KeyError: ‘’

Expected behavior

Execution of the NER.

Environment info

  • transformers version: 2.8.0
  • Platform: Linux-4.15.0-76-generic-x86_64-with-debian-buster-sid
  • Python version: 3.6.10
  • PyTorch version (GPU?): 1.3.1 (True)
  • Tensorflow version (GPU?): 2.0.0 (True)
  • Using GPU in script?: <fill in>
  • Using distributed or parallel set-up in script?: <fill in>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
stefan-itcommented, Apr 29, 2020

Additionally, the dataset format must be in a Token Label (delimiter is a space) format.

The error message shows, that an unexpected label ( ") was found, so I could imagine, that the dataset format is not consistent.

To check this, just do the following on your training, development and test set:

cat train.txt dev.txt test.txt | grep -v "^$" | cut -d " " -f 2 | sort | uniq

This should give you all labels. If you see other tokens, then there’s something wrong in the dataset.

0reactions
stale[bot]commented, Jul 22, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python 3.x - Transformers Pipeline from Huggingface
I am trying out the transformers pipeline from huggingface ... __version__ '2.8.0' I am running on Python 3.7.6 >>> from transformers import ...
Read more >
Why am I getting KeyError: 'loss'? - Hugging Face Forums
Why when I run trainer.train() it gives me Keyerror:'loss' previously i use something like start_text and stop_text and I read in previous ...
Read more >
Rasa Open Source Change Log
This argument became redundant when Python 3.6 support was dropped as asyncio.run became available in Python 3.7.
Read more >
Cannot import nengo_dl on ms azure - Nengo forum
Hi, I tried to: pip install nengo-dl on Microsoft azure I was able to install it but got this exception when import nengo_dl:...
Read more >
pytest Documentation - Read the Docs
pytest will run all files of the form test_*.py or *_test.py in the current ... Key error expected because a config is not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found