Skip to content

Commit 26bed8d

Browse files
kaixuanliuydshieh
authored andcommitted
adjust input and output texts for test_modeling_recurrent_gemma.py (huggingface#39190)
* adjust input and output texts for test_modeling_recurrent_gemma.py Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * fix bug Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * adjust Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * update Expectation match Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> * fix --------- Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com> Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
1 parent d45273f commit 26bed8d

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

tests/models/recurrent_gemma/test_modeling_recurrent_gemma.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
from transformers import AutoModelForCausalLM, AutoTokenizer, RecurrentGemmaConfig, is_torch_available, set_seed
2222
from transformers.testing_utils import (
23+
Expectations,
2324
require_bitsandbytes,
2425
require_read_token,
2526
require_torch,
@@ -215,20 +216,30 @@ def test_2b_generate(self):
215216
@require_read_token
216217
def test_2b_sample(self):
217218
set_seed(0)
218-
EXPECTED_TEXT = ['Where is Paris ?\n\nChoose the word or phrase that is closest in meaning to the word in capital letters.\n\nREDEEM\n(A) sort out\n(B) think over\n(C) turn in\n(D) take back\n\nWrite the correct word in the space next to each definition. Use each word only once.\n\nto badly damage\n\nOn the lines provided below, write <em>P</em> if the underlined word group is a phrase and <em>NP</em> if it is not a phrase. Example $\\underline{\\text{P}}$ 1. We have finally discovered the secret $\\underline{\\text{of delicious pizza. }}$'] # fmt: skip
219+
expectations = Expectations(
220+
{
221+
(None, None): [
222+
"What is Deep learning ?\n\nDeep learning is the next frontier in computer vision. It is an Artificial Intelligence (AI) discipline that is rapidly being adopted across industries. The success of Deep"
223+
],
224+
("cuda", 8): [
225+
"What is Deep learning ?\n\nDeep learning is the next frontier in computer vision, it’s an incredibly powerful branch of artificial intelligence.\n\nWhat is Dalle?\n\nDalle is",
226+
],
227+
}
228+
)
229+
EXPECTED_TEXT = expectations.get_expectation()
219230
model = AutoModelForCausalLM.from_pretrained(self.model_id).to(torch_device)
220231

221232
tokenizer = AutoTokenizer.from_pretrained(self.model_id)
222-
inputs = tokenizer("Where is Paris ?", return_tensors="pt", padding=True).to(torch_device)
223-
output = model.generate(**inputs, max_new_tokens=128, do_sample=True)
233+
inputs = tokenizer("What is Deep learning ?", return_tensors="pt", padding=True).to(torch_device)
234+
output = model.generate(**inputs, max_new_tokens=32, do_sample=True)
224235
output_text = tokenizer.batch_decode(output, skip_special_tokens=True)
225236

226237
self.assertEqual(output_text, EXPECTED_TEXT)
227238

228239
@require_bitsandbytes
229240
@require_read_token
230241
def test_model_2b_8bit(self):
231-
EXPECTED_TEXTS = ['Hello I am doing a project on the topic of "The impact of the internet on the society" and I am looking', "Hi today I'm going to show you how to make a simple and easy to make a simple and easy"] # fmt: skip
242+
EXPECTED_TEXTS = ['Hello I am doing a project on the topic of "The impact of social media on the society" and I am looking', "Hi today I'm going to show you how to make a simple and easy to make a 3D"] # fmt: skip
232243

233244
model = AutoModelForCausalLM.from_pretrained(
234245
"gg-hf/recurrent-gemma-2b-hf", device_map={"": torch_device}, load_in_8bit=True, torch_dtype=torch.bfloat16

0 commit comments

Comments
 (0)