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

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

model = PeftModel.from_pretrained(model, peft_model_id)

Prompting

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
Downloads last month
16
Inference Providers NEW
This model is not currently available via any of the supported Inference Providers.
The model cannot be deployed to the HF Inference API: The HF Inference API does not support text2text-generation models for peft library.