noamaanMulla-03/transformers-issues huggingface dataset:
'T5Config' object has no attribute '__deepcopy__'
Author: nmntz
Pull request: no
Labels: name: bug

### System Info

- `transformers` version: 4.27.0.dev0
- Platform: Linux-5.4.0-125-generic-x86_64-with-glibc2.17
- Python version: 3.8.15
- Huggingface_hub version: 0.11.0
- PyTorch version (GPU?): 1.13.0+cu117 (True)
- Tensorflow version (GPU?): not installed (NA)
- 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>

### Reproduction

The following fails for me:
```python
  model_name = "google/t5-v1_1-small"
  config = AutoConfig.from_pretrained(model_name)
  model_ref = T5ForConditionalGeneration._from_config(config)
  
  'T5Config' object has no attribute '__deepcopy__'
  File "/home/nouamane/projects/transformers/src/transformers/configuration_utils.py", line 260, in __getattribute__ (Current frame)
    return super().__getattribute__(key)
  File "/home/nouamane/miniconda/envs/py38/lib/python3.8/copy.py", line 151, in deepcopy
    copier = getattr(x, "__deepcopy__", None)
  File "/home/nouamane/projects/transformers/src/transformers/models/t5/modeling_t5.py", line 1498, in __init__
    encoder_config = copy.deepcopy(config)
  File "/home/nouamane/projects/transformers/src/transformers/modeling_utils.py", line 1077, in _from_config
    model = cls(config, **kwargs)
  File "/home/nouamane/projects/brrr/examples/t5/test_t5.py", line 78, in test_t5
    model_ref = T5ForConditionalGeneration._from_config(config)
  File "/home/nouamane/projects/brrr/examples/t5/test_t5.py", line 298, in <module>
    test_t5()
AttributeError: 'T5Config' object has no attribute '__deepcopy__'
```
Could be a cache problem (because I just installed transformers from source today)

### Expected behavior

Loading config should work fine

Comments:
Provide simple way to train a new translation model from scratch
Author: eraoul
Pull request: no

# 🚀 Feature request

<!-- A clear and concise description of the feature proposal.
     Please provide a link to the paper and code in case they exist. -->

## Motivation

Huggingface just released a huge pile of pretrained translation models. I just want to train a completely custom model on a custom language pair, without pretraining etc.

<!-- Please outline the motivation for the proposal. Is your feature request
     related to a problem? e.g., I'm always frustrated when [...]. If this is related
     to another GitHub issue, please link here too. -->

## Your contribution

<!-- Is there any way that you could help, e.g. by submitting a PR?
     Make sure to read the CONTRIBUTING.MD readme:
     https://github.com/huggingface/transformers/blob/master/CONTRIBUTING.md -->


Comments:
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.


unstale

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.


unstale

@sshleifer I was wondering whether there is any activity on this issue. I have trained some models with MarianMT, but I am really interested in training a model from scratch with the transformers library. 

This isn't supported by default, but is definitely possible.


Rough steps would be:
1) Make a local directory with your intialized model and tokenizer.

2) Run a command like [this](https://github.com/huggingface/transformers/blob/master/examples/research_projects/seq2seq-distillation/distil_marian_no_teacher.sh) where `$m` is the path your your local dir.

cc @patil-suraj

@sshleifer  could you please repost the command that the web-page does not exist anymore?

https://github.com/huggingface/transformers/blob/master/examples/research_projects/seq2seq-distillation/distil_marian_no_teacher.sh

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/master/CONTRIBUTING.md) are likely to be ignored.

unstale

unstale
Megatron-11B
Author: KnutJaegersberg
Pull request: no
Labels: name: New model

### Model description

I discovered two implementations of this facebook model on the hub, which was trained on the same corpus as Roberta/Bert. I want to try out some prompting, but when I try to download it with 

from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("hyunwoongko/megatron-11B")


I get a 
KeyError: 'megatron' exception. 

This is a relatively sizable model which is as interesting as gpt-j to me, does it work with transformers? 
I found one of the two model re-publishers below wrote their own library, but it depends on outdated versions of transformer. Can we use this model with transformers? 


### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

The two megatron-to-pytorch models on the hub: 
https://huggingface.co/models?search=megatron-11

Extra py lib which should make it work: 
https://pypi.org/project/megatron-11b/

Comments:
I'm still learning prompting, but after poking around a bit with this model using the pylib I shared above, I found the generated text was of quite low quality for the model size. I got way better results with GPT-J and even GPT-2. 
Despite its size, I doubt this model is useful enough. 

