File size: 2,600 Bytes
feca0b9
 
 
 
 
 
52989b8
 
 
 
 
5359233
 
 
 
 
 
52989b8
5359233
 
 
 
 
 
0dbb893
5359233
 
 
 
52989b8
5359233
52989b8
5359233
52989b8
5359233
52989b8
5359233
52989b8
5359233
52989b8
5359233
 
 
 
 
 
 
 
52989b8
5359233
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
language: pt
tags:
  - seq2seq
  - t5
widget:
  - text: "['growth', 'neutralizing']: Sempre estressado e pensando em um monte de coisas ao mesmo tempo, preciso levar uma de cada vez, sobrecarga estressada, necessidade de reclamar"
  - text: "['growth', 'neutralizing', 'optimism']: Se eu não tiver um colapso mental antes do final do verão, será um milagre."
  - text: "['impermanence']: Dirigindo para visitar a vovó no hospital e o meu filho que está doente."
  - text: "['optimism']: Ótimo agora, como vou explicar isso para ela, ela está tão perto de mim que não posso perdê-la :'("
  - text: "['growth', 'optimism']: sempre há algo que eu poderia estar fazendo. Eu geralmente escolho não fazer isso."
---

# Positive Perspectives with Portuguese Text Reframing

## Model description

This model is a [PTT5][https://huggingface.co/unicamp-dl/ptt5-base-portuguese-vocab] finetuned to sentiment transfer task, where the objective is to reverse the sentiment polarity of a text without contradicting the original meaning. Based on the paper [arXiv:2204.02952](https://arxiv.org/abs/2204.02952).

## How to use

The model uses one or more sentiment strategies concatenated with a sentence and will generate a sentence with the applied sentiment output. The maximum string length is 1024 tokens. Entries must be organized in the following format:

```
"['thankfulness', 'optimism']: Tenho tanta coisa para fazer antes de sair da cidade por uma semana no domingo."
```

### Available sentiment strategies:

**growth**: viewing a challenging event as an opportunity for the author to specifically grow or improve himself.

**impermanence**: Saying that bad things don't last forever, will get better soon, and/or that other people have had similar difficulties.

**neutralizing**: Replacing a negative word with a neutral word. For example, “This was a terrible day” becomes “This was a long day”.

**optimism**: Focusing on things about the situation itself, at that moment, that are good (not just predicting a better future).

**self_affirmation**: Talking about what strengths the author already has, or values he admires, such as love, courage, perseverance, etc.

**thankfulness**: Expressing gratitude or gratitude with keywords like appreciate, happy for it, grateful for, good thing, etc.

### Usage

```python
from transformers import pipeline

pipe = pipeline('summarization', "dominguesm/positive-reframing-ptbr")

text = "['thankfulness', 'optimism']: Tenho tanta coisa para fazer antes de sair da cidade por uma semana no domingo."

pipe(text, max_length=1024)

```