noamaanMulla-03/transformers-issues huggingface dataset:
Request for scripts/helper function to create custom jsonl files for translation 
Author: SupreethRao99
Pull request: no

### Feature request

In the examples for machine translation there's a section that states that current scripts can only consume data in a custom jsonl format as follows
```json
{ "translation": { "en": "Others have dismissed him as a joke.", "ro": "Alții l-au numit o glumă." } }
{ "translation": { "en": "And some are holding out for an implosion.", "ro": "Iar alții așteaptă implozia." } }
```
It would be great if there are helper scripts that could convert pandas data frames into this particular format 

### Motivation

Its frustrating data has to be converted into the particular format for it to be consumed by the training scripts, it would be nice if the scripts consumed CSV's with one column being language1 and the other column being language2. 

### Your contribution

I could help testing and validating the code

Comments:
Examples are just that examples. You should adapt the data processing part to your specific data format.
OPTForCausalLM - ValueError: The following `model_kwargs` are not used by the model: ['new_doc']
Author: FurkanGozukara
Pull request: no

### System Info

Hello. I am using this model : https://huggingface.co/facebook/galactica-6.7b

The example is like this pretty straight

```
from transformers import AutoTokenizer, OPTForCausalLM

tokenizer = AutoTokenizer.from_pretrained("facebook/galactica-6.7b")
model = OPTForCausalLM.from_pretrained("facebook/galactica-6.7b")

input_text = "The Transformer architecture [START_REF]"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

outputs = model.generate(input_ids)
print(tokenizer.decode(outputs[0]))
```


**new GALACTICA model supports the below inputs but I am getting error. This is the code I run**


```
from transformers import AutoTokenizer, OPTForCausalLM

tokenizer = AutoTokenizer.from_pretrained("facebook/galactica-6.7b")
model = OPTForCausalLM.from_pretrained("facebook/galactica-6.7b")

input_text = "The benefits of deadlifting\n\n"
input_ids = tokenizer(input_text, return_tensors="pt").input_ids

outputs = model.generate(input_ids,new_doc=True, top_p=0.7, max_length=2000)
print(tokenizer.decode(outputs[0]))
```



