ImportError: cannot import name 'DefaultDataCollator'
See original GitHub issue🐛 Bug
Information
Using “from transformers import DefaultDataCollator” raises an ImportError on my system. Unsure if this is really a bug or if I’m doing something stupid. Any help would be appreciated.
Model I am using (Bert, XLNet …): N/A
Language I am using the model on (English, Chinese …): N/A
The problem arises when using:
- 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)
- my own task or dataset: (give details below)
To reproduce
Steps to reproduce the behavior:
- from transformers import DefaultDataCollator
Expected behavior
For the import to go through cleanly.
Environment info
transformers
version: 2.8.0- Platform: Ubuntu 18.04
- Python version: 3.6.9
- PyTorch version (GPU?): 1.5.0, No
- Tensorflow version (GPU?): -
- Using GPU in script?: No
- Using distributed or parallel set-up in script?: -
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (2 by maintainers)
Top Results From Across the Web
Transformer: Error importing packages. "ImportError: cannot ...
Change the torch version in colab by running this command !pip install torch==1.4.0. Then, It worked for me.
Read more >Cannot import Data Collator For PLM - Transformers
Cannot import Data Collator For PLM ... in <module> from transformers import ( ImportError: cannot import name 'DataCollatorForPermutationLanguageModeling'.
Read more >Can not import DataCollatorForLanguageModeling - CSDN博客
It's because the pip package hasn't been updated. The script to train is changed fundamentally. so you can try building from scratch using....
Read more >python/keyonvafa/sequential-rationales/huggingface/src ...
import collections import inspect import math import os import random import re ... TrainingArguments` with the ``output_dir`` set to a directory named ......
Read more >cannot import name 'file_hash' from 'pooch.utils' - YouTube
How to resolve ImportError : cannot import name 'file_hash' from 'pooch.utils'
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like the way to fix this is to now use
from transformers.data.data_collator import tf_default_data_collator
. Is there any way to update this in the tutorial?you can open transformers/data/data_collator.py,you can find ‘tf_default_data_collator’ is not exsit,then you can find function ‘default_data_collator’
so you can replace by this code: