Views
No views yet

quora from Huggingface/NLP| Dataset | Split | # samples |
|---|---|---|
| quora | train | 404290 |
| quora after filter repeated questions | train | 149263 |
1from transformers import AutoModelWithLMHead, AutoTokenizer
2
3tokenizer = AutoTokenizer.from_pretrained("mrm8488/t5-small-finetuned-quora-for-paraphrasing")
4model = AutoModelWithLMHead.from_pretrained("mrm8488/t5-small-finetuned-quora-for-paraphrasing")
5
6def paraphrase(text, max_length=128):
7
8 input_ids = tokenizer.encode(text, return_tensors="pt", add_special_tokens=True)
9
10 generated_ids = model.generate(input_ids=input_ids, num_return_sequences=5, num_beams=5, max_length=max_length, no_repeat_ngram_size=2, repetition_penalty=3.5, length_penalty=1.0, early_stopping=True)
11
12 preds = [tokenizer.decode(g, skip_special_tokens=True, clean_up_tokenization_spaces=True) for g in generated_ids]
13
14 return preds
15
16preds = paraphrase("paraphrase: What is the best framework for dealing with a huge text dataset?")
17
18for pred in preds:
19 print(pred)
20
21# Output:
22'''
23What is the best framework for dealing with a huge text dataset?
24What is the best framework for dealing with a large text dataset?
25What is the best framework to deal with a huge text dataset?
26What are the best frameworks for dealing with a huge text dataset?
27What is the best framework for dealing with huge text datasets?
28'''Created by Manuel Romero/@mrm8488 | LinkedIn
Made with ♥ in Spain