unk handling in v3.0 different than v2.0?
Author: BCWang93
Pull request: no
Labels: name: wontfix

name: Core: Tokenization

# ❓ Questions & Help

<!-- The GitHub issue tracker is primarly intended for bugs, feature requests,
     new models and benchmarks, and migration questions. For all other questions,
     we direct you to the Hugging Face forum: https://discuss.huggingface.co/ .
     You can also try Stack Overflow (SO) where a whole community of PyTorch and
     Tensorflow enthusiast can help you out. In this case, make sure to tag your
     question with the right deep learning framework as well as the
     huggingface-transformers tag: 
     https://stackoverflow.com/questions/tagged/huggingface-transformers 
     -->

## Details
<!-- Description of your issue -->
I have this problem in runing my code in transformers3.0.2,
Trainable parameters: 102274668
248
250
252
252
248
250
252
252
Traceback (most recent call last):
  File "train.py", line 92, in <module>
    run('./configs/base_config.json')
  File "train.py", line 88, in run
    main(config)
  File "train.py", line 66, in main
    trainer.train()
  File "/DATA2/disk1/wangbingchen/project/ccks2020-task8-pytorch/base/base_trainer.py", line 67, in train
    result = self._train_epoch(epoch)
  File "/DATA2/disk1/wangbingchen/project/ccks2020-task8-pytorch/trainer/trainer.py", line 59, in _train_epoch
    for batch_idx, batch_data in enumerate(self.train_iter):
  File "/home/wangbingchen/wangbingchen/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 345, in __next__
    data = self._next_data()
  File "/home/wangbingchen/wangbingchen/anaconda3/lib/python3.7/site-packages/torch/utils/data/dataloader.py", line 385, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "/home/wangbingchen/wangbingchen/anaconda3/lib/python3.7/site-packages/torch/utils/data/_utils/fetch.py", line 47, in fetch
    return self.collate_fn(data)
  File "/DATA2/disk1/wangbingchen/project/ccks2020-task8-pytorch/data_process/military_data_process.py", line 179, in collate_fn
    text_token_ids = torch.LongTensor(np.array(text_token_ids))
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, int64, int32, int16, int8, uint8, and bool.
this is the problem of embedding length.But when I run this code in transformers2.11,everything is well.So,I want to ask the difference of transformers2.11 and transformers3.0.2.Thanks very much!
<!-- You should first ask your question on the forum or SO, and only if
     you didn't get an answer ask it here on GitHub. -->
**A link to original question on the forum/Stack Overflow**:

Comments:
Hey @BCWang93, can you post a reproducible code snippet? It would be great if we could just copy paste your code and see the same error you post here :-) 

> Hey @BCWang93, can you post a reproducible code snippet? It would be great if we could just copy paste your code and see the same error you post here :-)

Because this is an entire project, I can't paste the full code. But I found the difference between transformers 3 and 2. Transformers2 maps ID to "[unk]" when dealing with characters like '\n','\r' et.al, but transformers3 discards all such characters when dealing with such cases. Like this:
![image](https://user-images.githubusercontent.com/31853251/90902807-9db0d980-e3ff-11ea-8ebf-4abf3d97b732.png)
Thanks very much!

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.