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

Feat/demographic attributes/jais13b #270

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
firojalam marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
from llmebench.datasets import ArabGendDataset
from llmebench.models import FastChatModel
from llmebench.tasks import ClassificationTask


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


def config():
return {
"dataset": ArabGendDataset,
"task": ClassificationTask,
"model": FastChatModel,
"model_args": {
"class_labels": ["m", "f"],
"max_tries": 3,
},
}


def prompt(input_sample):
base_prompt = (
f"Identify the gender from the following name as 'female' or 'male'.\n\n"
f"name: {input_sample}"
f"gender: \n"
)
return [
{
"role": "user",
"content": base_prompt,
},
]


def post_process(response):
label = response["choices"][0]["message"]["content"]
if label.lower() == "male":
return "m"
elif "female" in label.lower():
return "f"
else:
return None
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from llmebench.datasets import ArapTweetDataset
from llmebench.models import FastChatModel
from llmebench.tasks import ClassificationTask


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


def config():
return {
"dataset": ArapTweetDataset,
"task": ClassificationTask,
"model": FastChatModel,
"model_args": {
"class_labels": ["Female", "Male"],
"max_tries": 30,
},
}


def prompt(input_sample):
base_prompt = (
f"Identify the gender from the following name as 'Female' or 'Male'.\n\n"
f"name: {input_sample}"
f"gender: \n"
)

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


def post_process(response):
label = response["choices"][0]["message"]["content"]
# label = label.replace("gender:", "").strip()
if "gender: Female" in label or "\nFemale" in label or label == "Female":
label = "Female"
elif (
"gender: Male" in label
or "\nMale" in label
or "likely to be 'Male'" in label
or label == "Male"
or "typically a 'Male' name" in label
):
label = "Male"
else:
label = None

return label
Loading