noamaanMulla-03/transformers-issues huggingface dataset:
layoutlmv3-base-chinese tokenizer could not be loaded.
Author: pogevip
Pull request: no
Labels: name: bug

### System Info

```
File ~/anaconda3/envs/paddle_env/lib/python3.8/site-packages/transformers/models/layoutlmv3/tokenization_layoutlmv3.py:325, in LayoutLMv3Tokenizer.__init__(self, vocab_file, merges_file, errors, bos_token, eos_token, sep_token, cls_token, unk_token, pad_token, mask_token, add_prefix_space, cls_token_box, sep_token_box, pad_token_box, pad_token_label, only_label_first_subword, **kwargs)
    305 mask_token = AddedToken(mask_token, lstrip=True, rstrip=False) if isinstance(mask_token, str) else mask_token
    307 super().__init__(
    308     errors=errors,
    309     bos_token=bos_token,
   (...)
    322     **kwargs,
    323 )
--> 325 with open(vocab_file, encoding="utf-8") as vocab_handle:
    326     self.encoder = json.load(vocab_handle)
    327 self.decoder = {v: k for k, v in self.encoder.items()}

TypeError: expected str, bytes or os.PathLike object, not NoneType

```





### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [ ] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

none

### Expected behavior

```
from transformers import AutoProcessor, AutoModel, XLMRobertaTokenizer, LayoutLMv3
chinese_processor = AutoProcessor.from_pretrained("./layoutlmv3_base_chinese", apply_ocr=False, local_files_only=True) 
```
But we seem need vocab.json and merges.txt to load the LayoutLMv3Tokenizer .
So  could you provide a function to convert them or confirm whether there is a diff between these two tokenizers?

Comments:
The same problem, can you please solve it

**The problem still exists.**

processor = AutoProcessor.from_pretrained("microsoft/layoutlmv3-base", apply_ocr=False)
It can run successfully，fail to load "microsoft/layoutlmv3-base-chinese", such as: 
processor = AutoProcessor.from_pretrained("microsoft/layoutlmv3-base-chinese", apply_ocr=False)

TypeError: expected str, bytes or os.PathLike object, not NoneType


Version: 4.22.0.dev0
Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow
Home-page: https://github.com/huggingface/transformers
Author: The Hugging Face team (past and future) with the help of all our contributors 

As far as I know, transformers doesn't support chinese layoultlmv3,  but unilm is OK.
https://github.com/microsoft/unilm/tree/master/layoutlmv3

> As far as I know, transformers doesn't support chinese layoultlmv3, but unilm is OK. https://github.com/microsoft/unilm/tree/master/layoutlmv3

But I see it also requires vocab.json and merges.txt. I cannot load tokenizer either.
https://github.com/microsoft/unilm/blob/master/layoutlmv3/layoutlmft/models/layoutlmv3/tokenization_layoutlmv3.py

