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

Implement generic ClassificationTask #242

Merged
merged 4 commits into from
Oct 28, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Merge branch 'main' into feat/sst2
  • Loading branch information
fdalvi committed Oct 28, 2023
commit 938780bff1e23780a5d42e69e8577e415df9d945
40 changes: 40 additions & 0 deletions assets/en/sentiment_emotion_others/sentiment/SST2_GPT4_ZeroShot.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,53 @@
<<<<<<< HEAD
from llmebench.datasets import SST2
from llmebench.models import OpenAIModel
from llmebench.tasks import ClassificationTask
=======
from llmebench.datasets import HuggingFaceDataset
from llmebench.models import OpenAIModel
from llmebench.tasks import SentimentTask
>>>>>>> main


def metadata():
return {
"author": "Arabic Language Technologies, QCRI, HBKU",
"model": "gpt-4-32k (version 0314)",
<<<<<<< HEAD
"description": "GPT4 32k tokens model hosted on Azure, using the ChatCompletion API. API version '2023-03-15-preview'. Uses an prompt specified in Arabic.",
# "scores": {"Macro-F1": "0.547"},
=======
"description": "GPT4 32k tokens model hosted on Azure, using the ChatCompletion API. API version '2023-03-15-preview'.",
>>>>>>> main
}


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


@@ -46,7 +73,20 @@ def post_process(response):
label = response["choices"][0]["message"]["content"].lower()

label_fixed = label.replace("label:", "").replace("sentiment: ", "").strip()
<<<<<<< HEAD
if label_fixed.startswith("Please provide the text"):
label_fixed = None

return label_fixed
=======

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

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

return None
>>>>>>> main
You are viewing a condensed version of this merge commit. You can view the full changes here.