noamaanMulla-03/transformers-issues huggingface dataset:
transformers does not detect Tensorflow when installing tensorflow-cpu package
Author: faph
Pull request: no

### System Info

This issue was introduced in transformers 4.30.x.



Output of pip list (partial):

```
tensorflow-cpu                       2.12.0
tensorflow-estimator                 2.12.0
tensorflow-intel                     2.12.0
tensorflow-io-gcs-filesystem         0.31.0
transformers                         4.30.1
```

### Who can help?

_No response_

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

Manifests itself like this:

```
None of PyTorch, TensorFlow >= 2.0, or Flax have been found. Models won't be available and only tokenizers, configuration and file/data utilities can be used.
ImportError while loading 

<REDACTED>

    from transformers import file_utils, modeling_tf_outputs, modeling_tf_utils
.venv\lib\site-packages\transformers\modeling_tf_utils.py:42: in <module>
    from .generation import GenerationConfig, TFGenerationMixin
E   ImportError: cannot import name 'TFGenerationMixin' from 'transformers.generation' (<REDACTED>)
```

### Expected behavior

No errors, Tensorflow detected.

Comments:
@apbard I see you touched the Tensorflow detection logic here: https://github.com/huggingface/transformers/commit/83eda6435e7c842e55b42a529e9bf367bf2a126b. 

cc @ydshieh @Rocketknight1  