![image](https://user-images.githubusercontent.com/19240467/202852602-74833f48-a83b-406e-8d6f-0f51e38ef859.png)


### Who can help?

_No response_

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

test

### Expected behavior

test

Comments:
@FurkanGozukara I do not see the new_doc parameter accepted neither in code nor in example scripts ? Can you point me to where you got example scripts with new_doc parameter ? 

> @FurkanGozukara I do not see the new_doc parameter accepted neither in code nor in example scripts ? Can you point me to where you got example scripts with new_doc parameter ?

https://github.com/paperswithcode/galai

![image](https://user-images.githubusercontent.com/19240467/203018858-60dfd7fd-f186-4fe8-8217-ab3ab493f9cc.png)



@FurkanGozukara I think there is an mix up, the huggingface api so far does not support new_doc parameter, the new_doc parameter is present in galai library released by paperwithcode .

https://github.com/paperswithcode/galai/blob/f6d9b0a5b35a0eda53597a5ea7d51963bfc05de1/galai/model.py#L88

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.
cannot import electratokenizer or model. It works on colabnotebook but not in python
Author: prsatyal
Pull request: no

### System Info

i have tensorflow version 2.11.0 and transformer version 4.24.0

and i cannot import TFElectraModel. It works for me in google colab but not in my pc.

from transformers import  TFElectraModel
gives me the following error

RuntimeError: Failed to import transformers.models.electra.modeling_tf_electra because of the following error (look up to see its traceback):
No module named 'keras.saving.hdf5_format'

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

in windows install python 3.10
install tensorflow
install numpy
install scikit-learn
install transformers

import tensorflow as tf
import numpy as np
import transformers
from transformers import ElectraTokenizer
from transformers import TFElectraModel

### Expected behavior

It should load the TFElectraModel, i have loaded this model a million times ins google colab and it still works there even now.

Comments:
Transformers is not currently compatible with TensorFlow 2.11 (which broke a lot of things compared to the previous versions). It should be fixed on main so you can either do:
- an install of Transformers from source
- or downgrade your TensorFlow to 2.10

Hi There! I figured as much so is downgraded to tensorflow 2.10 and
installed transformers from the source

On Mon, Nov 21, 2022 at 8:29 PM Sylvain Gugger ***@***.***>
wrote:

> Transformers is not currently compatible with TensorFlow 2.11 (which broke
> a lot of things compared to the previous versions). It should be fixed on
> main so you can either do:
>
>    - an install of Transformers from source
>    - or downgrade your TensorFlow to 2.10
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/huggingface/transformers/issues/20329#issuecomment-1322165802>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AYGQ4SMR5SK5XB45Y5KRPYDWJODDNANCNFSM6AAAAAASFGNBJE>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>


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.
Mismatch in torch size
Author: devyndonahue
Pull request: no

I am trying to fine-tune an NER model using "malduwais/distilbert-base-uncased-finetuned-ner" model, in the dataset I am finetuning on there are only 5 features as opposed to 9 in the one this model was trained on. I get this error when calling trainer.train()

```
RuntimeError: Error(s) in loading state_dict for DistilBertForTokenClassification:
	size mismatch for classifier.weight: copying a param with shape torch.Size([9, 768]) from checkpoint, the shape in current model is torch.Size([5, 768]).
	size mismatch for classifier.bias: copying a param with shape torch.Size([9]) from checkpoint, the shape in current model is torch.Size([5]).
	You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.
```

is there a way to adjust the size when finetuning? Thank you

Comments:
As the error message told you, load your model with `ignore_mismatched_sizes=True`.

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.
TFGPT2ForSequenceClassification.from_pretrained with num_labels parameter creates a model with reversed layers order
Author: justnoxx
Pull request: no

### System Info

platform: macos, m1 max
python version: 3.9.13
transformers version: 4.25.1

### Who can help?

@Rocketknight1 

### Information

- [X] 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

The following code:

```python
from transformers import GPT2Tokenizer, TFGPT2ForSequenceClassification
model = TFGPT2ForSequenceClassification.from_pretrained('gpt2-medium', num_labels=30)
model.summary()
```

It shows then:
```
Model: "tfgpt2_for_sequence_classification_7"
_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 score (Dense)               multiple                  30720     
                                                                 
 transformer (TFGPT2MainLaye  multiple                 354823168 
 r)                                                              
                                                                 
=================================================================
Total params: 354,853,888
Trainable params: 354,853,888
Non-trainable params: 0

```
So as you can see dense layer goes before transformer layer, it should be opposite.

Also there is a Colab link: https://colab.research.google.com/drive/1MeNzHHXnccLAkNlSRpWELQhWF5Y7aIyS#scrollTo=hIbZMVd7xumr


### Expected behavior

I think that the dense layer should go after the transformer layer so that model could be trained. Looks like that something like this has been brought up some time ago:

https://github.com/huggingface/transformers/issues/11515

Comments:
Hi @justnoxx 👋 

The layers are being called in the expected order, as you can see in the [model's forward pass](https://github.com/huggingface/transformers/blob/bbcd961897aa6cc439ef4cca5cef6db4283c5b76/src/transformers/models/gpt2/modeling_tf_gpt2.py#L1139). 

`model.summary()` is not fully compatible with our models because we rely on [Keras model subclassing](https://keras.io/api/models/), as opposed to Keras sequential/functional API (whose `model.summary()` produces the expected output).

@gante now I see it, thanks a lot for your help. Closing this issue now.
Getting different result with different batch size and sequence length
Author: JaheimLee
Pull request: no

Here is the code:
```
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0'
from transformers import BertTokenizer, BertModel
import torch

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained("bert-base-uncased")
model = model.to(device)
model.eval()

text1 = [
    "Replace me by any text you'd like.",
    # "The weather is great!"
]
encoded_input1 = tokenizer(text1, return_tensors='pt', padding=True)
encoded_input1 = encoded_input1.to(device)
with torch.no_grad():
    output1 = model(**encoded_input1).last_hidden_state
cls1 = output1[:, 0, :]

text2 = [
    "Replace me by any text you'd like.",
    "The weather is great!"
    # "The result changed with different batch size and sequence length"
]
encoded_input2 = tokenizer(text2, return_tensors='pt', padding=True)
encoded_input2 = encoded_input2.to(device)
with torch.no_grad():
    output2 = model(**encoded_input2).last_hidden_state
cls2 = output2[:, 0, :]

text3 = [
    "Replace me by any text you'd like.",
    # "The weather is great!"
    "The result is changed with different batch size or sequence length."
]
encoded_input3 = tokenizer(text3, return_tensors='pt', padding=True)
encoded_input3 = encoded_input3.to(device)
with torch.no_grad():
    output3 = model(**encoded_input3).last_hidden_state
cls3 = output3[:, 0, :]

print(torch.equal(cls1[0], cls2[0]))
print(torch.equal(cls1[0], cls3[0]))
print(torch.equal(cls2[0], cls3[0]))
```
All of these results are False. Is it as expected?

Comments:
Hey @JaheimLee 👋 

Yes, minor fluctuations are to be expected. Their causes include (but are not limited to) the numerical masking from the attention mask and the order of operations in fp32 computations.

Because of these fluctuations, we typically consider results correct if their are within 1e-5 of each other, in examples like yours :)

Ok，thanks！
Remove non-breaking spaces
Author: aphedges
Pull request: yes

# What does this PR do?

This PR removes non-breaking spaces in various places in the codebase. The first commit was from when I first found the problem over a year ago, and the second commit fixes all other non-breaking spaces in the repository as of now.

I'm not sure of a good check to prevent this going forward, but it at least fixes the problem as it exists now.

## Before submitting
- [x] 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.
- [ ] 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?

## Who can review?

Library:

- trainer: @sgugger

Documentation: @sgugger and @stevhliu

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Encoding parameter
Author: PrasathMuru
Pull request: no

### Feature request

##transformers.AutoModel.from_pretrained()##  module allows to load pretrained models from local directories as well. The local pickle files path is an argument of the above function. These files can have different encoding types. 

A parameter called 'encoding' can be added in the parameter list similar to 

pandas.read_csv('path/to/csv/file',encoding='utf-8') 

which takes encoding type as parameter. But this proposed encoding feature must be enabled only while loading local files and should not take parameters while loading models from other sources (like HF-Hub etc).

### Motivation

I face Unicode-Decode error while loading pickled model files from local directory. To overcome this issue, the above feature would help to avoid the unicode-decode error.

### Your contribution

Unfortunately, I can't contribute now.

Comments:
Duplicate of #20923
Update run_mlm_no_trainer.py
Author: vedant-z
Pull request: yes

Fixes #18436 

## Before submitting
- [x] 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).
- [ ] Did you write any new necessary tests?


## Who can review?
@muellerzr 

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.

<!-- Your PR will be replied to more quickly if you can figure out the right person to tag with @

 If you know how to use git blame, that is the easiest way, otherwise, here is a rough guide of **who to tag**.
 Please tag fewer than 3 people.

Models:

- albert, bert, xlm: @LysandreJik
- blenderbot, bart, marian, pegasus, encoderdecoder,  t5: @patrickvonplaten, @patil-suraj
- longformer, reformer, transfoxl, xlnet: @patrickvonplaten
- fsmt: @stas00
- funnel: @sgugger
- gpt2: @patrickvonplaten, @LysandreJik
- rag: @patrickvonplaten, @lhoestq
- tensorflow: @LysandreJik

Library:

- benchmarks: @patrickvonplaten
- deepspeed: @stas00
- ray/raytune: @richardliaw, @amogkam
- text generation: @patrickvonplaten
- tokenizers: @n1t0, @LysandreJik
- trainer: @sgugger
- pipelines: @LysandreJik

Documentation: @sgugger

HF projects:

- datasets: [different repo](https://github.com/huggingface/datasets)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Examples:

- maintained examples (not research project or legacy): @sgugger, @patil-suraj
- research_projects/bert-loses-patience: @JetRunner
- research_projects/distillation: @VictorSanh

 -->


Comments:
@muellerzr Please let me know if I have to make some changes or have I done it correctly

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

@vedant-z  Why did you close the request yourself? Was there a mistake?
Long-Short Transformer
Author: schmidek
Pull request: no
Labels: name: New model

# 🌟 New model addition

## Model description

https://arxiv.org/abs/2107.02192

In this paper, they propose Long-Short Transformer, an efficient self-attention mechanism for modeling long sequences with linear complexity for both language and vision tasks. It aggregates a novel long-range attention with dynamic projection to model distant correlations and a short-term attention to capture fine-grained local correlations. Transformer-LS can be applied to both autoregressive and bidirectional models without additional complexity.

## Open source status

* [x] the model implementation is available: https://github.com/NVIDIA/transformer-ls
* [x] the model weights are available: https://github.com/NVIDIA/transformer-ls
* [x] who are the authors: Chen Zhu (@zhuchen03) and Wei Ping and Chaowei Xiao and Mohammad Shoeybi and Tom Goldstein and Anima Anandkumar and Bryan Catanzaro (NVIDIA, University of Maryland)

Comments:
A PyTorch implementation: https://github.com/lucidrains/long-short-transformer

Cool work! However, models have a low chance of being added if there are no pre-trained weights available.

Thanks for your interest in our work! We have released the code for ImageNet and LRA at [https://github.com/NVIDIA/transformer-ls](url). Pretrained weights for ImageNet are also available. We will release the character-level LM soon. 

Hi @zhuchen03! - Since I would like to add your model to the HuggingFace I am wondering if the pretrained weights are also available for character-level LM?

Hi @NielsRogge @zhuchen03 - I would like to implement these models. I will start with the ImageNet classification one.
[CI doc] safely testing experimental CI features
Author: stas00
Pull request: yes

After causing a few CI workflow disruptions with my recent attempts to figure out how to get circleCI do something new (skip heavy builds on doc-only PRs) I realized that future such experiments can be much smoother and lead to close to zero annoyance to anybody involved in submitting and handling PRs.

This PR documents my idea on how to do it given the current limitations of CircleCI and GithubActions, so that we could continue doing such experiments in the future and not interfere with anything.

That's said please vote here:

* Github Actions: https://github.com/actions/runner/issues/2347
* CircleCI: https://ideas.circleci.com/ideas/CCI-I-344 (unfortunately requires a free account to vote)

to get a much simpler support for being able to have a failing step that shouldn't impact the overall PR status.

@LysandreJik, @sgugger 


Comments:
Removed Bert dependency from BertGeneration code base.
Author: Threepointone4
Pull request: yes


# What does this PR do?

-  Related to #19303 
-  Removed `BertGeneration` dependency from `Bert` code base.



<!--
Congratulations! You've made it this far! You're not quite done yet though.

Once merged, your PR is going to appear in the release notes with the title you set, so make sure it's a great title that fully reflects the extent of your awesome contribution.

Then, please replace this with a description of the change and which issue is fixed (if applicable). Please also include relevant motivation and context. List any dependencies (if any) that are required for this change.

Once you're done, someone will review your PR shortly (see the section "Who can review?" below to tag some potential reviewers). They may suggest changes to make the code even better. If no one reviewed your PR after a week has passed, don't hesitate to post a new comment @-mentioning the same persons---sometimes notifications get lost.
-->


## 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).
- [ ] Did you write any new necessary tests?


## Who can review?
@sgugger 



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

Thanks for your contribution!
Comparing a huggingface config with a dictionary raises an error as the `__eq__` method relies on `other` having a `__dict__` method
Author: mmcdermott
Pull request: no

`PreTrainedConfig`s inherit their `__eq__` methods from this:  https://github.com/huggingface/transformers/blob/3f936df66287f557c6528912a9a68d7850913b9b/src/transformers/configuration_utils.py#L736

This works fine for comparing two configs, but if you compare a config to something of a different type, (in particular a type without a `__dict__` attribute, like a pure `dict`), it throws an error. It would be easy to add a type check into the equals comparison to ensure that off-type comparisons return False instead.

Comments:
Would you like to make a PR with such a change?