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/parrot_fluency_model_onnx')
7model = ORTModelForSequenceClassification.from_pretrained('Deepchecks/parrot_fluency_model_onnx')
8
9# prepare the pipeline and generate inferences
10user_inputs = ['Natural language processing is an interdisciplinary subfield of linguistics, computer science, and artificial intelligence.',
11 'Pass on what you have learned. Strength, mastery, hmm… but weakness, folly, failure, also. Yes, failure, most of all. The greatest teacher, failure is.',
12 'Whispering dreams, forgotten desires, chaotic thoughts, dance with words, meaning elusive, swirling amidst.']
13pip = pipeline(task='text-classification', model=model, tokenizer=tokenizer, device=device, accelerator="ort")
14res = pip(user_inputs, batch_size=64, truncation="only_first")
15