Skip to content

Commit

Permalink
code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bsabri committed Oct 14, 2023
1 parent c142d5f commit 9ccadfa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions assets/en/PIQA_Phi_ZeroShot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from llmebench.models import FastChatModel
from llmebench.tasks import PIQATask


def metadata():
return {
"author": "Arabic Language Technologies, QCRI, HBKU",
Expand Down
32 changes: 22 additions & 10 deletions llmebench/datasets/PIQA.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json

import pandas as pd

from llmebench.datasets.dataset_base import DatasetBase
from llmebench.tasks import TaskType
import pandas as pd
import json


class PIQADataset(DatasetBase):
Expand Down Expand Up @@ -34,19 +36,29 @@ def metadata():

@staticmethod
def get_data_sample():
return {"input": "When boiling butter, when it's ready, you can", "sol1": "Pour it onto a plate", "sol2": "Pour it into a jar", "label": "1"}
return {
"input": "When boiling butter, when it's ready, you can",
"sol1": "Pour it onto a plate",
"sol2": "Pour it into a jar",
"label": "1",
}

def load_data(self, data_path, no_labels=False):
data_path = self.resolve_path(data_path + ".jsonl")
label_path = self.resolve_path(data_path + "-labels.lst")
data = []
label_data = pd.read_csv(label_path, sep="\t", header=None)

with open(data_path, "r", encoding="utf-8") as json_file:
for index, line in enumerate(json_file):
json_obj = json.loads(line)
label = label_data.loc[index]
data.append(
{"input": json_obj["goal"], "sol1": json_obj["sol1"], "sol2":json_obj["sol2"], "label": label}
)
for index, line in enumerate(json_file):
json_obj = json.loads(line)
label = label_data.loc[index]
data.append(
{
"input": json_obj["goal"],
"sol1": json_obj["sol1"],
"sol2": json_obj["sol2"],
"label": label,
}
)
return data
2 changes: 1 addition & 1 deletion llmebench/datasets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from .OSACT4SubtaskA import OSACT4SubtaskADataset
from .OSACT4SubtaskB import OSACT4SubtaskBDataset
from .PADT import PADTDataset
from .PIQA import PIQADataset
from .QADI import QADIDataset
from .QCRIDialectalArabicPOS import QCRIDialectalArabicPOSDataset
from .QCRIDialectalArabicSegmentation import QCRIDialectalArabicSegmentationDataset
Expand All @@ -50,4 +51,3 @@
from .XGLUEPOS import XGLUEPOSDataset
from .XNLI import XNLIDataset
from .XQuAD import XQuADDataset
from .PIQA import PIQADataset
1 change: 0 additions & 1 deletion llmebench/tasks/PIQA.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ def evaluate(self, gold_labels, pred_labels):
}

return results

2 changes: 1 addition & 1 deletion llmebench/tasks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from .NER import NERTask
from .NewsCategorization import NewsCategorizationTask
from .Offensive import OffensiveTask
from .PIQA import PIQATask
from .Q2QSimDetect import Q2QSimDetectionTask
from .QA import QATask
from .Sarcasm import SarcasmTask
Expand All @@ -31,7 +32,6 @@
from .STS import STSTask
from .Subjectivity import SubjectivityTask
from .XNLI import XNLITask
from .PIQA import PIQATask

TaskType = Enum(
"TaskType",
Expand Down

0 comments on commit 9ccadfa

Please sign in to comment.