# Using Pegasus for Paraphrasing

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-pegasus-for-paraphrasing%2F13462%3E%5C
**Category:** Beginners\
**Created:** [January 7, 2022, 5:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-pegasus-for-paraphrasing%2F13462 "2022-01-07T05:30:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![steelhard](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/steelhard/32/1671_2.png) [@steelhard](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fsteelhard)%5C
**Post date:** [January 7, 2022, 5:30am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fusing-pegasus-for-paraphrasing%2F13462%2F1 "2022-01-07T05:30:11Z")

</div>

So I’ve been using “Parrot Paraphraser”, however, I wanted to try Pegasus and compare results.

I’m scraping articles from news websites & splitting them into sentences then running each individual sentence through the Paraphraser, however, Pegasus is giving me the following error:

```auto
File "C:\Python\lib\site-packages\torch\nn\functional.py", line 2044, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
IndexError: index out of range in self

```

The code:

```auto
def get_response(input_text,num_return_sequences):
  batch = tokenizer.prepare_seq2seq_batch([input_text],truncation=True,padding='longest',max_length=1024, return_tensors="pt").to(torch_device)
  translated = model.generate(**batch,max_length=1024,num_beams=10, num_return_sequences=num_return_sequences, temperature=1.5)
  tgt_text = tokenizer.batch_decode(translated, skip_special_tokens=True)
  return tgt_text

for phrase in introduction_list:
    if len(phrase) > 15 and 'http' not in phrase and 'read more' not in phrase and 'Read more' not in phrase and phrase not in h2list and len(phrase) < 1024:
		para_phrases = get_response(phrase, 1)

```
