Skip to content

Commit

Permalink
Add ZeroShot Jais 13b asset for ArSAS (#252)
Browse files Browse the repository at this point in the history
* JAIS 13b ZeroShot for ArSAS dataset

* Fix minor issue in metadata

---------

Co-authored-by: Fahim Imaduddin Dalvi <[email protected]>
  • Loading branch information
AridHasan and fdalvi authored Jan 30, 2024
1 parent c69a3ea commit e852e80
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from llmebench.datasets import ArSASDataset
from llmebench.models import FastChatModel
from llmebench.tasks import SentimentTask


def metadata():
return {
"author": "Arabic Language Technologies, QCRI, HBKU",
"model": "Jais-13b-chat",
"description": "Locally hosted Jais-13b-chat model using FastChat.",
}


def config():
return {
"dataset": ArSASDataset,
"task": SentimentTask,
"model": FastChatModel,
}


def prompt(input_sample):
base_prompt = (
f'Classify the sentiment of the following sentence as "Positive", "Negative", "Neutral" or "Mixed". Output only the label and nothing else.\n'
f"Sentence: {input_sample}\n"
f"Label: "
)

return [
{
"role": "user",
"content": base_prompt,
},
]


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

if "i apologize" in out:
return None

j = out.find("label:")
if j > 0:
out = out[j + len("label:") :]
else:
j = out.find(" is:\n\n")
if j > 0:
out = out[j + len(" is:\n\n") :]
out = out.strip().title()
return out

0 comments on commit e852e80

Please sign in to comment.