模型:

davidmasip/racism

英文

预测一个给定文本是否是种族主义的模型:

  • LABEL_0 输出表示非种族主义文本
  • LABEL_1 输出表示种族主义文本

用法:

from transformers import pipeline

RACISM_MODEL = "davidmasip/racism"
racism_analysis_pipe = pipeline("text-classification",
                                model=RACISM_MODEL, tokenizer=RACISM_MODEL)

results = racism_analysis_pipe("Unos menas agreden a una mujer.")


def clean_labels(results):
    for result in results:
        label = "Non-racist" if results["label"] == "LABEL_0" else "Racist"
        result["label"] = label


clean_labels(results)
print(results)