gpt-3.5-turbo-0301· OpenAI
WildChat-4.8M (AI2)
What is the error import torch from transformers, import AutoTokenizer,…
- User
What is the error
import torch
from transformers, import AutoTokenizer, AutoModelWithLMHead
tokenizer = AutoTokenizer.from_pretrained('t5-base') model = AutoModelWithLMHead.from_pretrained('t5-base', return_dict=True)
inputs = tokenizer.encode("summarize: " + text, return_tensors='pt', max_length=512, truncation=True)
summary_ids = model.generate(inputs, max_length=150, min_length=80, length_penalty=5., num_beams=2)
summary = tokenizer.decode(summary_ids[0])
- Assistant
There is a comma after "from transformers" in the second line which should not be there. The correct syntax is "from transformers import AutoTokenizer, AutoModelWithLMHead".