forked from EleutherAI/lm-evaluation-harness
-
Notifications
You must be signed in to change notification settings - Fork 29
Add XCOPA task #111
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
Open
haileyschoelkopf
wants to merge
5
commits into
bigscience-workshop:master
Choose a base branch
from
haileyschoelkopf:xcopa
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add XCOPA task #111
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,91 @@ | ||
| """ | ||
| Homepage: | ||
| """ | ||
| import typing | ||
|
|
||
| from lm_eval.api.task import PromptSourceTask | ||
|
|
||
|
|
||
| _CITATION = """ | ||
| @article{ponti2020xcopa, | ||
| title={{XCOPA: A} Multilingual Dataset for Causal Commonsense Reasoning}, | ||
| author={Edoardo M. Ponti, Goran Glava�{s}, Olga Majewska, Qianchu Liu, Ivan Vuli'{c} and Anna Korhonen}, | ||
| journal={arXiv preprint}, | ||
| year={2020}, | ||
| url={https://ducdauge.github.io/files/xcopa.pdf} | ||
| } | ||
| """ | ||
|
|
||
| class XCopaBase(PromptSourceTask): | ||
| VERSION = 0 | ||
| DATASET_PATH = "xcopa" | ||
| DATASET_NAME = None | ||
|
|
||
| def has_training_docs(self): | ||
| return False | ||
|
|
||
| def has_validation_docs(self): | ||
| return True | ||
|
|
||
| def has_test_docs(self): | ||
| return True | ||
|
|
||
| def validation_docs(self): | ||
| return self.dataset["validation"] | ||
|
|
||
| def test_docs(self): | ||
| return self.dataset["test"] | ||
|
|
||
| def invalid_doc_for_prompt(self, doc) -> bool: | ||
| # HACK: Some copa templates have conditionals that ignore documents | ||
| # when the condition is not met, like `{if doc['question'] != \"cause\"}`. | ||
| # This means the prompt will never produce an input and target. | ||
| try: | ||
| result = self.prompt_template.apply(doc) | ||
| if result == ['']: | ||
| return True | ||
| else: | ||
| return False | ||
jon-tow marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| except Exception: | ||
| return True | ||
|
|
||
| class XCopaId(XCopaBase): | ||
| DATASET_NAME = "id" | ||
|
|
||
| class XCopaIt(XCopaBase): | ||
| DATASET_NAME = "it" | ||
|
|
||
| class XCopaSw(XCopaBase): | ||
| DATASET_NAME = "sw" | ||
|
|
||
| class XCopaTa(XCopaBase): | ||
| DATASET_NAME = "ta" | ||
|
|
||
| class XCopaVi(XCopaBase): | ||
| DATASET_NAME = "vi" | ||
|
|
||
| class XCopaZh(XCopaBase): | ||
| DATASET_NAME = "zh" | ||
|
|
||
| XCOPA_TASKS = [ | ||
| XCopaId, | ||
| XCopaIt, | ||
| XCopaSw, | ||
| XCopaTa, | ||
| XCopaVi, | ||
| XCopaZh, | ||
| ] | ||
|
|
||
| def construct_tasks() -> typing.Dict[str, XCopaBase]: | ||
| """ | ||
| Returns a dictionary of tasks keyed by task name, for example: | ||
| "xcopa/id": XCopaId | ||
| will dispatch to the GEM WikiLingua Arabic class. | ||
| """ | ||
| tasks = {} | ||
| for task_class in XCOPA_TASKS: | ||
| benchmark = task_class.DATASET_PATH | ||
| lang = task_class.DATASET_NAME | ||
| tasks[f"{benchmark}_{lang}"] = task_class | ||
| return tasks | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.