Just to confirm, if I set env var `FORCE_TF_AVAILABLE` all works as expected. (I'd like to avoid that of course)

Remark: On our CircleCI, the `tensorflow` is installed (forced by `tensorflow_text`), so there is `tensorflow` and `tensorflow_cpu` in the CI environment.

Confirmed this issue on my end. The problem is the name discrepancy between the packages and our `_is_package_available` code. Will open a PR to fix it!

PR is open at #24255 

@faph PR is merged. Since this will probably affect quite a few people, I'll leave a note here to other users who find this issue:

You should be able to resolve this by installing from `main` with `pip install --upgrade git+https://github.com/huggingface/transformers.git`. After our next version release, you can go back to just `pip install --upgrade transformers`. As this is a relatively serious issue we may do a hotfix release, but this is still under discussion.

Appreciate the efforts @Rocketknight1 !

Thanks for the quick bug report too @faph - our test suite wasn't checking installations with only `tensorflow-cpu`, so we never would have picked up this issue in time if you hadn't reported it!
Transformers can't detect tensorflow installed in some different path of the environment, even though the path is added to PYTHONPATH
Author: RickSanchezStoic
Pull request: no

Transformers is not able to detect tensorflow installed in different directory. 

Steps to reproduce, execute the commands in order:

`docker pull unifyai/ivy:latest`
`docker run --rm -it unifyai/ivy:latest`
 `pip install transformers`
`python`
`from transformers import TFDeiTModel`
`model = TFDeiTModel.from_pretrained("facebook/deit-base-distilled-patch16-224")`

 

Comments:
Hi @RickSanchezStoic, thanks for raising this issue! 

It seems this is a bug relating to how we detect TF being in the environment, @Rocketknight1 is opening a PR to resolve. Related issue here: #24253

Hi @RickSanchezStoic, can you confirm what you mean by "installed in a different directory" here? Do you mean that it's not installed as a library, but instead just present as a local directory in the directory you're running your code in?

@RickSanchezStoic we just merged PR #24255 based on this issue and #24253. However, it might not actually resolve your problem - can you test if the new version fixes your issue? You can install the latest version from main with `pip install --upgrade git+https://github.com/huggingface/transformers.git`

> Hi @RickSanchezStoic, can you confirm what you mean by "installed in a different directory" here? Do you mean that it's not installed as a library, but instead just present as a local directory in the directory you're running your code in?

It means when the package is installed elsewhere when you use the `--target` flag  with pip to specify a different location.

> @RickSanchezStoic we just merged PR #24255 based on this issue and #24253. However, it might not actually resolve your problem - can you test if the new version fixes your issue? You can install the latest version from main with `pip install --upgrade git+https://github.com/huggingface/transformers.git`

Sure! will check this out and report here. Thanks!

> @RickSanchezStoic we just merged PR #24255 based on this issue and #24253. However, it might not actually resolve your problem - can you test if the new version fixes your issue? You can install the latest version from main with `pip install --upgrade git+https://github.com/huggingface/transformers.git`

This worked. This is what we needed. Thanks a lot!
Skip some `TQAPipelineTests` tests in past CI
Author: ydshieh
Pull request: yes

# What does this PR do?

A continuation of #24251. `TapasModel` is used in pipeline tests (`TQAPipelineTests`) and we need torch >=12 there too.
(didn't check all failures in one go before opening PRs 😅 )

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

[8329381051](http://@googlemaps.com) 

>   #@https://github.com/huggingface/transformers/blob/fe861e578f50dc9c06de33cd361d2f625017e624/src/transformers/utils/hub.py#L734

/
```python`
#23655 [WlP] add transfer script

Comments:
Duplicate of #
TF: CTRL with native embedding layers
Author: gante
Pull request: yes

# What does this PR do?

Follows up on #23436, migrating the embedding layer of CTRL to native Keras embeddings

CTRL needed several related changes, so it deserves a stand-alone PR. This PR:
1. Replaces `TFSharedEmbeddings` by the native Keras layers
2. Fixes resized bias serialization, just like https://github.com/huggingface/transformers/pull/19013 does for BART -- in the process, gets rid of the separate LMHead class, which is outdated and tied to code scheduled for deprecation, and moves functions like `set_bias` to the right place
3. Fixes XLA issues (`prepare_inputs_for_generation` was incomplete)


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

@amyeroberts comments addressed 🙌 

I've double-checked: slow tests are passing for CTRL
Update check of core deps
Author: sgugger
Pull request: yes

# What does this PR do?

This PR updates the check of core dependencies to:
- include all of them (huggingface_hub and safetensors were not tested)
- add Accelerate since we have a lot of issues with versions mismatch, with the work done on the Trainer

cc @ydshieh one of the lines removed here concerns the Python 3.6 but you should include the equivalent for your PR to drop Python 3.7

Comments:
The docs for this PR live [here](https://moon-ci-docs.huggingface.co/docs/transformers/pr_24277). All of your documentation changes will be reflected on that endpoint.
Allow unneeded labels in forward 
Author: surya-narayanan
Pull request: no

### Feature request

It would be nice to leave in the `labels` part of my batch while passing it through `AutoModel`, and not have it throw the error `AutoModel doesn't expect keyword argument labels`

### Motivation

Sometimes i want to leave metadata in my batch, it would be nice for the model to use what it needs and leave the rest for downstream analysis. 

### Your contribution

Happy to discuss my needs and use case, and a PR if I can :) 

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.
Improvements Over `enable_progress_bar` in `transformers.utils.logging`
Author: aress31
Pull request: no

### Feature request

Would it be possible to enhance the functionality of the `tqdm` bar utilized in the [logging module](https://github.com/huggingface/transformers/blob/v4.28.1/src/transformers/utils/logging.py#L351) to provide greater flexibility and adaptability for a broader range of use cases?

### Motivation

At present, it is not feasible to track the model download progress except by employing the `tf_logging.enable_progress_bar` method, which does not support a custom `tqdm`. Moreover, the built-in `tqdm` does not flush output, causing complications in my specific use case where I am invoking my script as a child process of a node server. Consequently, the progress output fails to reach the node process before the download completes, rendering the progress bar futile. Thus, I am requesting for increased flexibility and functionality of the `tqdm` bar utilized in the logging module to cater to a wider array of scenarios.

### Your contribution

The fix would be to add a `tqdm` or `tqdm_kwargs` argument to the following method.

```python
def enable_progress_bar():
    """Enable tqdm progress bar."""
    global _tqdm_active
    _tqdm_active = True
    hf_hub_utils.enable_progress_bars()
```

Note: I have tried to set the tqdm using `tf_logging.tqdm = new_tqdm` but this seems to impact non download/progressbar type of messages which is odd...

Comments:
We do not plan on offering more than the ability to turn progress bars on and off.

What is the rational behind that?

Not offering the ability to control at least the stream where the tqdm works is hindering integration with other techs. E.g., a Node server calling a python script as subprocess.

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.
How does the decoder handle pad encodings without encoder attention mask ? 
Author: drkhan107
Pull request: no

I am trying to generate sequence using T5 decoder (not using generate function) by passing encodings and decoder input ids only. However my encoding has pad tokens as well. How is decoder able to handle those pad tokens without passing encoder attention mask. 

Here is my code

input_ids = tokenizer(seq, max_length=1024, padding='max_length', truncation=True, return_tensors="pt")
input_ids=input_ids.to(device)
encoder_output_vectors = model.base_model.encoder(input_ids['input_ids'], return_dict=True)
encodings=encoder_output_vectors.last_hidden_state

#recon is my prompt
decoder_input_ids = tokenizer("recon:", add_special_tokens=False, return_tensors="pt").input_ids
decoder_input_ids=decoder_input_ids.to(device)
decoder_hidden_state = None

    for i in range(max_len):
        with torch.no_grad():
            outputs=model.decoder(input_ids=decoder_input_ids,encoder_hidden_states=encodings)
            
            
        logits=model.lm_head(outputs[0])
        next_decoder_input_ids = torch.argmax(logits[:, -1:], axis=-1)
        decoder_input_ids = torch.cat([decoder_input_ids, next_decoder_input_ids], axis=-1)
        if next_decoder_input_ids == tokenizer.eos_token_id:
            break
                    
        
    rec=tokenizer.decode(decoder_input_ids[0], skip_special_tokens=True)

Comments:
cc @gante @younesbelkada 

Hey @drkhan107 👋 

The only alternative I see is to fine-tune the model using padded data as input and unpadded data as output, so the model learns to ignore the padding (and that may not work).

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.
Update tokenization_llama.py
Author: sjm1992st
Pull request: yes

# What does this PR do?

Fixes # (issue)
https://github.com/huggingface/transformers/issues/23175

we could see it :  https://github.com/facebookresearch/llama/blob/main/llama/generation.py
#line62: generation.py

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

cc @gante since Arthur is on holiday.

Hey @sjm1992st -- the issue in #23175 is unrelated to the tokenizer (see my comment there).

As such, without further context, I won't accept this PR :)

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.
Can you write code that trains bert with MLM and the next sentence at the same time?
Author: ingale726
Pull request: no

### Feature request

Or is there a training code already in place?

### Motivation

I've learned that training with both is better than training with mlm alone, by which I mean the generated vector features

### Your contribution

no yet

Comments:
Hi @xiao12mm, I belive the NSP loss isn't available for model training directly in huggingface. This [thread](https://discuss.huggingface.co/t/continual-pre-training-from-an-initial-checkpoint-with-mlm-and-nsp/6869) provide a script for NSP training.

About this - "training with both is better than training with mlm alone", there has been specific research done to verify the claim. One of the conclusions from "RoBERTa: A Robustly Optimized BERT Pretraining Approach" paper is that - "removing the NSP loss matches or slightly improves downstream task performance". 

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.
`Pix2StructImageProcessor` requires `torch>=1.11.0`
Author: ydshieh
Pull request: yes

# What does this PR do?

So let's be nice to past CI ❤️ !


It's the argument `antialias` in `interpolate` only supported in `torch>=1.11.0`:
```
torch.nn.functional.interpolate(..., antialias=True)
```

Comments:
_The documentation is not available anymore as the PR was closed or merged._
Add ffmpeg install for doctests
Author: amyeroberts
Pull request: yes

# What does this PR do?

`tests_pr_documentation_tests` fails if run on some docs e.g. `docs/source/en/task_summary.mdx` as ffmpeg is not installed. 

Install ffmpeg in `pr_documentation_tests` CircleCI job.

Despite trying to add changes to the code and docstrings - I was unable to trigger the tests in the CI suite for the doc tests :( 

## 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.
- [ ] 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._
__init__() got an unexpected keyword argument 'int8_threshold'
Author: DHOFM
Pull request: no

### System Info

- `transformers` version: 4.27.0.dev0
- Platform: Linux-4.15.0-177-generic-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.12.1
- PyTorch version (GPU?): 1.12.1+cu116 (True)
- Tensorflow version (GPU?): 2.10.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

also tried on Colab:
- `transformers` version: 4.27.0.dev0
- Platform: Linux-5.10.147+-x86_64-with-glibc2.29
- Python version: 3.8.10
- Huggingface_hub version: 0.12.1
- PyTorch version (GPU?): 1.13.1+cu116 (True)
- Tensorflow version (GPU?): 2.11.0 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Using GPU in script?: yes
- Using distributed or parallel set-up in script?: no

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [X] 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

Taken from Notebook named: HuggingFace meets bitsandbytes for lighter models on GPU for inference

```
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

name = "bigscience/bloom-3b"
model_8bit_thresh_4 = AutoModelForCausalLM.from_pretrained(name, device_map="auto", load_in_8bit=True, int8_threshold=4.0)

```
Error is: TypeError: __init__() got an unexpected keyword argument 'int8_threshold'

### Expected behavior

No error setting threshold

Comments:
You need to use the `quantization_config` to set any argument relative to 8bit loading, cc @younesbelkada 

Thanks, I tried and get : dispatch_model() got an unexpected keyword argument 'offload_index'... I thought offloading to cpu is default false?

i use
`quantization_config = BitsAndBytesConfig(llm_int8_threshold=4.0)`

and 

```
model_8bit = AutoModelForCausalLM.from_pretrained(
    model_id,
    device_map=device_map,
    quantization_config=quantization_config,
)
```

device_map is auto

You probably need an upgrade in your Accelerate lib to fix this error.

Mea culpa, I used one of my old Containers on my GPU Server, upgraded accelerate and it works as expected... Thanks a lot for your fast support

Even i upgraded the accelerate, it is throwing me the same error @DHOFM can you please tell me what version of accelerate are you using in your container?
cannot import name 'TextIteratorStreamer' from 'transformers'
Author: benam2
Pull request: no

### System Info

Hi 
My code raises error when I want to import `TextIteratorStreamer`
`from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer`

I have transformer installed !pip install --upgrade transformers in databricks.

If it helps this code runs successfully:
python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I love you'))"

Appreciate your input and help.

### Who can help?

 @ArthurZucker and @younesbelkada


### Expected behavior
Just run without error

Comments:
Add SPTSv2
Author: NielsRogge
Pull request: no
Labels: name: New model

### Model description

SPTSv2 is the latest SOTA text spotting model from Bytedance. Given that we already support DETR, should be a breeze to support this model as well.

SPTSv2 is an improvement over the first version: https://github.com/shannanyinxiang/SPTS.

### Open source status

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

### Provide useful links for the implementation

https://github.com/bytedance/SPTSv2

Comments:
Hi @NielsRogge can I please contribute this model?
Fix bug in slow tokenizer conversion, make it a lot faster
Author: stephantul
Pull request: yes

# What does this PR do?

The slow tokenizer conversion currently has a bug where merges with a score of 0 do not get used due to an erroneous check. The check simply tested truthiness, but was actually looking for a `None`. During fixing, I noticed that the code was also slow, so I made it a lot faster.

Fixes #24233

## 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.
- [ ] 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.

@ArthurZucker 


Comments:
Speed info: the new implementation takes 70 ms, the old one took 123 seconds for the `openlm-research/open_llama_7b` tokenizer mentioned in the issue.

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

> Really nice fix and improvement - thanks for working on this ❤️
> 
> Logic all looks good to me. There's a test that's failing, but it's decorated with `@is_flaky` so shouldn't be preventing CI being green here. @ydshieh any insights into what might be happening?

@amyeroberts 

`is_flacky()` won't keep the test green 100%. It just runs the test a few times (default `5`) 😿 . The failing is still expected but less frequently.

Sorry for the weird error. I forgot to re-run tests after the second commit
Fix `check_config_attributes`: check all configuration classes
Author: ydshieh
Pull request: yes

# What does this PR do?

As @NielsRogge points out to me, the `check_config_attributes` doesn't check all configuration classes (to make sure all `__init__` arguments are really used).

This is because `CONFIG_MAPPING` doesn't contain all configuration classes, in particular, the vision/text config classes for models like Blip2 or CLIP.

This PR fixes this issue, and remove some unused arguments/attributes in some configuration classes.

Comments:
_The documentation is not available anymore as the PR was closed or merged._
DetrAttention `is_decoder` is not defined
Author: JayL0321
Pull request: no

https://github.com/huggingface/transformers/blob/fe861e578f50dc9c06de33cd361d2f625017e624/src/transformers/models/detr/modeling_detr.py#LL502C9-L502C19

The `is_decoder` parameter is in the init function, but it is not reference in the body. While in `DetrDecoderLayer`, this parameter is initialized as `True`. Very confused, not sure whether there's something missing in `DetrAttention`. 

Comments:
cc @NielsRogge 

Yes, seems like a left-over from copying from another model. Feel free to open a PR to remove the `is_decoder` parameter