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.

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:

  1. 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:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Jadikercommented, Apr 16, 2022

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?

0reactions
ImmortalZcommented, Aug 13, 2022

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:

from transformers.data.data_collator import default_data_collator
Read more comments on GitHub >

github_iconTop 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 >

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