File tree 1 file changed +4
-6
lines changed
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -53,12 +53,10 @@ from transformers import AutoTokenizer
53
53
- from transformers import AutoModelForCausalLM
54
54
+ from optimum.intel.ipex import IPEXModelForCausalLM
55
55
56
- - model = AutoModelForCausalLM.from_pretrained(
57
- + model = IPEXModelForCausalLM.from_pretrained(
58
- "gpt2",
59
- torch_dtype=torch.bfloat16,
60
- export=True,
61
- )
56
+
57
+ model_id = "gpt2"
58
+ - model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16)
59
+ + model = IPEXModelForCausalLM.from_pretrained(model_id, torch_dtype=torch.bfloat16, export=True)
62
60
tokenizer = AutoTokenizer.from_pretrained("gpt2")
63
61
input_sentence = ["Answer the following yes/no question by reasoning step-by-step please. Can you write a whole Haiku in a single tweet?"]
64
62
model_inputs = tokenizer(input_sentence, return_tensors="pt")
You can’t perform that action at this time.
0 commit comments