SimpleTransformers Error: VersionConflict: tokenizers==0.9.4? How do I fix this?

SimpleTransformers Error: VersionConflict: tokenizers==0.9.4? How do I fix this?

我正在尝试从他们在 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 is required for a normal functioning of this module, but found tokenizers==0.10.0. Try: pip install transformers -U or pip install -e '.[dev]' if you're working with git master

我试过 !pip install transformers -U 甚至 !pip install tokenizers==0.9.4 但总是报同样的错误。 我以前执行过这段代码,它工作得很好,但现在它给出了提到的错误。

我把它放在这里以防有人遇到同样的问题。 得到了作者本人的帮助。

Workaround:
Install tokenizers==0.9.4 before install simpletransformers

In Colab for example;

!pip install tokenizers==0.9.4
!pip install simpletransformers

https://github.com/ThilinaRajapakse/simpletransformers/issues/950

如上所述,我认为您基本上只需要 !pip install tokenizers==0.9.4,它将卸载 tokenizers-0.10.0 并安装 tokenizers-0.9.4