Spaces:
Sleeping
Sleeping
Update models.py
Browse files
models.py
CHANGED
|
@@ -62,6 +62,38 @@ Text: "{sentence}"
|
|
| 62 |
Please revise this text such that it maintains the criticism in the original text and delivers it in a friendly but professional manner. Make minimal changes to the original text. [/INST] Revised Text: """
|
| 63 |
return prompt
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
def query_model_score(sentence, api_key, model_id, prompt_fun):
|
| 66 |
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
|
| 67 |
headers = {"Authorization": f"Bearer {api_key}"}
|
|
@@ -117,6 +149,9 @@ def revise_review(review, api_key, model_id, highlight_color):
|
|
| 117 |
elif 'mistral' in model_id.lower():
|
| 118 |
revision_prompt = mistral_revise
|
| 119 |
score_prompt = mistral_score
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
try:
|
| 122 |
review = review.replace('"', "'")
|
|
|
|
| 62 |
Please revise this text such that it maintains the criticism in the original text and delivers it in a friendly but professional manner. Make minimal changes to the original text. [/INST] Revised Text: """
|
| 63 |
return prompt
|
| 64 |
|
| 65 |
+
def phi_score(sentence):
|
| 66 |
+
prompt = f"""<|system|>
|
| 67 |
+
You are an assistant helping with paper reviews.
|
| 68 |
+
You will be tasked to classify sentences as 'J' or 'V'
|
| 69 |
+
|
| 70 |
+
'J' is positive or 'J' is encouraging.
|
| 71 |
+
'J' has a neutral tone or 'J' is not discouraging and not encouraging.
|
| 72 |
+
'V' is overly blunt or 'V' contains excessive negativity and no constructive feedback.
|
| 73 |
+
'V' contains an accusatory tone or 'V' contains sweeping generalizations or 'V' contains personal attacks.<|end|>
|
| 74 |
+
<|user|>
|
| 75 |
+
Text: "{sentence}"
|
| 76 |
+
|
| 77 |
+
Please classify this text as either 'J' or 'V'. Only output 'J' or 'V' with no additional explanation.<|end|>
|
| 78 |
+
<|assistant|>
|
| 79 |
+
"""
|
| 80 |
+
return prompt
|
| 81 |
+
|
| 82 |
+
def phi_revise(sentence):
|
| 83 |
+
prompt = f"""<|system|>
|
| 84 |
+
You are an assistant that helps users revise Paper Reviews.
|
| 85 |
+
Paper reviews exist to provide authors of academic research papers constructive critism.<|end|>
|
| 86 |
+
<|user|>
|
| 87 |
+
This is text found in a review.
|
| 88 |
+
This text was classified as 'toxic'
|
| 89 |
+
|
| 90 |
+
Text: "{sentence}"
|
| 91 |
+
|
| 92 |
+
Please revise this text such that it maintains the criticism in the original text and delivers it in a friendly but professional manner. Make minimal changes to the original text.<|end|>
|
| 93 |
+
<|assistant|>
|
| 94 |
+
"""
|
| 95 |
+
return prompt
|
| 96 |
+
|
| 97 |
def query_model_score(sentence, api_key, model_id, prompt_fun):
|
| 98 |
API_URL = f"https://api-inference.huggingface.co/models/{model_id}"
|
| 99 |
headers = {"Authorization": f"Bearer {api_key}"}
|
|
|
|
| 149 |
elif 'mistral' in model_id.lower():
|
| 150 |
revision_prompt = mistral_revise
|
| 151 |
score_prompt = mistral_score
|
| 152 |
+
elif 'phi' in model_id.lower():
|
| 153 |
+
revision_prompt = phi_revise
|
| 154 |
+
score_prompt = phi_score
|
| 155 |
|
| 156 |
try:
|
| 157 |
review = review.replace('"', "'")
|