File size: 2,262 Bytes
640bc91
 
763d2d1
 
 
 
 
1e4b0f7
640bc91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f8a5bad
 
9f489ff
f8a5bad
 
 
 
 
 
 
 
9f489ff
f8a5bad
9173256
9f489ff
f8a5bad
9f489ff
f8a5bad
 
9f489ff
f8a5bad
 
 
 
 
 
 
 
 
 
 
 
 
9f489ff
f8a5bad
 
 
640bc91
927b271
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
640bc91
 
927b271
 
 
763d2d1
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
---
license: apache-2.0
language:
- en
library_name: peft
tags:
- politeness
pipeline_tag: text2text-generation
---



# Politeness Generative Model

## Overview

This GPT-based model is a text2text generator that writes a polite version of an input sentence. It is based on gpt-j-6B and was aligned using 29,000 pairs of sentences.


## Prompt

You have an input text. Write a polite version of the text preserving the meaning of the input. 

Input: What are your thoughts on the proposed merger and its potential effects on our industry?

Output: I'm sorry, but I don't have any thoughts on the proposed merger and its potential effects on our industry.

## Quick tutorial

```python
import torch
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer

peft_model_id = "mmendoza/gpt-j-6B-lora-polite-enh"
config = PeftConfig.from_pretrained(peft_model_id)
model = AutoModelForCausalLM.from_pretrained(config.base_model_name_or_path, return_dict=True, load_in_8bit=True, device_map='auto')
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
```

# Load the Politeness Model
```python
model = PeftModel.from_pretrained(model, peft_model_id)
```

# Prompting
```python
batch = tokenizer("You have an input text. Write a polite version of the text preserving the meaning of the input. 
Input: No card counting allowed in blackjack at the casino. Output: ", return_tensors='pt')

with torch.cuda.amp.autocast():
  output_tokens = model.generate(**batch, max_new_tokens=50, pad_token_id=tokenizer.eos_token_id)

line = tokenizer.decode(output_tokens[0], skip_special_tokens=True)

start = 'Output: '
end = '.'

line = line.replace("\n"," ")
line = (line.split(start))[1].split(end)[0]
```

"Please refrain from counting cards in blackjack at the casino."


---
library_name: peft
---
## Training procedure


The following `bitsandbytes` quantization config was used during training:
- load_in_8bit: True
- load_in_4bit: False
- llm_int8_threshold: 6.0
- llm_int8_skip_modules: None
- llm_int8_enable_fp32_cpu_offload: False
- llm_int8_has_fp16_weight: False
- bnb_4bit_quant_type: fp4
- bnb_4bit_use_double_quant: False
- bnb_4bit_compute_dtype: float32


### Framework versions


- PEFT 0.4.0.dev0