nlp-with-transformers / notebooks

Jupyter notebooks for the Natural Language Processing with Transformers book
https://transformersbook.com/
Apache License 2.0
3.81k stars 1.17k forks source link

Chapter 4 (04_multilingual-ner.ipynb), Trainer() reported KeyError: 'email' #142

Open shandong1970 opened 1 month ago

shandong1970 commented 1 month ago

Information

The problem arises in chapter:

Describe the bug

To Reproduce

Steps to reproduce the behavior:

  1. one by one to run the code of <04_multilingual-ner.ipynb>.
  2. when you call Trainer, you will meet the error.

The code snippets are below:

from transformers import Trainer

trainer = Trainer(model_init=model_init, args=training_args, 
                  data_collator=data_collator, compute_metrics=compute_metrics,
                  train_dataset=panx_de_encoded["train"],
                  eval_dataset=panx_de_encoded["validation"], 
                  tokenizer=xlmr_tokenizer)

The error messages are below:

/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_deprecation.py:131: FutureWarning: 'Repository' (from 'huggingface_hub.repository') is deprecated and will be removed from version '1.0'. Please prefer the http-based alternatives instead. Given its large adoption in legacy code, the complete removal is only planned on next major release.
For more details, please read https://huggingface.co/docs/huggingface_hub/concepts/git_vs_http.
  warnings.warn(warning_message, FutureWarning)
/content/notebooks/xlm-roberta-base-finetuned-panx-de is already a clone of https://huggingface.co/shandong1970/xlm-roberta-base-finetuned-panx-de. Make sure you pull the latest changes with `repo.git_pull()`.
WARNING:huggingface_hub.repository:/content/notebooks/xlm-roberta-base-finetuned-panx-de is already a clone of https://huggingface.co/shandong1970/xlm-roberta-base-finetuned-panx-de. Make sure you pull the latest changes with `repo.git_pull()`.
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
[<ipython-input-54-ef227f75390c>](https://localhost:8080/#) in <cell line: 4>()
      2 from transformers import Trainer
      3 
----> 4 trainer = Trainer(model_init=model_init, args=training_args, 
      5                   data_collator=data_collator, compute_metrics=compute_metrics,
      6                   train_dataset=panx_de_encoded["train"],

4 frames
[/usr/local/lib/python3.10/dist-packages/huggingface_hub/repository.py](https://localhost:8080/#) in __init__(self, local_dir, clone_from, repo_type, token, git_user, git_email, revision, skip_lfs_files, client)
    543 
    544             if git_email is None:
--> 545                 git_email = user["email"]
    546 
    547             if git_user is None:

KeyError: 'email'

Expected behavior

Ice-Citron commented 1 month ago

i think i faced this error before. this is something you need to try to solve by passing in your HF_TOKEN i think. something along the line.