@@ -139,8 +139,9 @@ def test_text_generation_phi4_mini(self):
139139 import torch
140140 from transformers import RobertaTokenizer , T5ForConditionalGeneration
141141
142- tokenizer = RobertaTokenizer .from_pretrained ("microsoft/Phi-4-mini-instruct" )
143- model = T5ForConditionalGeneration .from_pretrained ("microsoft/Phi-4-mini-instruct" )
142+ model_id = "microsoft/Phi-4-mini-instruct"
143+ tokenizer = RobertaTokenizer .from_pretrained (model_id )
144+ model = T5ForConditionalGeneration .from_pretrained (model_id )
144145
145146 text = "def greet(user): print(f'hello <extra_id_0>!')"
146147 input_ids = tokenizer (text , return_tensors = "pt" ).input_ids
@@ -158,6 +159,41 @@ def test_text_generation_phi4_mini(self):
158159 )
159160 print (tokenizer .decode (generated_ids [0 ], skip_special_tokens = True ))
160161
162+ @never_test ()
163+ def test_text_generation_phi3_mini (self ):
164+ # clear&&NEVERTEST=1 python _unittests/ut_tasks/try_tasks.py -k phi3_mini
165+
166+ from transformers import Phi3ForCausalLM , AutoTokenizer
167+
168+ model_id = "microsoft/Phi-3-mini-4k-instruct"
169+ tokenizer = AutoTokenizer .from_pretrained (model_id )
170+ model = Phi3ForCausalLM .from_pretrained (model_id )
171+
172+ messages = [
173+ {
174+ "role" : "system" ,
175+ "content" : (
176+ "You are a helpful digital assistant. Please provide safe, "
177+ "ethical and accurate information to the user."
178+ ),
179+ },
180+ {
181+ "role" : "user" ,
182+ "content" : (
183+ "Can you provide ways to eat combinations of bananas and dragonfruits?"
184+ ),
185+ },
186+ ]
187+ inputs = tokenizer .apply_chat_template (
188+ messages , add_generation_prompt = True , return_tensors = "pt"
189+ )
190+
191+ # simply generate a single sequence
192+ print ()
193+ with steal_forward (model ):
194+ generated_ids = model .generate (inputs , max_length = 100 )
195+ print (tokenizer .decode (generated_ids [0 ], skip_special_tokens = True ))
196+
161197 @never_test ()
162198 @unittest .skip (
163199 reason = "AttributeError: 'Phi4MMModel' object has no attribute "
0 commit comments