{"record":{"id":"bd8100a7e268d9fd","repo":"keras-team/keras","slug":"ngrams-must-be-none-an-integer-or-a-tuple-of-i","errorCode":null,"errorMessage":"`ngrams` must be None, an integer, or a tuple of integers. Received: ngrams={ngrams}","messagePattern":"`ngrams` must be None, an integer, or a tuple of integers\\. Received: ngrams=(.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"keras/src/layers/preprocessing/text_vectorization.py","lineNumber":294,"sourceCode":"            allowable_strings=(\n                \"int\",\n                \"one_hot\",\n                \"multi_hot\",\n                \"count\",\n                \"tf_idf\",\n            ),\n            caller_name=self.__class__.__name__,\n            arg_name=\"output_mode\",\n        )\n\n        # 'ngrams' must be one of (None, int, tuple(int))\n        if not (\n            ngrams is None\n            or isinstance(ngrams, int)\n            or isinstance(ngrams, tuple)\n            and all(isinstance(item, int) for item in ngrams)\n        ):\n            raise ValueError(\n                \"`ngrams` must be None, an integer, or a tuple of \"\n                f\"integers. Received: ngrams={ngrams}\"\n            )\n\n        # 'output_sequence_length' must be one of (None, int) and is only\n        # set if output_mode is \"int\"\".\n        if output_mode == \"int\" and not (\n            isinstance(output_sequence_length, int)\n            or (output_sequence_length is None)\n        ):\n            raise ValueError(\n                \"`output_sequence_length` must be either None or an \"\n                \"integer when `output_mode` is 'int'. Received: \"\n                f\"output_sequence_length={output_sequence_length}\"\n            )\n\n        if output_mode != \"int\" and output_sequence_length is not None:\n            raise ValueError(","sourceCodeStart":276,"sourceCodeEnd":312,"githubUrl":"https://github.com/keras-team/keras/blob/7a34a03db60bf60042242d6a556fc3be119046a5/keras/src/layers/preprocessing/text_vectorization.py#L276-L312","documentation":"Error \"`ngrams` must be None, an integer, or a tuple of integers. Received: ngrams={ngrams}\" thrown in keras-team/keras.","triggerScenarios":"Thrown at keras/src/layers/preprocessing/text_vectorization.py:294 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7a34a03db60bf60042242d6a556fc3be119046a5","analyzedAt":"2026-08-25T21:25:25.994Z","schemaVersion":2},"datasetVersion":"2026-08-26T02:17:13.382Z"}