For more details, do check out
our Github repo.
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("razent/SciFive-base-PMC")
4model = AutoModelForSeq2SeqLM.from_pretrained("razent/SciFive-base-PMC")
5
6sentence = "Identification of APC2 , a homologue of the adenomatous polyposis coli tumour suppressor ."
7text = sentence + " </s>"
8
9encoding = tokenizer.encode_plus(text, pad_to_max_length=True, return_tensors="pt")
10input_ids, attention_masks = encoding["input_ids"].to("cuda"), encoding["attention_mask"].to("cuda")
11
12outputs = model.generate(
13 input_ids=input_ids, attention_mask=attention_masks,
14 max_length=256,
15 early_stopping=True
16)
17
18for output in outputs:
19 line = tokenizer.decode(output, skip_special_tokens=True, clean_up_tokenization_spaces=True)
20 print(line)