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

Add SST2 asset for RedPajama-INCITE chat model #246

Merged
merged 1 commit into from
Oct 29, 2023
Merged
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from llmebench.datasets import HuggingFaceDataset
from llmebench.models import FastChatModel
from llmebench.tasks import ClassificationTask


def metadata():
return {
"author": "Arabic Language Technologies, QCRI, HBKU",
"model": "togethercomputer/RedPajama-INCITE-Chat-3B-v1",
"description": "Locally hosted RedPajama-INCITE-Chat 3b parameters model using FastChat.",
"scores": {"Accuracy": "0.681"},
}


def config():
return {
"dataset": HuggingFaceDataset,
"dataset_args": {
"huggingface_dataset_name": "sst2",
"column_mapping": {
"input": "sentence",
"label": "label",
"input_id": "idx",
},
},
"task": ClassificationTask,
"model": FastChatModel,
"general_args": {"custom_test_split": "validation"},
}


def prompt(input_sample):
prompt_string = (
f"You are tasked with analyzing the sentiment of the given sentence. "
f"Please read it carefully and determine whether the sentiment expressed is positive or negative. Provide only label.\n\n"
f"sentence: {input_sample.strip()}\n"
f"label:\n"
)
return [
{
"role": "system",
"content": "You are a data annotation expert specializing in sentiment analysis.",
},
{"role": "user", "content": prompt_string},
]


def post_process(response):
response = response["choices"][0]["message"]["content"].lower()
response = response.replace(".", "")
response = response.strip()

if response.endswith("positive"):
return 1
elif response.endswith("negative"):
return 0
elif "positive" in response and "negative" not in response:
return 1
elif "negative" in response and "positive" not in response:
return 0
else:
return None
Loading