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:
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.
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()