├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Pedro Henrique Paiola 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Portuguese T5 for Abstractive Summarization (PTT5 Summ) 2 | 3 | The code will be released soon. 4 | 5 | ## Introduction 6 | PTT5 Summ is a fine-tuned [PTT5](https://github.com/unicamp-dl/PTT5) model to perform Abstractive Summarization in Brazilian Portuguese texts. This model was fine-tuned on the datasets: [WikiLingua](https://github.com/esdurmus/Wikilingua), [XL-Sum](https://github.com/csebuetnlp/xl-sum), [TeMário](http://www.nilc.icmc.usp.br/nilc/download/NILCTR0706-MazieroEtAl(2).pdf) and [CSTNews](http://nilc.icmc.usp.br/CSTNews/login/?next=/CSTNews/). 7 | 8 | For further information, please go to [PTT5 Summ repository](https://github.com/pedropaiola/ptt5-summ). 9 | 10 | ## Available models 11 | | Model | Dataset used in fine-tuning| 12 | | :-: | :-: | 13 | | [phpaiola/ptt5-base-summ-wikilingua](https://huggingface.co/phpaiola/ptt5-base-summ-wikilingua) | WikiLingua | 14 | | [phpaiola/ptt5-base-summ-xlsum](https://huggingface.co/phpaiola/ptt5-base-summ-xlsum) | XL-Sum | 15 | | [phpaiola/ptt5-base-summ-temario](https://huggingface.co/phpaiola/ptt5-base-summ-temario) | 1st phase: WikiLingua. 2nd phase: TeMario | 16 | | [phpaiola/ptt5-base-summ-cstnews](https://huggingface.co/phpaiola/ptt5-base-summ-cstnews) | 1st phase: WikiLingua. 2nd phase: CSTNews| 17 | 18 | ## Usage example 19 | ```python 20 | # Tokenizer 21 | from transformers import T5Tokenizer 22 | 23 | # PyTorch model 24 | from transformers import T5Model, T5ForConditionalGeneration 25 | 26 | token_name = 'unicamp-dl/ptt5-base-portuguese-vocab' 27 | model_name = 'phpaiola/ptt5-base-summ-xlsum' 28 | 29 | tokenizer = T5Tokenizer.from_pretrained(token_name ) 30 | model_pt = T5ForConditionalGeneration.from_pretrained(model_name) 31 | 32 | text = ''' 33 | “A tendência de queda da taxa de juros no Brasil é real, é visível”, disse Meirelles, que participou na capital americana de uma série de reuniões e encontros com banqueiros e investidores que aconteceram paralelamente às reuniões do Fundo Monetário Internacional (FMI) e do Banco Mundial (Bird) no fim de semana. 34 | Para o presidente do BC, a atual política econômica do governo e a manutenção da taxa de inflação dentro da meta são fatores que garantem queda na taxa de juros a longo prazo. 35 | “Mas é importante que nós não olhemos para isso apenas no curto prazo. Temos que olhar no médio e longo prazos”, disse Meirelles. 36 | Para ele, o trabalho que o Banco Central tem feito para conter a inflação dentro da meta vai gerar queda gradual da taxa de juros. 37 | BC do ano 38 | Neste domingo, Meirelles participou da cerimônia de entrega do prêmio “Banco Central do ano”, oferecido pela revista The Banker à instituição que preside. 39 | “Este é um sinal importante de reconhecimento do nosso trabalho, de que o Brasil está indo na direção correta”, disse ele. 40 | Segundo Meirelles, o Banco Central do Brasil está sendo percebido como uma instituição comprometida com a meta de inflação. 41 | “Isso tem um ganho importante, na medida em que os agentes formadores de preços começam a apostar que a inflação vai estar na meta, que isso é levado a sério no Brasil”, completou. 42 | O presidente do Banco Central disse ainda que a crise política brasileira não foi um assunto de interesse prioritário dos investidores que encontrou no fim de semana. 43 | ''' 44 | 45 | inputs = tokenizer.encode(text, max_length=512, truncation=True, return_tensors='pt') 46 | summary_ids = model_pt.generate(inputs, max_length=256, min_length=32, num_beams=5, no_repeat_ngram_size=3, early_stopping=True) 47 | summary = tokenizer.decode(summary_ids[0]) 48 | print(summary) 49 | # O presidente do Banco Central, Henrique Meirelles, disse neste domingo, em Washington, que a taxa de juros no Brasil é real, mas que o Brasil está indo na direção correta. 50 | 51 | ``` 52 | 53 | # Citation 54 | 55 | @aInProceedings{ptt5summ_bracis, 56 | author="Paiola, Pedro H. 57 | and de Rosa, Gustavo H. 58 | and Papa, Jo{\~a}o P.", 59 | editor="Xavier-Junior, Jo{\~a}o Carlos 60 | and Rios, Ricardo Ara{\'u}jo", 61 | title="Deep Learning-Based Abstractive Summarization for Brazilian Portuguese Texts", 62 | booktitle="BRACIS 2022: Intelligent Systems", 63 | year="2022", 64 | publisher="Springer International Publishing", 65 | address="Cham", 66 | pages="479--493", 67 | isbn="978-3-031-21689-3"} 68 | 69 | --------------------------------------------------------------------------------