Hugging Face transformer – 对象不可调用

huangapple go评论87阅读模式
英文:

Hugging Face transformer - object not callable

问题

我正在尝试使用Hugging Face的T5转换器制作文本摘要器。

我从Hugging Face的网站上运行以下代码:

from transformers import T5Tokenizer, T5Model

tokenizer = T5Tokenizer.from_pretrained("t5-small")
model = T5Model.from_pretrained("t5-small")

在此之前,我使用pip安装了transformers、sentencepiece和datasets transformers[sentencepiece]。

当我运行它时,我收到以下错误信息:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [9], line 2
      1 # Load the T5 model and tokenizer
----> 2 tokenizer = T5Tokenizer.from_pretrained("t5-small")
      3 model = T5Model.from_pretrained("t5-small")

TypeError: 'NoneType' object is not callable

我在这里做错了什么?

英文:

I am trying to make a text summarizer using the T5 transformer from Hugging Face.

From the Hugging Face site I am running this:

from transformers import T5Tokenizer, T5Model

tokenizer = T5Tokenizer.from_pretrained("t5-small")
model = T5Model.from_pretrained("t5-small")

Before this I pip installed transformers, sentencepiece, and datasets transformers[sentencepiece]

When I run it I get the following:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [9], line 2
      1 # Load the T5 model and tokenizer
----> 2 tokenizer = T5Tokenizer.from_pretrained("t5-small")
      3 model = T5Model.from_pretrained("t5-small")

TypeError: 'NoneType' object is not callable

What am I doing wrong here?

答案1

得分: 1

我重新启动了内核,然后它正常工作了。

英文:

I restarted the kernel and then it worked

huangapple
  • 本文由 发表于 2023年3月8日 16:49:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75670969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定