天天看點

transformers.tokenization_utils_base

1.問題描述:

在使用Transformer或者SentenceTransformer時有時會遇到如下警告,甚是惱火!!!

2.錯誤:

WARNING:transformers.tokenization_utils_base:Truncation was not explicitely activated but

max_length

is provided a specific value, please use

truncation=True

to explicitely truncate examples to max length. Defaulting to ‘longest_first’ truncation strategy. If you encode pairs of sequences (GLUE-style) with the tokenizer you can select this strategy more precisely by providing a specific strategy to

truncation

.

3.解決方法:

import logging
logging.basicConfig(level=logging.ERROR)
           

4.特殊情況

當使用的是jupter notebook,添加完代碼需要重新開機服務才可以哦!

如果恰好解決了你的問題的話,麻煩點個贊呗O(∩_∩)O。

繼續閱讀