我在这里关注本教程:https ://huggingface.co/transformers/training.html - 不过,我遇到了一个错误,我认为本教程缺少导入,但我不知道是哪个。
这些是我目前的进口:
# Transformers installation
! pip install transformers
# To install from source instead of the last release, comment the command above and uncomment the following one.
# ! pip install git+https://github.com/huggingface/transformers.git
! pip install datasets transformers
from transformers import pipeline
当前代码:
from datasets import load_dataset
raw_datasets = load_dataset("imdb")
from transformers import AutoTokenizer
tokenizer = AutoTokenizer.from_pretrained("bert-base-cased")
inputs = tokenizer(sentences, padding="max_length", truncation=True)
错误:
NameError Traceback (most recent call last)
<ipython-input-9-5a234f114e2e> in <module>()
----> 1 inputs = tokenizer(sentences, padding="max_length", truncation=True)
NameError: name 'sentences' is not defined