How to suppress warning "Be aware, overflowing tokens are not returned"

526 views Asked by At

I am using NewsSentiment, a targeted sentiment analysis library for Python. It is (too) occasionally throwing the warning:

Be aware, overflowing tokens are not returned for the setting you have chosen, i.e. sequence pairs with the 'longest_first' truncation strategy. So the returned list will always be empty even if some tokens have been removed.

I have done some research and this appears to be issued by a huggingface transformer, and the library does have a Roberta dependency. However, I do not invoke Roberta in my code so I'm not sure how to suppress the warning. I have tried

warnings.filterwarnings("ignore", message="Be aware, overflowing tokens are not returned for the setting you have chosen, i.e. sequence pairs with the 'longest_first' truncation strategy. So the returned list will always be empty even if some toke")
warnings.filterwarnings("ignore", category=UserWarning, module='transformers')

But neither does the job. Anyone know how to do it?

1

There are 1 answers

0
Kamlesh Kumar On

Use this code snippet to get rid of this warning.

import logging
logging.disable(logging.WARNING)