When I got coherent sentences out, it switched topics every second sentence.
Graphormer
Author: clefourrier
Pull request: no
Labels: name: New model

### Model description

Graph Transformer model developed by Microsoft.

https://graphormer.readthedocs.io/en/latest/

### Open source status

- [X] The model implementation is available
- [X] The model weights are available

### Provide useful links for the implementation

Full implementation: https://github.com/microsoft/Graphormer/

Weights: 
-  pcqm4mv1_graphormer_base: https://ml2md.blob.core.windows.net/graphormer-ckpts/checkpoint_best_pcqm4mv1.pt
-  pcqm4mv2_graphormer_base: https://ml2md.blob.core.windows.net/graphormer-ckpts/checkpoint_best_pcqm4mv2.pt
-  pcqm4mv1_graphormer_base_for_molhiv: https://ml2md.blob.core.windows.net/graphormer-ckpts/checkpoint_base_preln_pcqm4mv1_for_hiv.pt

Comments:
Hi, @clefourrier  
can I contribute to this? also open to any other issue 
I have previously contributed to PyTorch (350+ lines of C++, Objective C, and Python)

Hi @Raman-Kumar, I'd be delighted to have some help! 

I'll try to wrap up what I have and clean up a bit by Friday, and either I'll need your help on this to finish up, or it will be good and we can work together on integrating TokenGT, another graph transformer (for which I have draft code), or if you are feeling very confident, you can integrate another graph transformer model of your choice, wdyt?

😊 Replying a little late, I was going through other issues and reading some PRs.
@clefourrier 
I would like to work on integrating TokenGT

and am also ready to offer any other help if you have a delegable workload.
Meanwhile, I am reading more blogs and your work.

Solved by the merge of Graphormer
Fix `GitModelIntegrationTest.test_batched_generation` device issue
Author: ydshieh
Pull request: yes

# What does this PR do?

In PR #21282, `input_ids` is not on the target device and CI fails with

```bash
E       RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select)
```

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Tokens truncated if exceeded 512 tensor shape
Author: thoufeeq1218
Pull request: no

### System Info

Hi, 
    Im using Layoutlmv2 pretrained transformer model, if I put "truncation =True" only half of the image were detected remain not
