Views
No views yet
pip install optimum[onnxruntime-gpu]1from transformers import AutoTokenizer
2from optimum.onnxruntime import ORTModelForSequenceClassification
3from optimum.pipelines import pipeline
4
5# load tokenizer and model weights
6tokenizer = AutoTokenizer.from_pretrained('Deepchecks/roberta_base_formality_ranker_onnx')
7model = ORTModelForSequenceClassification.from_pretrained('Deepchecks/roberta_base_formality_ranker_onnx')
8
9# prepare the pipeline and generate inferences
10user_inputs = ["I hope this email finds you well", "I hope this email find you swell", "What's up doc?"]
11pip = pipeline(task='text-classification', model=model, tokenizer=tokenizer, device=device, accelerator="ort")
12res = pip(user_inputs, batch_size=64, truncation="only_first")
13