我正在尝试从他们在 google colab 上的网站执行 simpletransformers 示例。
例子:
from simpletransformers.classification import ClassificationModel, ClassificationArgs
import pandas as pd
import logging
logging.basicConfig(level=logging.INFO)
transformers_logger = logging.getLogger("transformers")
transformers_logger.setLevel(logging.WARNING)
# Preparing train data
train_data = [
["Aragorn was the heir of Isildur", 1],
["Frodo was the heir of Isildur", 0],
]
train_df = pd.DataFrame(train_data)
train_df.columns = ["text", "labels"]
# Preparing eval data
eval_data = [
["Theoden was the king of Rohan", 1],
["Merry was the king of Rohan", 0],
]
eval_df = pd.DataFrame(eval_data)
eval_df.columns = ["text", "labels"]
# Optional model configuration
model_args = ClassificationArgs(num_train_epochs=1)
# Create a ClassificationModel
model = ClassificationModel(
"roberta", "roberta-base", args=model_args
)
# Train the model
model.train_model(train_df)
# Evaluate the model
result, model_outputs, wrong_predictions = model.eval_model(eval_df)
# Make predictions with the model
predictions, raw_outputs = model.predict(["Sam was a Wizard"])
但它给了我以下错误:
VersionConflict:tokenizers==0.9.4 是该模块正常运行所必需的,但发现 tokenizers==0.10.0。尝试: pip install transformers -U 或 pip install -e '.[dev]' 如果你正在使用 git master
我已经尝试过!pip install transformers -U
,甚至!pip install tokenizers==0.9.4
仍然出现同样的错误。我之前已经执行过这段代码,它的工作很有趣,但现在它给出了提到的错误。