![res](https://user-images.githubusercontent.com/86664855/203488657-64f08e35-7c07-4580-a5f0-3b34675640a2.png)


### Who can help?

@sanchit-gandhi @sgugger 

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

can't modify model weights shape to match the input tensor shape

### Expected behavior

I want to get full predictions, Thanks in advance🙂

Comments:
Hey @thoufeeq1218! That's a lot of apple crumble! cc'ing in the vision specialist @NielsRogge 😎

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.

@NielsRogge ping on this issue.

Hi,

The recommendation here is to apply a "sliding window" approach, which means that, if your sequence of tokens is > 512, you apply a sliding window with a certain stride (like a window that each time takes 512 tokens as input, and then you shift the window 128 tokens - this is called the stride) and then average predictions for tokens which are part of several windows.

You can specify `return_overflowing_tokens` and `stride` arguments in the processor/tokenizer's call method.

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.
Remove duplicate declarations in dummy inputs for TFLongformer
Author: peakji
Pull request: yes

# What does this PR do?

Remove duplicated lines in [modeling_tf_longformer.py](https://github.com/huggingface/transformers/compare/main...peakji:transformers:patch-1#diff-782b222e9d393fe6750cf8e4cd870bcf3748a92ade5086e518b4d716a80080f8).

## 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?

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:

- text models: @ArthurZucker and @younesbelkada
- vision models: @amyeroberts and @NielsRogge
- speech models: @sanchit-gandhi
- graph models: @clefourrier

Library:

- flax: @sanchit-gandhi
- generate: @gante
- pipelines: @Narsil
- tensorflow: @gante and @Rocketknight1
- tokenizers: @ArthurZucker
- trainer: @sgugger

Integrations:

- deepspeed: HF Trainer: @stas00, Accelerate: @pacman100
- ray/raytune: @richardliaw, @amogkam

Documentation: @sgugger, @stevhliu and @MKhalusova

HF projects:

- accelerate: [different repo](https://github.com/huggingface/accelerate)
- datasets: [different repo](https://github.com/huggingface/datasets)
- diffusers: [different repo](https://github.com/huggingface/diffusers)
- rust tokenizers: [different repo](https://github.com/huggingface/tokenizers)

Maintained examples (not research project or legacy):

- Flax: @sanchit-gandhi
- PyTorch: @sgugger
- TensorFlow: @Rocketknight1

 -->


Comments:
_The documentation is not available anymore as the PR was closed or merged._
Why the 'tokenizer' will return more than one token for single word in GPT2?
Author: Zeqing-Wang
Pull request: no

I'm trying to use the GPT2 to get the feature of a single word. But i find not every single word will get a single token from the 'tokenizer'.  I don't know why it's like that. 
Here is my code:

```
def test_gpt2():
    tokenizer = GPT2Tokenizer.from_pretrained('gpt2')
    model = GPT2Model.from_pretrained('gpt2')
    model.to(torch.device("cuda"))
    # model.feature_extractor._freeze_parameters()
    text = 'irving'#"irving"
    encoded_input = tokenizer(text, return_tensors='pt')
    print(encoded_input)
    encoded_input = encoded_input.to(torch.device("cuda"))
    output = model(**encoded_input)
    print(encoded_input)
   #  print(output.last_hidden_state)
    print(output.last_hidden_state.shape)
```
and the output is:

{'input_ids': tensor([[  81, 1075]]), 'attention_mask': tensor([[1, 1]])}
{'input_ids': tensor([[  81, 1075]], device='cuda:0'), 'attention_mask': tensor([[1, 1]], device='cuda:0')}
torch.Size([1, 2, 768]

It seems like the word 'irving' is mapped to '81' and '1075'

It also happens on some other words.

Comments:
Please use the [forums](https://discuss.huggingface.co/) to ask questions like this as we keep issues for bugs and feature requests only.

Most Transformer models use subword tokenizers, which mean that one word can be split into several tokens. Here the GPT2 tokenizer splits `"irving"` into `["ir", "ving"]`.

> Please use the [forums](https://discuss.huggingface.co/) to ask questions like this as we keep issues for bugs and feature requests only.
> 
> Most Transformer models use subword tokenizers, which mean that one word can be split into several tokens. Here the GPT2 tokenizer splits `"irving"` into `["ir", "ving"]`.

I am sry for putting the question in the wrong place....

and thanks for your help, I've got it!
Fix DETR tests after #21144
Author: amyeroberts
Pull request: yes

# What does this PR do?

Bug introduced with #21144 when checking whether annotations were batched. In part, because of a mismatch between type annotations and input types. Updated logic and annotations. 

## 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._
Add cPython files in build
Author: sgugger
Pull request: yes

# What does this PR do?

As reported by @clefourrier the Graphormer model in the last release is not usable as is, as the cpython file containing the code for the collation of samples is not included in the built package. This PR fixes that by including the extensions (similar to what we did for custom CUDA kernels).

This will be included in the next patch release.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Generate: Relaxed `max_length` and `max_new_tokens` coexistence
Author: gante
Pull request: yes

# What does this PR do?

TL;DR: stops raising an exception in `.generate()` when `max_length` and `max_new_tokens` are both set -- `max_new_tokens` will take precedence.

Context: Some downstream uses of `.generate()`, for legacy reasons, set `max_length` (e.g. pipelines, API). If a user tries manually setting `max_new_tokens`, as suggested in the documentation, an exception is thrown (even if `max_length` is manually set to `None`). 

Because `max_length` can be set outside the `GenerationConfig` and `.generate()`, it's hard to detect whether the `max_length` is intentionally set (and thus shouldn't be allowed together with `max_new_tokens`) or simply a helpful default. Raising an exception can thus block a correct usage of `max_new_tokens`. This PR relaxes this requirement, making `max_new_tokens` take precedence and raising an informative warning instead.

Fixes #21369 

___________________________________________________________________
Example of failing code before this PR:
```py

import requests

API_URL = "https://api-inference.huggingface.co/models/google/flan-t5-xl"
headers = {"Authorization": "Bearer hf_xxx"}


def query(payload):
    response = requests.post(API_URL, headers=headers, json=payload)
    return response.json()


output = query(
    {"inputs": "The answer to the universe is", "parameters": {"max_new_tokens": 100}}
)
output
```

Comments:
cc @lewtun -- thank you for raising the issue 🙏 

_The documentation is not available anymore as the PR was closed or merged._
[`run_(clm|mlm).py` examples] add streaming dataset support
Author: stas00
Pull request: yes

This PR adds streaming dataset support. It's fine if it remains a PR for those who might need it. if it's to be merged should probably check when streaming was added to `datasets` and require that version.

1. API-wise everything is as before but need to pass `--streaming`  to load the dataset in a streaming mode. 
2. and also since `IterableDataset` has no `__len__` this makes the `--max_steps` flag required (possibly can make this more clear by asserting earlier if `--streaming` and `not --max_steps`)

This should make a huge speed up to start working with large datasets. So that work can start immediately and the data gets loaded progressively (which overall is likely to be slower - haven't measured yet - but it makes starting much easier).


Example run:
```
python examples/pytorch/language-modeling/run_clm.py --bf16 --seed 42 \
--model_name_or_path facebook/opt-1.3b --dataset_name wikitext \
--dataset_config_name wikitext-103-raw-v1 --per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 --gradient_accumulation_steps 1 --do_train \
--do_eval --logging_steps 10 --save_steps 1000 --eval_steps 100 --weight_decay \
0.1 --num_train_epochs 1 --adam_beta1 0.9 --adam_beta2 0.95 --learning_rate \
0.0002 --lr_scheduler_type linear --warmup_steps 500 --report_to tensorboard \
--output_dir save_dir --max_steps 1_000_000 --streaming
```

Ported this to `run_mlm.py` as well.

Thank you, @lhoestq for helping with this

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

Reworked w/o `kwargs` and copying the code where needed, please let me know when it's good for you and I can replicate to mlm

should I figure out when streaming was added and put a assert if an earlier datasets is used?

Good point. Streaming was introduced a while ago, but I think it stabilized with the 2.0 version, so maybe use this one as a minimal requirement for streaming?

- added version check
- ported to mlm
- added a doc entry

This is good to go for a final review, Sylvain. Thank you.

And thank you for reviewing my work, Sylvain!
Stored XSS
Author: saas-pro
Pull request: no

### System Info

Hi Team,
I've discovered a **stored cross-site scripting** vulnerability on your domain (https://transformer.huggingface.co/). Is your organization currently conducting a bug bounty program for this website? If so, kindly provide me with the appropriate information. Additionally, would it be possible for you to furnish me with the email contact of your security team?

Best Regards

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

null

### Expected behavior

null

Comments:
Hi @Dark-Aura, Thanks for reaching out to us! 🤗 We have a bug bounty program with HackerOne and would love for you to submit security vulnerability reports to https://hackerone.com/hugging_face. We'll need to send you an invite since this is a private program, so please feel free to send us an email at security@huggingface.co or let me know your H1 username. Please let us know if there are any questions. Thanks again!

Thanks for your reply, however, I had already visited this page and I'm getting a 404 error, for your perusal I'm attaching the screenshot please take a look at it
![image](https://user-images.githubusercontent.com/65353593/215638681-274becb8-757c-4b98-8f37-ea826abc6a18.png)


Hi @Dark-Aura,

Thanks for sending your H1 username to us via email; you should receive an invite to our bug bounty program soon. Please let us know if you run into any issues submitting reports!

Thanks again,
Michelle
Add DETA
Author: NielsRogge
Pull request: yes

# What does this PR do?

This PR adds [DETA](https://github.com/jozhang97/DETA/issues/3). DETA is a slight change to Deformable DETR by using traditional IoU-based assignment as opposed to the Hungarian matching used in the original DETR, and incorporating NMS (non-maximum suppression) in the postprocessing.

Note: this model has a `torchvision` dependency for NMS.

To do:

- [x] transfer checkpoints

Comments:
cc @alaradirik this PR is in a ready state, except for 2 things:

- [x] whether or not we leverage torchvision's `batched_nms` => the CI is currently failing because this library is not installed. Will also ask for @sgugger and @LysandreJik's opinion here
- [ ] the `post_process_object_detection` method might require an in-depth look

There is no problem with the model requiring torchvision to be installed. We have many models with specific dependencies, some of which you ported yourself ;-).
Just protect the import between `if is_torchvision_available()` and have a the first line in the init of the models be a `require_backends(["torchvision"])`.

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

@sgugger I've addressed all comments, except for adding support for the custom kernel.

Could we perhaps add support for the custom kernel for the 3 models (Mask2Former, OneFormer and DETA) in a separate PR?

In this case, remove the code trying to load the custom kernels in the modeling file and we can add it back in the PR that will deal with custom kernels.

@sgugger ok, feel free to approve :)

Failing test is unrelated/flaky, merging.