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

Scitail #943

Merged
merged 6 commits into from
Oct 26, 2019
Merged
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
44 changes: 44 additions & 0 deletions jiant/tasks/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3241,3 +3241,47 @@ def get_metrics(self, reset=False):
"""Get metrics specific to the task"""
acc = self.scorer1.get_metric(reset)
return {"accuracy": acc}


@register_task("scitail", rel_path="SciTailV1.1/tsv_format/")
class SciTailTask(PairClassificationTask):
""" Task class for SciTail http://data.allenai.org/scitail/ """

def __init__(self, path, max_seq_len, name, **kw):
super().__init__(name, n_classes=2, **kw)
self.path = path
self.max_seq_len = max_seq_len

self.train_data_text = None
self.val_data_text = None
self.test_data_text = None

def load_data(self):
"""Process and load Scitail data"""
targ_map = {"neutral": 0, "entails": 1}
self.train_data_text = load_tsv(
self._tokenizer_name,
os.path.join(self.path, "scitail_1.0_train.tsv"),
max_seq_len=self.max_seq_len,
label_fn=targ_map.__getitem__,
)
self.val_data_text = load_tsv(
self._tokenizer_name,
os.path.join(self.path, "scitail_1.0_dev.tsv"),
max_seq_len=self.max_seq_len,
label_fn=targ_map.__getitem__,
)
self.test_data_text = load_tsv(
self._tokenizer_name,
os.path.join(self.path, "scitail_1.0_test.tsv"),
max_seq_len=self.max_seq_len,
label_fn=targ_map.__getitem__,
return_indices=True,
)
self.sentences = (
self.train_data_text[0]
+ self.train_data_text[1]
+ self.val_data_text[0]
+ self.val_data_text[1]
)
log.info("\tFinished loading SciTail")