question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`if not something` is ambiguous

See original GitHub issue

System Info

  • transformers version: 4.22.0
  • Platform: Linux-4.19.157-1.20201118.el7.x86_64-x86_64-with-glibc2.17
  • Python version: 3.8.3
  • Huggingface_hub version: 0.9.1
  • PyTorch version (GPU?): 1.10.2+cu111 (True)
  • Tensorflow version (GPU?): 2.10.0 (True)
  • Flax version (CPU?/GPU?/TPU?): 0.6.0 (gpu)
  • Jax version: 0.3.17
  • JaxLib version: 0.3.15
  • Using GPU in script?: YES
  • Using distributed or parallel set-up in script?: NO

GPU device: A100 x 1

Who can help?

@SaulLu

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

I run the following code https://github.com/huggingface/transformers/blob/main/examples/flax/language-modeling/run_mlm_flax.py#L296 and an error occurs here: https://github.com/huggingface/transformers/blob/2c8b508ccabea6638aa463a137852ff3b64be036/src/transformers/tokenization_utils_base.py#L2907

My required_input is a tensor (in jax), sometimes I get error ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all().

Expected behavior

https://github.com/huggingface/transformers/blob/2c8b508ccabea6638aa463a137852ff3b64be036/src/transformers/tokenization_utils_base.py#L2907

I suggest to use if required_input is None instead of if not required_input to avoid error, as the latter one is ambiguous.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
sguggercommented, Oct 21, 2022

Sorry this slipped through the cracks. Very much in agreeance here @lsz05 and this is one of the reason we usually avoid relying on Python magic bool conversion but test for explicit values. Would you mind making a PR with a fix?

0reactions
github-actions[bot]commented, Dec 10, 2022

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 are likely to be ignored.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is the phrase "if not" really as ambiguous as I think? - Reddit
It's all about possibility. Expressions using "if not" do not mean two opposite things. What they mean is that it is possible —...
Read more >
If not, why not? - The Grammarphobia Blog
Bernstein, another usage authority, says “if not” is “usually perfectly clear in spoken language,” though it becomes “a tantalizing ambiguity” ...
Read more >
Don't use this ambiguous, if not totally flummoxing construction.
With the “it's X, if not Y” formula, ambiguity is built right into the word “if.” That conjunction exists to help us describe...
Read more >
Ambiguous Definition & Meaning - Merriam-Webster
The meaning of AMBIGUOUS is doubtful or uncertain especially from obscurity or indistinctness. How to use ambiguous in a sentence.
Read more >
"All X are not made equal" - ambiguous meaning?
This would be commonly understood by most English speakers to mean the following sentence, which is what I'd use: Well, this car is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found