我正试图从google的网站上执行简单变压器示例。
示例:
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安装变压器-U或pip安装-e '.dev‘如果您正在使用git
我已经尝试过!pip install transformers -U,甚至!pip install tokenizers==0.9.4,但是仍然给出了同样的错误。我以前执行过这段代码,它的工作非常有趣,但是现在它给出了前面提到的错误。
发布于 2021-01-29 13:12:36
我把这个放在这里,以防有人面临同样的问题。我是由造物主自己帮助的。
解决方案:例如,在Colab中安装简单变压器之前安装tokenizers==0.9.4;!pip安装tokenizers==0.9.4 !pip安装简单变压器
https://github.com/ThilinaRajapakse/simpletransformers/issues/950
发布于 2022-01-12 14:42:38
如上所述,我认为您基本上需要的是!pip install tokenizers==0.9.4,它将卸载tokenizers-0.10.0并安装tokenizers-0.9.4。
https://stackoverflow.com/questions/65924090
复制相似问题