--- license: apache-2.0 datasets: - taln-ls2n/kp20k language: - en library_name: transformers tags: - keyphrase-generation --- # Model Card for bart-base-kp20k This is a BART-base model for keyphrase generation. # Model Details ## Model Description This is a BART-base model for keyphrase generation. We specifically, we fine-tuned [bart-base](https://huggingface.co/facebook/bart-base) on the KP20k dataset in a ONE2MANY setting, that is, given a source text as input, the task is to generate keyphrases as a single sequence of delimiter-separated phrases. During fine-tuning, gold keyphrases are arranged in the present-absent order which was found to give the best results. - **Developed by:** [boudinfl](https://boudinfl.github.io/) - **Model type:** Language model - **Language(s) (NLP):** en - **License:** apache-2.0 - **Parent Model:** [bart-base](https://huggingface.co/facebook/bart-base) # Usage ```python from transformers import BartForConditionalGeneration, AutoTokenizer model = BartForConditionalGeneration.from_pretrained('taln-ls2n/bart-base-kp20k') tokenizer = AutoTokenizer.from_pretrained('taln-ls2n/bart-base-kp20k') # inputs are formatted as "titleabstract" input_text = "BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and ComprehensionWe present BART, a denoising autoencoder for pretraining sequence-to-sequence models. BART is trained by (1) corrupting text with an arbitrary noising function, and (2) learning a model to reconstruct the original text. It uses a standard Tranformer-based neural machine translation architecture which, despite its simplicity, can be seen as generalizing BERT (due to the bidirectional encoder), GPT (with the left-to-right decoder), and other recent pretraining schemes. We evaluate a number of noising approaches, finding the best performance by both randomly shuffling the order of sentences and using a novel in-filling scheme, where spans of text are replaced with a single mask token. BART is particularly effective when fine tuned for text generation but also works well for comprehension tasks. It matches the performance of RoBERTa on GLUE and SQuAD, and achieves new state-of-the-art results on a range of abstractive dialogue, question answering, and summarization tasks, with gains of up to 3.5 ROUGE. BART also provides a 1.1 BLEU increase over a back-translation system for machine translation, with only target language pretraining. We also replicate other pretraining schemes within the BART framework, to understand their effect on end-task performance." input_ids = tokenizer(input_text, return_tensors="pt") outputs = model.generate(**input_ids) print(tokenizer.decode(outputs[0], skip_special_tokens=True)) # denoising;natural language generation;machine translation;machine learning;sequence-to ``` # Bias, Risks, and Limitations Significant research has explored bias and fairness issues with language models (see, e.g., [Sheng et al. (2021)](https://aclanthology.org/2021.acl-long.330.pdf) and [Bender et al. (2021)](https://dl.acm.org/doi/pdf/10.1145/3442188.3445922)). Predictions generated by the model may include disturbing and harmful stereotypes across protected classes; identity characteristics; and sensitive, social, and occupational groups. # Training Details ## Training Data This model was fine-tuned on the training split of the [KP20k dataset](https://huggingface.co/datasets/taln-ls2n/kp20k). ## Training Procedure We fine-tuned [bart-base](https://huggingface.co/facebook/bart-base) on the training split of the [KP20k dataset](https://huggingface.co/datasets/taln-ls2n/kp20k) in a ONE2MANY setting, that is, given a source text as input, the task is to generate keyphrases as a single sequence of delimiter-separated phrases. During fine-tuning, gold keyphrases are arranged in the present-absent order which was found to give the best results. The model is trained for 15 epochs. # Evaluation We evaluate the performance of this model on the test split of the KP20K dataset in terms of \\(F_1\\) score using exact match between gold and predicted keyphrases. Stemming (Porter stemmer) is applied to reduce the number of mismatches and duplicates are removed. We compute the scores both at the top-k predicted keyphrases with \\(k \in 5, 10\\), and at the number \\(M\\) of keyphrases predicted by the models. For \\(F_1@k\\) scores, if the number of predicted keyphrases is below \\(k\\), we append incorrect predictions until it reaches exactly \\(k\\) keyphrases. We also report scores for present and absent keyphrases separately to get more insights about the extractive and generative capabilities of the model. | Eval | \\(F_1@M\\) | \\(F_1@5\\) | \\(F_1@10\\) | | :-------- | ----------: | ----------: | -----------: | | all | 28.7 | 28.0 | 25.4 | | present | 37.3 | 35.5 | 29.2 | | absent | 2.4 | 5.9 | 5.8 | # Environmental Impact Experiments were conducted using a private infrastructure, which has a carbon efficiency of 0.432 kgCO2eq/kWh. A cumulative of 63 hours of computation was performed on hardware of type RTX 2080 Ti (TDP of 250W). Total emissions are estimated to be 6.8 kgCO2eq of which 0 percents were directly offset. Estimations were conducted using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).