1import onnxruntime as ort
2import numpy as np
3from transformers import AutoTokenizer
4
5# Load the tokenizer
6tokenizer = AutoTokenizer.from_pretrained("CohenQu/DeepSeek-R1-Distill-Qwen-7B-GRPO")
7
8# Load the ONNX model
9onnx_model_path = "model.onnx" # Path to your ONNX model
10session = ort.InferenceSession(onnx_model_path)
11question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
12inputs = tokenizer(question, return_tensors="np", padding=True)
13output = session.run(
14 None, # Output names can be None to get all outputs
15 {'input_ids': inputs['input_ids'],'attention_mask': inputs['attention_mask']}
16)[0]
17generated_text = tokenizer.decode(np.argmax(output, axis=-1)[0], skip_special_tokens=True)
18print("Generated Text:", generated_text)