VladimirVorobev's picture
Update README.md
e679a5b
|
raw
history blame
4.07 kB
metadata
license: openrail
datasets:
  - humarin/chatgpt-paraphrases
language:
  - en
library_name: transformers
inference:
  parameters:
    num_beams: 5
    num_beam_groups: 5
    num_return_sequences: 5
    repetition_penalty: 10.01
    diversity_penalty: 3.01
    no_repeat_ngram_size: 2
    temperature: 0.7
    max_length: 128
widget:
  - text: What are the best places to see in New York?
    example_title: New York tourist attractions
  - text: When should I go to the doctor?
    example_title: Doctor's time
  - text: >-
      Rammstein's album Mutter was recorded in the south of France in May and
      June 2000, and mixed in Stockholm in October of that year.
    example_title: Rammstein's album Mutter
pipeline_tag: text2text-generation

This model was trained on our ChatGPT paraphrase dataset.

This dataset is based on the Quora paraphrase question, texts from the SQUAD 2.0 and the CNN news dataset.

This model is based on the T5-base model. We used "transfer learning" to get our model to generate paraphrases as well as ChatGPT. Now we can say that this is one of the best paraphrases of the Hugging Face.

Kaggle link

Deploying example:

from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

device = "cuda"

tokenizer = AutoTokenizer.from_pretrained("humarin/chatgpt_paraphraser_on_T5_base")

model = AutoModelForSeq2SeqLM.from_pretrained("humarin/chatgpt_paraphraser_on_T5_base").to(device)

def paraphrase(
    question,
    num_beams=5,
    num_beam_groups=5,
    num_return_sequences=5,
    repetition_penalty=10.0,
    diversity_penalty=3.0,
    no_repeat_ngram_size=2,
    temperature=0.7,
    max_length=128
):
    input_ids = tokenizer(
        f'paraphrase: {question}',
        return_tensors="pt", padding="longest",
        max_length=max_length,
        truncation=True,
    ).input_ids
    
    outputs = model.generate(
        input_ids, temperature=temperature, repetition_penalty=repetition_penalty,
        num_return_sequences=num_return_sequences, no_repeat_ngram_size=no_repeat_ngram_size,
        num_beams=num_beams, num_beam_groups=num_beam_groups,
        max_length=max_length, diversity_penalty=diversity_penalty
    )

    res = tokenizer.batch_decode(outputs, skip_special_tokens=True)

    return res

Usage examples

Input:

text = 'What are the best places to see in New York?'
paraphrase(text)

Output:

['Which places should I not miss when visiting New York?',
 'What are the top-rated tourist destinations in New York?',
 'Where should I go sightseeing in New York?',
 'Can you suggest some must-see places in New York?',
 'What are some must-see places in New York?']

Input:

text = "Rammstein's album Mutter was recorded in the south of France in May and June 2000, and mixed in Stockholm in October of that year."
paraphrase(text)

Output:

['In May and June 2000, Rammstein filmed the album Mutter in the south of France, with mixing taking place in Stockholm in October of that year.',
 'The album Mutter by Rammstein was recorded in the south of France during May and June 2000, with subsequent mixing taking place in Stockholm in October of that year.',
 'Mutter, the album by Rammstein, was recorded in the south of France during May and June 2000, with mixing taking place at Stockholm in October of that year.',
 "Rammstein's album Mutter was produced during May and June 2000 in southern France, with mixing taking place in Stockholm from October.",
 'In May and June 2000, Rammstein recorded Mutter in southern France, followed by mixing it in Stockholm in October of the same year.']

Train parameters:

epochs = 3.5
batch_size = 64
max_length = 128
lr = 5e-5
batches_qty = 196465
betas = (0.9, 0.999)
eps = 1e-08