NoneType is not callable.

#1
by eastwind - opened
File <command-2149863258257856>:12
      2 from transformers import pipeline
      4 generate_text = pipeline(
      5     model="h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b",
      6     torch_dtype=torch.float16,
   (...)
      9     device_map = 'auto',
     10 )
---> 12 res = generate_text(
     13     "What is quantum tunnelling",
     14     min_new_tokens=2,
     15     max_new_tokens=1024,
     16     do_sample=False,
     17     num_beams=1,
     18     temperature=float(0.3),
     19     repetition_penalty=float(1.2),
     20     renormalize_logits=True
     21 )
     22 print(res[0]["generated_text"])

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/transformers/pipelines/text_generation.py:201, in TextGenerationPipeline.__call__(self, text_inputs, **kwargs)
    160 def __call__(self, text_inputs, **kwargs):
    161     """
    162     Complete the prompt(s) given as inputs.
    163 
   (...)
    199           ids of the generated text.
    200     """
--> 201     return super().__call__(text_inputs, **kwargs)

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/transformers/pipelines/base.py:1119, in Pipeline.__call__(self, inputs, num_workers, batch_size, *args, **kwargs)
   1111     return next(
   1112         iter(
   1113             self.get_iterator(
   (...)
   1116         )
   1117     )
   1118 else:
-> 1119     return self.run_single(inputs, preprocess_params, forward_params, postprocess_params)

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/transformers/pipelines/base.py:1125, in Pipeline.run_single(self, inputs, preprocess_params, forward_params, postprocess_params)
   1124 def run_single(self, inputs, preprocess_params, forward_params, postprocess_params):
-> 1125     model_inputs = self.preprocess(inputs, **preprocess_params)
   1126     model_outputs = self.forward(model_inputs, **forward_params)
   1127     outputs = self.postprocess(model_outputs, **postprocess_params)

File ~/.cache/huggingface/modules/transformers_modules/h2oai/h2ogpt-gm-oasst1-multilang-2048-falcon-7b/d5781acb7c1b1af6437449a28d8302acbcd08404/h2oai_pipeline.py:16, in H2OTextGenerationPipeline.preprocess(self, prompt_text, prefix, handle_long_generation, **generate_kwargs)
     12 def preprocess(
     13     self, prompt_text, prefix="", handle_long_generation=None, **generate_kwargs
     14 ):
     15     prompt_text = self.prompt.format(instruction=prompt_text)
---> 16     return super().preprocess(
     17         prompt_text,
     18         prefix=prefix,
     19         handle_long_generation=handle_long_generation,
     20         **generate_kwargs,
     21     )

File /local_disk0/.ephemeral_nfs/cluster_libraries/python/lib/python3.10/site-packages/transformers/pipelines/text_generation.py:204, in TextGenerationPipeline.preprocess(self, prompt_text, prefix, handle_long_generation, **generate_kwargs)
    203 def preprocess(self, prompt_text, prefix="", handle_long_generation=None, **generate_kwargs):
--> 204     inputs = self.tokenizer(
    205         prefix + prompt_text, padding=False, add_special_tokens=False, return_tensors=self.framework
    206     )
    207     inputs["prompt_text"] = prompt_text
    209     if handle_long_generation == "hole":

TypeError: 'NoneType' object is not callable

I thought it was sentencepiece but the error still exists

H2O.ai org

Thank you for reporting @eastwind

Please try the updated pipeline from the model card. Falcon needs the tokenizer to be explicitly passed to the pipeline.

Thanks so much. This fixed it

eastwind changed discussion status to closed

Sign up or log in to comment