Skip to content

Commit

Permalink
Format code
Browse files Browse the repository at this point in the history
  • Loading branch information
fdalvi committed Jan 31, 2024
1 parent d739a26 commit bae5d43
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def prompt(input_sample):
input_sample = arr[:1000]

prompt_string = (
f'Does the following tweet contain a factually correct claim or not? Answer only by yes or no.\n\n'
f"Does the following tweet contain a factually correct claim or not? Answer only by yes or no.\n\n"
f"tweet: {input_sample}\n"
f"label: \n"
)
Expand All @@ -46,13 +46,26 @@ def post_process(response):
label = label.replace("</s>", "")
label = label.lower()

if (label.startswith("i am unable to verify") or label.startswith(
"i am unable to categorize") or label.startswith("i cannot") or "cannot" in label
if (
label.startswith("i am unable to verify")
or label.startswith("i am unable to categorize")
or label.startswith("i cannot")
or "cannot" in label
):
label_fixed = None
elif "label: incorrect" in label or "incorrect" in label or label == "no" or label == "لا":
elif (
"label: incorrect" in label
or "incorrect" in label
or label == "no"
or label == "لا"
):
label_fixed = "no"
elif "label: correct" in label or "correct" in label or "yes" in label or "نعم" in label:
elif (
"label: correct" in label
or "correct" in label
or "yes" in label
or "نعم" in label
):
label_fixed = "yes"
else:
label_fixed = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,28 @@ def prompt(input_sample):
def post_process(response):
label = response["choices"][0]["text"].lower().replace(".", "").lower()

if (label.startswith("i am unable to verify") or label.startswith(
"i am unable to categorize") or label.startswith("i cannot") or "cannot" in label
if (
label.startswith("i am unable to verify")
or label.startswith("i am unable to categorize")
or label.startswith("i cannot")
or "cannot" in label
):
label_fixed = None
elif "label: incorrect" in label or "incorrect" in label or label == "no" or label == "لا":
elif (
"label: incorrect" in label
or "incorrect" in label
or label == "no"
or label == "لا"
):
label_fixed = "no"
elif "label: correct" in label or "correct" in label or "yes" in label or "نعم" in label:
elif (
"label: correct" in label
or "correct" in label
or "yes" in label
or "نعم" in label
):
label_fixed = "yes"
else:
label_fixed = None


return label_fixed
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def few_shot_prompt(input_sample, base_prompt, examples):


def prompt(input_sample, examples):
base_prompt = f'Does the following tweet contain a factually correct claim or not? Answer only by yes or no.'
base_prompt = f"Does the following tweet contain a factually correct claim or not? Answer only by yes or no."
return [
{
"role": "system",
Expand All @@ -65,14 +65,27 @@ def prompt(input_sample, examples):
def post_process(response):
label = response["choices"][0]["message"]["content"].lower()

if (label.startswith("i am unable to verify") or label.startswith(
"i am unable to categorize") or label.startswith("i cannot") or "cannot" in label
if (
label.startswith("i am unable to verify")
or label.startswith("i am unable to categorize")
or label.startswith("i cannot")
or "cannot" in label
):
#print(label)
# print(label)
label_fixed = None
elif "label: incorrect" in label or "incorrect" in label or label == "no" or label == "لا":
elif (
"label: incorrect" in label
or "incorrect" in label
or label == "no"
or label == "لا"
):
label_fixed = "no"
elif "label: correct" in label or "correct" in label or "yes" in label or "نعم" in label:
elif (
"label: correct" in label
or "correct" in label
or "yes" in label
or "نعم" in label
):
label_fixed = "yes"
else:
label_fixed = None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def config():

def prompt(input_sample):
prompt_string = (
f'Does the following tweet contain a factually correct claim or not? Answer only by yes or no.\n\n'
f"Does the following tweet contain a factually correct claim or not? Answer only by yes or no.\n\n"
f"tweet: {input_sample}\n"
f"label: \n"
)
Expand All @@ -45,14 +45,27 @@ def prompt(input_sample):
def post_process(response):
label = response["choices"][0]["message"]["content"].lower()

if (label.startswith("i am unable to verify") or label.startswith(
"i am unable to categorize") or label.startswith("i cannot") or "cannot" in label
if (
label.startswith("i am unable to verify")
or label.startswith("i am unable to categorize")
or label.startswith("i cannot")
or "cannot" in label
):
#print(label)
# print(label)
label_fixed = None
elif "label: incorrect" in label or "incorrect" in label or label == "no" or label == "لا":
elif (
"label: incorrect" in label
or "incorrect" in label
or label == "no"
or label == "لا"
):
label_fixed = "no"
elif "label: correct" in label or "correct" in label or "yes" in label or "نعم" in label:
elif (
"label: correct" in label
or "correct" in label
or "yes" in label
or "نعم" in label
):
label_fixed = "yes"
else:
label_fixed = None
Expand Down

0 comments on commit bae5d43

Please sign in to comment.