hf_mirrors/distilroberta-base-rejection-v1
Model Introduction
Files & versions
Analysis

Model Card for distilroberta-base-rejection-v1

It aims to identify rejections in LLMs when the prompt doesn't pass content moderation, classifying inputs into two categories: 0 for normal outputs and 1 for rejection detected.

It achieves the following results on the evaluation set:

  • Loss: 0.0544
  • Accuracy: 0.9887
  • Recall: 0.9810
  • Precision: 0.9279
  • F1: 0.9537

Intended Uses & Limitations

It aims to identify rejection, classifying inputs into two categories: 0 for normal output and 1 for rejection detected.

The model's performance is dependent on the nature and quality of the training data. It might not perform well on text styles or topics not represented in the training set.

Additionally, distilroberta-base is case-sensitive model.

How to Get Started with the Model

Transformers


import argparse
import torch
import numpy as np
from openmind import pipeline, is_torch_npu_available
from openmind import AutoTokenizer, AutoModelForSequenceClassification, pipeline

def parse_args():
    parser = argparse.ArgumentParser(description="Eval the model")
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="path or model",
        default="ChongqingAscend/distilroberta-base-rejection-v1",
    )
    args = parser.parse_args()
    return args


def main():
    args = parse_args()
    model_path = args.model_name_or_path
    device = "npu" if is_torch_npu_available()  else  "cpu"
    tokenizer = AutoTokenizer.from_pretrained(model_path)
    model = AutoModelForSequenceClassification.from_pretrained(model_path)
    
    classifier = pipeline(
      "text-classification",
      model=model,
      tokenizer=tokenizer,
      truncation=True,
      max_length=512,
      device=device,
    )
    
    print(classifier("Sorry, but I can't assist with that."))

if __name__ == "__main__":
    main()