Error when loading model
#3
by
pritish
- opened
Whenever I run this line of code:
summarizer = pipeline("summarization", model="slauw87/bart-large-cnn-samsum")
I get this error:
OSError: slauw87/bart-large-cnn-samsum does not appear to have a file named config.json. Checkout 'https://huggingface.co/slauw87/bart-large-cnn-samsum/main' for available files.
Please Help!!!
I solved this error. If you want to use this model try this code:
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
# load the tokenizer and summarizer
tokenizer = AutoTokenizer.from_pretrained("slauw87/bart_summarisation")
summarizer = AutoModelForSeq2SeqLM.from_pretrained("slauw87/bart_summarisation")
# use gpu
summarizer = summarizer.to('cuda')
def summarizer(text, summary_max_length):
inputs = tokenizer(
text,
return_tensors='pt',
padding=True
)['input_ids'].to('cuda')
summary_ids = summarizer.generate(
inputs,
max_length=summary_max_length,
length_penalty=3.0,
num_beams=2
)
summary = tokenizer.decode(
summary_ids[0] ,
skip_special_tokens=True,
clean_up_tokenization_spaces=False
)
return summary
output = summarizer("long text here")