Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("aglazkova/bart_multitask_finetuned_for_title_and_keyphrase_generation")
4model = AutoModelForSeq2SeqLM.from_pretrained("aglazkova/bart_multitask_finetuned_for_title_and_keyphrase_generation")
5
6
7text = "In this paper, we investigate cross-domain limitations of keyphrase generation using the models for abstractive text summarization.\
8 We present an evaluation of BART fine-tuned for keyphrase generation across three types of texts, \
9 namely scientific texts from computer science and biomedical domains and news texts. \
10 We explore the role of transfer learning between different domains to improve the model performance on small text corpora."
11
12#generating \n-separated keyphrases
13tokenized_text = tokenizer.prepare_seq2seq_batch(["<|KEYPHRASES|> " + text], return_tensors='pt')
14translation = model.generate(**tokenized_text)
15translated_text = tokenizer.batch_decode(translation, skip_special_tokens=True)[0]
16print(translated_text)
17
18#generating title
19tokenized_text = tokenizer.prepare_seq2seq_batch(["<|TITLE|> " + text], return_tensors='pt')
20translation = model.generate(**tokenized_text)
21translated_text = tokenizer.batch_decode(translation, skip_special_tokens=True)[0]
22print(translated_text)@INPROCEEDINGS{10139061,
author={Glazkova, Anna and Morozov, Dmitry},
booktitle={2023 IX International Conference on Information Technology and Nanotechnology (ITNT)},
title={Multi-task fine-tuning for generating keyphrases in a scientific domain},
year={2023},
pages={1-5},
doi={10.1109/ITNT57377.2023.10139061}}