diff --git a/tests/models/chatglm/test_modeling_chatglm.py b/tests/models/chatglm/test_modeling_chatglm.py index 88454cfd6de857..0f0c0443f558c6 100644 --- a/tests/models/chatglm/test_modeling_chatglm.py +++ b/tests/models/chatglm/test_modeling_chatglm.py @@ -484,85 +484,3 @@ def test_model_13b_greedy_generation(self): generated_ids = model.generate(input_ids, max_new_tokens=64, top_p=None, temperature=1, do_sample=False) text = tokenizer.decode(generated_ids[0], skip_special_tokens=True) self.assertEqual(EXPECTED_TEXT_COMPLETION, text) - - -@require_torch -class CodeChatGlmIntegrationTest(unittest.TestCase): - PROMPTS = [ - '''def remove_non_ascii(s: str) -> str: - """ - return result -''', - """# Installation instructions: - ```bash - - ``` -This downloads the ChatGLM inference code and installs the repository as a local pip package. -""", - """class InterfaceManagerFactory(AbstractManagerFactory): - def __init__( -def main(): - factory = InterfaceManagerFactory(start=datetime.now()) - managers = [] - for i in range(10): - managers.append(factory.build(id=i)) -""", - """/-- A quasi-prefunctoid is 1-connected iff all its etalisations are 1-connected. -/ -theorem connected_iff_etalisation [C D : precategoroid] (P : quasi_prefunctoid C D) : -π₁ P = 0 ↔ = 0 := -begin -split, -{ intros h f, - rw pi_1_etalisation at h, - simp [h], - refl -}, -{ intro h, - have := @quasi_adjoint C D P, - simp [←pi_1_etalisation, this, h], - refl -} -end -""", - ] - - @require_torch_accelerator - @slow - def test_model_7b_logits(self): - model = ChatGlmForCausalLM.from_pretrained("codechatglm/CodeChatGlm-7b-hf").to(torch_device) - tokenizer = CodeLlamaTokenizer.from_pretrained("codechatglm/CodeChatGlm-7b-hf") - # Tokenize and prepare for the model a list of sequences or a list of pairs of sequences. - # meaning by default this supports passing splitted list of inputs - processed_text = tokenizer.batch_decode(tokenizer(self.PROMPTS)["input_ids"], add_special_tokens=False) - # fmt: off - EXPECTED_TEXT = [ - '
 def remove_non_ascii(s: str) -> str:\n    """  \n    return result\n ',
-            ' 
 # Installation instructions:\n    ```bash\n \n    ```\nThis downloads the ChatGLM inference code and installs the repository as a local pip package.\n ',
-            ' 
 class InterfaceManagerFactory(AbstractManagerFactory):\n    def __init__( \ndef main():\n    factory = InterfaceManagerFactory(start=datetime.now())\n    managers = []\n    for i in range(10):\n        managers.append(factory.build(id=i))\n ',
-            ' 
 /-- A quasi-prefunctoid is 1-connected iff all its etalisations are 1-connected. -/\ntheorem connected_iff_etalisation [C D : precategoroid] (P : quasi_prefunctoid C D) :\nπ₁ P = 0 ↔   = 0 :=\nbegin\nsplit,\n{ intros h f,\n    rw pi_1_etalisation at h,\n    simp [h],\n    refl\n},\n{ intro h,\n    have := @quasi_adjoint C D P,\n    simp [←pi_1_etalisation, this, h],\n    refl\n}\nend\n '
-        ]
-        # fmt: on
-        self.assertEqual(processed_text, EXPECTED_TEXT)
-        processed_text_suffix_first = tokenizer.batch_decode(
-            tokenizer(self.PROMPTS, suffix_first=True, add_special_tokens=False)["input_ids"]
-        )
-
-        # fmt: off
-        EXPECTED_TEXT = [
-            '
 \n    return result\n  def remove_non_ascii(s: str) -> str:\n    """ ',
-            '
 \n    ```\nThis downloads the ChatGLM inference code and installs the repository as a local pip package.\n  # Installation instructions:\n    ```bash\n',
-            '
 \ndef main():\n    factory = InterfaceManagerFactory(start=datetime.now())\n    managers = []\n    for i in range(10):\n        managers.append(factory.build(id=i))\n  class InterfaceManagerFactory(AbstractManagerFactory):\n    def __init__(',
-            '
  = 0 :=\nbegin\nsplit,\n{ intros h f,\n    rw pi_1_etalisation at h,\n    simp [h],\n    refl\n},\n{ intro h,\n    have := @quasi_adjoint C D P,\n    simp [←pi_1_etalisation, this, h],\n    refl\n}\nend\n  /-- A quasi-prefunctoid is 1-connected iff all its etalisations are 1-connected. -/\ntheorem connected_iff_etalisation [C D : precategoroid] (P : quasi_prefunctoid C D) :\nπ₁ P = 0 ↔ '
-        ]
-        EXPECTED_IDS = torch.tensor([[    1, 32007, 822, 3349, 29918, 5464, 29918, 294, 18869, 29898,29879, 29901, 851, 29897, 1599, 851, 29901, 13, 1678, 9995, 29871, 32008, 13, 1678, 736, 1121, 13, 32009, 15941, 1661, 29899, 28599, 2687, 4890, 515, 263, 1347, 29889, 13, 13, 1678, 826, 3174, 29901, 13, 4706, 269, 29901, 450, 1347, 304, 3349, 1661, 29899, 28599, 2687, 4890, 515, 29889, 13, 13, 1678, 16969, 29901, 13, 4706, 450, 1347, 411, 1661, 29899, 28599, 2687, 4890, 6206, 29889, 13, 1678, 9995, 13, 1678, 1121, 353, 5124, 13, 1678, 363, 274, 297, 269, 29901, 13, 4706, 565, 4356, 29898, 29883, 29897, 529, 29871, 29896, 29906, 29947, 29901, 13, 9651, 1121, 4619, 274, 32010, 2]])
-        # fmt: on
-        self.assertEqual(processed_text_suffix_first, EXPECTED_TEXT)
-        input_ids = tokenizer(self.PROMPTS[0], return_tensors="pt")["input_ids"]
-        generated_ids = model.generate(input_ids.to(torch_device), max_new_tokens=128)
-        torch.testing.assert_close(generated_ids, EXPECTED_IDS)
-
-        EXPECTED_INFILLING = [
-            ' 
 def remove_non_ascii(s: str) -> str:\n    """  \n    return result\n Remove non-ASCII characters from a string.\n\n    Args:\n        s: The string to remove non-ASCII characters from.\n\n    Returns:\n        The string with non-ASCII characters removed.\n    """\n    result = ""\n    for c in s:\n        if ord(c) < 128:\n            result += c '
-        ]
-        infilling = tokenizer.batch_decode(generated_ids)
-        self.assertEqual(infilling, EXPECTED_INFILLING)