Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize fluency, diversity and adequacy model tags #33

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions parrot/parrot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
class Parrot():

def __init__(self, model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=False):
def __init__(
self,
model_tag="prithivida/parrot_paraphraser_on_T5",
adequacy_model="prithivida/parrot_adequacy_model",
fluency_model="prithivida/parrot_fluency_model",
diversity_model="paraphrase-distilroberta-base-v2",
use_gpu=False):
from transformers import AutoTokenizer
from transformers import AutoModelForSeq2SeqLM
import pandas as pd
Expand All @@ -9,9 +15,9 @@ def __init__(self, model_tag="prithivida/parrot_paraphraser_on_T5", use_gpu=Fals
from parrot.filters import Diversity
self.tokenizer = AutoTokenizer.from_pretrained(model_tag)
self.model = AutoModelForSeq2SeqLM.from_pretrained(model_tag)
self.adequacy_score = Adequacy()
self.fluency_score = Fluency()
self.diversity_score= Diversity()
self.adequacy_score = Adequacy(model_tag=adequacy_model)
self.fluency_score = Fluency(model_tag=fluency_model)
self.diversity_score= Diversity(model_tag=diversity_model)

def rephrase(self, input_phrase, use_gpu=False, diversity_ranker="levenshtein", do_diverse=False, style=1, max_length=32, adequacy_threshold = 0.90, fluency_threshold = 0.90):
if use_gpu:
Expand Down