Skip to content

Commit

Permalink
Fix GPT4 asset
Browse files Browse the repository at this point in the history
  • Loading branch information
fdalvi committed Oct 28, 2023
1 parent 4d92d1f commit 5995d4b
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions assets/en/sentiment_emotion_others/sentiment/SST2_GPT4_ZeroShot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from llmebench.datasets import SST2
from llmebench.datasets import HuggingFaceDataset
from llmebench.models import OpenAIModel
from llmebench.tasks import SentimentTask

Expand All @@ -13,13 +13,22 @@ def metadata():

def config():
return {
"dataset": SST2,
"dataset": HuggingFaceDataset,
"dataset_args": {
"huggingface_dataset_name": "sst2",
"column_mapping": {
"input": "sentence",
"label": "label",
"input_id": "idx",
},
},
"task": SentimentTask,
"model": OpenAIModel,
"model_args": {
"class_labels": ["positive", "negative"],
"max_tries": 3,
},
"general_args": {"custom_test_split": "validation"},
}


Expand All @@ -45,7 +54,13 @@ def post_process(response):
label = response["choices"][0]["message"]["content"].lower()

label_fixed = label.replace("label:", "").replace("sentiment: ", "").strip()

if label_fixed.startswith("Please provide the text"):
label_fixed = None

return label_fixed
if label_fixed == "positive":
return 1
elif label_fixed == "negative":
return 0

return None

0 comments on commit 5995d4b

Please sign in to comment.