-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BLOOMZ asset for OSACT4SubtaskB (#218)
Co-authored-by: Fahim Imaduddin Dalvi <[email protected]>
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
...r/factuality_disinformation_harmful_content/hate_speech/OSACT4SubtaskB_BLOOMZ_ZeroShot.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
|
||
from llmebench.datasets import OSACT4SubtaskBDataset | ||
from llmebench.models import PetalsModel | ||
from llmebench.tasks import HateSpeechTask | ||
|
||
|
||
def config(): | ||
return { | ||
"dataset": OSACT4SubtaskBDataset, | ||
"dataset_args": {}, | ||
"task": HateSpeechTask, | ||
"task_args": {}, | ||
"model": PetalsModel, | ||
"model_args": { | ||
"class_labels": ["HS", "NOT_HS"], | ||
"max_tries": 3, | ||
}, | ||
"general_args": { | ||
"data_path": "data/factuality_disinformation_harmful_content/hate_speech/OSACT2020-sharedTask-test-tweets-labels.txt" | ||
}, | ||
} | ||
|
||
|
||
def prompt(input_sample): | ||
return { | ||
"prompt": 'Given the following Arabic tweet, label it as "HS" or "NOT_HS" based on the content of the tweet. Provide only label.\n\n' | ||
+ "sentence: " | ||
+ input_sample | ||
+ "label: \n" | ||
} | ||
|
||
|
||
def post_process(response): | ||
label = response["outputs"].strip() | ||
label = label.replace("<s>", "") | ||
label = label.replace("</s>", "") | ||
|
||
return label |