Skip to content
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
3 changes: 2 additions & 1 deletion lmeval/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ def load_benchmark(path: str, archive = None, use_tempfile: bool | None = None)
media_to_load = []
for category in benchmark.categories:
for task in category.tasks:
if isinstance(task.scorer.type, ScorerType):
scorer_values = set(item.value for item in ScorerType)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why don't you make a frozen set or add a class method in ScorerType to search so it's created once instead many times over.

if task.scorer.type in scorer_values:
scorer_name = str(task.scorer.type)
stype = ScorerType[scorer_name]
else:
Expand Down
6 changes: 5 additions & 1 deletion lmeval/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,13 @@ class Question(CustomModel):
# we need it for (de)serialization - automated added by Task.add()
id: int = Field(default=-1)
question: str | None = Field(default=None)
description: str = Field(default="")
language: str = Field(default="en")

# answer
answer: str | None = Field(default=None)
# old answer (e.g. in case the anwere (label) changed due to a manual review)
answer_old: str | None = Field(default=None)
# additional answers e.g. for multiple choice questions
additional_answers: List[str] = Field(default_factory=list)

Expand Down Expand Up @@ -94,6 +97,7 @@ def add_media(self, path: str| Path, filetype: FileType = FileType.auto,
".mp4": [FileType.mp4, Modality.video],
".py": [FileType.python, Modality.code],
".pdf": [FileType.pdf, Modality.document],
".html": [FileType.html, Modality.code],
}

# auto detection if needed
Expand Down Expand Up @@ -124,4 +128,4 @@ def _compute_file_hash(self, path: Path,

class GroupedQuestion(Question):
metadata: Dict[str, Any]
question_set: List[Question]
question_set: List[Question]