![1663659780(1)](https://user-images.githubusercontent.com/29231853/191197738-3eee84fe-57c2-47b6-ab43-1a91ea2fb823.png)

How did you solve it, please?
Fix the wrong schedule in runner check CI
Author: ydshieh
Pull request: yes

# What does this PR do?

The current (wrong) schedule in `check_runner_status.yml`:
`* */1 * * *` -> “At every minute past every hour.”
But we want
`0 */1 * * *` -> “At minute 0 past every hour.”


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Change document question answering pipeline to always return an array
Author: ankrgyl
Pull request: yes

# What does this PR do?

Updates the DocumentQuestionAnsweringPipeline to always return an array, to fix the inference widget, and also be easier to use in general.

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [x ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- x[ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [ ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [x ] Did you write any new necessary tests?


## Who can review?

@Narsil @mishig25 



Comments:
_The documentation is not available anymore as the PR was closed or merged._

i think this will fix this issue:

<img width="686" alt="image" src="https://user-images.githubusercontent.com/326577/191121642-1fd004ea-4111-439b-923c-020acf05c5b7.png">


Yes that is exactly its intent!
OSError in linux server
Author: PersianSpock
Pull request: no
Labels: name: bug

### System Info

Python 3.8.10

version of transformers == 4.0.1

linux server


### Who can help?

@patil-suraj

Hi. I'm fine-tuning TrOCR in Farsi.

### Information

- [ ] The official example scripts
- [X] My own modified scripts

### Tasks

- [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [X] My own task or dataset (give details below)

### Reproduction

tokenizer xlm-roberta-large
model: 
`model = VisionEncoderDecoderModel.from_encoder_decoder_pretrained("google/vit-base-patch16-224-in21k", 'facebook/mbart-large-50', from_tf=True)`

### Expected behavior

I expect it to run and train the model as it does in colab, but it gives me this error:

> OSError: Unable to load weights from pytorch checkpoint file for '/root/.cache/huggingface/transformers/d01bfc4a52063e6f2cc1bc7063192e012043a7c6d8e75981bb6afbb9dc911001.e4710baf72bd00d091aab2ae692d487c057734cf044ba421696823447b95521e' at '/root/.cache/huggingface/transformers/d01bfc4a52063e6f2cc1bc7063192e012043a7c6d8e75981bb6afbb9dc911001.e4710baf72bd00d091aab2ae692d487c057734cf044ba421696823447b95521e'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.

Comments:
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
Layer #0 (named "roberta") expects 0 weight(s), but the saved weights have 199 element(s)
Author: QixinLi
Pull request: no

# ❓ Questions & Help

## Details
I wanna build a new NLU model extented by TFRobertaPreTrainedModel.
And I write code with reference to 'TFRobertaForSequenceClassification' class.
```python
from transformers import TFRobertaPreTrainedModel, TFRobertaMainLayer
class TFRobertaForNLU(TFRobertaPreTrainedModel):
    def __init__(self, config, *inputs, **kwargs):
        super().__init__(config, *inputs, **kwargs)
        self.roberta = TFRobertaMainLayer(config, name="roberta")

    def call(self,inputs=None,attention_mask=None,token_type_ids=None,position_ids=None,head_mask=None,inputs_embeds=None,output_attentions=None,output_hidden_states=None,labels=None,training=False,):
        pass

model = TFRobertaForNLU.from_pretrained("jplu/tf-xlm-roberta-base")
```
And I got an error:
```python
Traceback (most recent call last):
  File "test.py", line 449, in <module>
  File ".../lib/python3.7/site-packages/transformers/modeling_tf_utils.py", line 489, in from_pretrained
    model.load_weights(resolved_archive_file, by_name=True)
  File ".../lib/python3.7/site-packages/tensorflow_core/python/keras/engine/training.py", line 181, in load_weights
    return super(Model, self).load_weights(filepath, by_name)
  File ".../lib/python3.7/site-packages/tensorflow_core/python/keras/engine/network.py", line 1175, in load_weights
    saving.load_weights_from_hdf5_group_by_name(f, self.layers)
  File ".../lib/python3.7/site-packages/tensorflow_core/python/keras/saving/hdf5_format.py", line 751, in load_weights_from_hdf5_group_by_name
    str(len(weight_values)) + ' element(s).')
ValueError: Layer #0 (named "roberta") expects 0 weight(s), but the saved weights have 199 element(s).
```

It seems like the 'roberta' layer not properly initialized. Am I wrong in somewhere?

Comments:
Hello, I'm facing the same issue. Do you find any solutions ? :)

Hello, facing the same problem

cc @Rocketknight1 @gante :raised_hands: 

Directly using `TFRobertaMainLayer` is unusual and not recommended - @jessiewang158 can you try using `TFRobertaModel` instead?

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.
[Wav2Vec2] Fix None loss in docstring for Wav2Vec2ForPretraining
Author: abdouaziz
Pull request: yes

# What does this PR do?

- [ ]  This PR fix None loss in docstring for Wav2Vec2ForPretraining

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_19061). All of your documentation changes will be reflected on that endpoint.

Hey @abdouaziz! Looks like you need to rebase onto main: https://github.com/huggingface/transformers/pull/18960#issuecomment-1248291349

That should fix the file changes!
[Wav2Vec2] Fix `None` loss in docstring for Wav2Vec2ForPreTraining
Author: abdouaziz
Pull request: yes

# What does this PR do?

- [ ] It fixes the Nan value returned in the contrastive loss of [Wav2Vec2ForPreTraining](https://huggingface.co/docs/transformers/v4.21.3/en/model_doc/wav2vec2#transformers.Wav2Vec2ForPreTraining)  .
- [ ] Adding sampled_negative_indices as a target allows Wav2Vec2ForPreTraining to calculate the loss. 


Comments:
_The documentation is not available anymore as the PR was closed or merged._

Great! Now that we've established the problem:

> loss is `None` as `sampled_negative_indices` is omitted from the args of the model

and verified the fix:

> forward `sampled_negative_indices` to the model

we can touch-up this PR and get it merged!

We'll need to do two things:
1. Remove the erroneous file [src/transformers/models/test.py](https://github.com/huggingface/transformers/pull/18960/files/e94a4d4e7bb108aeba8daafc3de7b58fc5048838#diff-dc9af87a30bbbc682dfaf00796e992367511d96095a2f0a46a8da06a948a7050)
2. Code quality: you can do this simply by running `make style` from the root of the Transformers repo 🤗

Let me know if you have any questions! Cheers!

Hello @sanchit-gandhi  Thanks for the help , I am still having some issue even when I make sure that I had installed all the necessary packages I am still having this error . 
Even `pip install black[jupyter]` is installed and when I run `make style`i have the same error here : 
```py

Skipping .ipynb files as Jupyter dependencies are not installed.
You can fix this by running ``pip install black[jupyter]``
would reformat examples/research_projects/lxmert/modeling_frcnn.p
...
```

Hey @abdouaziz. Thanks for removing the erroneous file :) Don't worry about the `.ipynb` warning as we've not changed any Python notebooks! Looks like something else is up with `make style` though - we have 567 files changed in this PR! There should only be 2 files changed (wav2vec2 and wav2vec2-conformer).

Could you try the following in turn and check whether the number of files changed drops back down to 2 after each step:
1. Rebasing onto main:
```
git fetch upstream
git rebase upstream/main
```
And then running `make style`.
2. Updating HF doc builder https://pypi.org/project/hf-doc-builder/
```
pip install --upgrade hf-doc-builder
```
And then running `make style`.

If that doesn't fix it we can try some other hacks!



Hey @abdouaziz - sorry this has been so arduous! Are you still interested in completing this PR? Feel free to open a new one if you wish and we can go from there!

> 
Hello @sanchit-gandhi  , Yes i am interesting to completing this RP , but I am still having  the same issue here the new PR 
https://github.com/huggingface/transformers/pull/19061#issue-1375177421 , 
I am ready for suggestion ??
Skip `test_export_to_onnx` for `LongT5` if `torch` < 1.11
Author: ydshieh
Pull request: yes

# What does this PR do?

With torch `1.10`, We get some exception from C++ file.
```bash
Exception raised from index_select_out_cpu_ at ../aten/src/ATen/native/TensorAdvancedIndexing.cpp:887 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0x42 (0x7f60b7f4dd62 in /home/yih_dar_huggingface_co/miniconda3/envs/py39/lib/python3.9/site-packages/torch/lib/libc10.so)
```
Skip this test for torch < 1.11: **Make past CI clean**


P.S. this test is only defined for 3 models (T5, LongT5 and FSMT), but skipped (without any condition) for T5 and FSMT.
It should be fine to remove this test, and rely on `tests/onnx`.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Update no_trainer scripts with new Accelerate functionalities
Author: muellerzr
Pull request: yes
Labels: name: PyTorch

name: External

name: Examples

# Update the `no_trainer` scripts to keep aligned with Accelerate capabilities

## What does this add?

Updates all `no_trainer` scripts to use the latest capabilities.

## Why is it needed?

Accelerate had a number of new capabilities added, including better saving/loading, experiment tracking, and support for LR Schedulers. As a result, much of the current scripts can either be simplified from their hard-coded behaviors, or have these features added

Modified scripts with potential major changes:
- `language-modeling`
- `multiple-choice`
- `question-answering`
- `summarization`
- `text-classification`
- `token-classification`
- `translation`

The speech fine-tuning will be updated in a later PR

## Basic usage examples:

* Saving checkpoints each epoch or number of steps:
```bash
accelerate launch language-modeling/run_clm_no_trainer --checkpointing_steps "epoch"
```
```bash
accelerate launch language-modeling/run_clm_no_trainer --checkpointing_steps 100
```
* Resuming training from a saved checkpoint: 
```bash
accelerate launch language-modeling/run_clm_no_trainer --resume_from_checkpoint "epoch_1"
```
* Use any available trackers that Accelerate can automatically pick up including Weights and Biases, TensorBoard, and CometML
```bash
accelerate launch language_modeling/run_clm_no_trainer --with_tracking
```
## Anticipated maintence burden? (What will happen in say, 3 months if something changes)

As it gets more widly used, these scripts might need small updates if we find the end-users prefer a different experience when it comes to logging, or other small bugfixes we find as time goes on.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
GPT Neox Japanese is in the release notes for v4.22.X but does not appear to be in the v4.22.X package.
Author: SO0529
Pull request: no
Labels: name: bug

### System Info

I've checked in Colab that GPT Neox Japanese is not in v4.22.1
```
- `transformers` version: 4.22.1
- Platform: Linux-5.10.133+-x86_64-with-Ubuntu-18.04-bionic
- Python version: 3.7.14
- Huggingface_hub version: 0.9.1
- PyTorch version (GPU?): 1.12.1+cu113 (False)
- Tensorflow version (GPU?): 2.8.2 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: <fill in>
- Using distributed or parallel set-up in script?: <fill in>
```

### Who can help?

@LysandreJik

### Information

- [X] The official example scripts
- [ ] My own modified scripts

### Tasks

- [X] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

1. Open colab
2. `!pip install transformers` to install the latest version (currently v4.22.1)
3. `from transformers import GPTNeoXJapaneseForCausalLM, GPTNeoXJapaneseTokenizer`
then raise below import error.
```---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
[<ipython-input-7-401722e84f23>](https://localhost:8080/#) in <module>
----> 1 from transformers import GPTNeoXJapaneseForCausalLM, GPTNeoXJapaneseTokenizer

ImportError: cannot import name 'GPTNeoXJapaneseForCausalLM' from 'transformers' (/usr/local/lib/python3.7/dist-packages/transformers/__init__.py)

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
```

In [this release note](https://github.com/huggingface/transformers/releases/tag/v4.22.0), I thought we can use `GPT NeoX Japanese` from v4.22.0 release. That's not surprising, the model was not included in the zip file of the v4.22.0 release...
I would be glad to know the situation:smiley:

FYI
We can use GPT NeoX Japanese from `pip install git+https://github.com/huggingface/transformers` because it's in the main branch.

### Expected behavior

`GPT Neox Japanese` must be able to import correctly.

Comments:
Hey @SO0529, sorry about that! That's on me, I missed this in the release notes. I just removed it. For now you can install the repo from source as you have noted in order to use it.

Thanks for letting me know!

Thank you for quick response and update the release note!
We are looking forward to the next release when GPT NeoX Japanese will be available.
Let's close this issue. Thank you!
Fix GLUE MNLI evaluation when using `max_eval_samples`
Author: lvwerra
Pull request: yes

# What does this PR do?

Even when selecting `max_eval_samples` the script will always also evaluate on the full mismatched validation set. This PR fixes this by sampling the mismatched split the same way the matched split is sampled.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add post_process_semantic_segmentation method to DPTFeatureExtractor
Author: alaradirik
Pull request: yes

# What does this PR do?
Adds post_process_semantic_segmentation method to DPTFeatureExtractor.

I will open an issue and separate PRs to make sure that:
- Segmentation models (DETR, MaskFormer, SegFormer, etc.) have consistently named post-processing methods, arguments and outputs
- ImageSegmentationPipeline works with all available segmentation models

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [X ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [X] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [ ] Did you write any new necessary tests?



Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix FlaxPretTrainedModel pt weights check
Author: mishig25
Pull request: yes

# What does this PR do?

[files tab](https://github.com/huggingface/transformers/pull/19133/files) should make it clear on what's being changed.

```py
if os.path.join(pretrained_model_name_or_path, WEIGHTS_NAME)
# will evaluate always to True as long as `pretrained_model_name_or_path` is a non-empty str
```

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Fix BeitFeatureExtractor postprocessing
Author: alaradirik
Pull request: yes

# What does this PR do?
- Fixes a `BeitFeatureExtractor.post_process_semantic_segmentation()` assertion error when no `target_sizes` argument is provided
- Ensures post_process_semantic_segmentation returns a list of int64 PyTorch tensors
- Adds a test to ensure correct post-processing

## Before submitting
- [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
- [X ] Did you read the [contributor guideline](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md#start-contributing-pull-requests),
      Pull Request section?
- [ ] Was this discussed/approved via a Github issue or the [forum](https://discuss.huggingface.co/)? Please add a link
      to it if that's the case.
- [X ] Did you make sure to update the documentation with your changes? Here are the
      [documentation guidelines](https://github.com/huggingface/transformers/tree/main/docs), and
      [here are tips on formatting docstrings](https://github.com/huggingface/transformers/tree/main/docs#writing-source-documentation).
- [X ] Did you write any new necessary tests?




Comments:
_The documentation is not available anymore as the PR was closed or merged._

Hey @alaradirik, please also ping a core maintainer for review before merging PRs.
Use metrics that consider the input as well as the (predicted, reference) tuple in the Trainer
Author: slvcsl
Pull request: no

### Feature request

Allow the **compute_metrics()** in the **Trainer** to take into account the **original input** in addition to the predictions and labels.

### Motivation

It is currently possible to pass a custom compute_metrics() to the Trainer for evaluation. An example is 

```
def compute_metrics(eval_preds):
    metric = evaluate.load("glue", "mrpc")
    logits, labels = eval_preds
    predictions = np.argmax(logits, axis=-1)
    return metric.compute(predictions=predictions, references=labels)

```
However, the compute_metrics seems to be constrained only to receive a logit, label tuple. 

This is insufficient for some metrics that also depend on the original sentence. An example is [SARI](https://huggingface.co/spaces/evaluate-metric/sari), which is currently implemented in the evaluate library.

Being unable to use the original input in the evaluation makes it impossible to use the Trainer for some seq2seq tasks, e.g. simplification.

### Your contribution

If the request is accepted, I will try to contribute with a PR.

Comments:
I just saw that the feature is actually already added. 

One can add the trainer argument --include_inputs_for_metrics
and the compute_metrics will receive the inputs as the third element of the tuple.
Support depencencies from github
Author: lhoestq
Pull request: yes

Updated the `deps` regex to support dependencies from github.

For example I often want to run the `transformers` CI but with the `main` branch of `datasets` using
```
    "datasets @ git+https://github.com/huggingface/datasets@main#egg=datasets",
```

Comments:
Tests failure are not related to this PR (but to `datasets`, sorry)


May I merge anyway ?


EDIT: actually the CI has been fixed on main, let me just update this PR

_The documentation is not available anymore as the PR was closed or merged._