Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: nyu-mll/jiant
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v2.2.0
Choose a base ref
...
head repository: nyu-mll/jiant
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 13 commits
  • 64 files changed
  • 5 contributors

Commits on May 21, 2021

  1. Update setup.py

    jeswan authored May 21, 2021
    Copy the full SHA
    310f22b View commit details

Commits on Jul 9, 2021

  1. Copy the full SHA
    2666eb9 View commit details

Commits on Jul 26, 2021

  1. Fix xlm-r loading (#1329)

    zphang authored Jul 26, 2021
    Copy the full SHA
    51e9be2 View commit details

Commits on Oct 17, 2021

  1. Copy the full SHA
    386d4e7 View commit details

Commits on Dec 31, 2021

  1. Bump lxml from 4.6.3 to 4.6.5 (#1344)

    Bumps [lxml](https://github.com/lxml/lxml) from 4.6.3 to 4.6.5.
    - [Release notes](https://github.com/lxml/lxml/releases)
    - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
    - [Commits](lxml/lxml@lxml-4.6.3...lxml-4.6.5)
    
    ---
    updated-dependencies:
    - dependency-name: lxml
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 31, 2021
    Copy the full SHA
    f71d0ba View commit details

Commits on Feb 3, 2022

  1. Copy the full SHA
    127e021 View commit details

Commits on Mar 31, 2022

  1. Copy the full SHA
    f9e0e7c View commit details

Commits on Jun 23, 2022

  1. Update dependencies (#1351)

    * versions
    
    * black
    zphang authored Jun 23, 2022
    Copy the full SHA
    e6d9062 View commit details

Commits on Oct 16, 2022

  1. Copy the full SHA
    132f07f View commit details

Commits on Oct 17, 2022

  1. updates

    zphang committed Oct 17, 2022
    Copy the full SHA
    8d13a82 View commit details
  2. libs (#1356)

    zphang authored Oct 17, 2022
    Copy the full SHA
    ebb4b37 View commit details
  3. Bump lxml from 4.6.5 to 4.9.1 (#1352)

    Bumps [lxml](https://github.com/lxml/lxml) from 4.6.5 to 4.9.1.
    - [Release notes](https://github.com/lxml/lxml/releases)
    - [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
    - [Commits](lxml/lxml@lxml-4.6.5...lxml-4.9.1)
    
    ---
    updated-dependencies:
    - dependency-name: lxml
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 17, 2022
    Copy the full SHA
    3cf0de2 View commit details
  4. Black (#1357)

    * libs
    
    * black
    zphang authored Oct 17, 2022
    Copy the full SHA
    daa5a25 View commit details
Showing with 611 additions and 207 deletions.
  1. +1 −1 .circleci/config.yml
  2. +2 −0 README.md
  3. +7 −2 jiant/proj/main/components/container_setup.py
  4. +2 −1 jiant/proj/main/components/evaluate.py
  5. +5 −2 jiant/proj/main/components/task_sampler.py
  6. +2 −1 jiant/proj/main/components/write_configs.py
  7. +2 −1 jiant/proj/main/export_model.py
  8. +7 −3 jiant/proj/main/metarunner.py
  9. +14 −6 jiant/proj/main/modeling/model_setup.py
  10. +6 −2 jiant/proj/main/modeling/primary.py
  11. +42 −13 jiant/proj/main/modeling/taskmodels.py
  12. +6 −2 jiant/proj/main/preprocessing.py
  13. +30 −9 jiant/proj/main/runner.py
  14. +2 −1 jiant/proj/main/runscript.py
  15. +14 −5 jiant/proj/main/scripts/configurator.py
  16. +5 −2 jiant/proj/main/tokenize_and_cache.py
  17. +12 −4 jiant/proj/simple/runscript.py
  18. +9 −9 jiant/scripts/benchmarks/xtreme/subscripts/d_write_configs.sh
  19. +22 −9 jiant/scripts/benchmarks/xtreme/xtreme_submission.py
  20. +20 −10 jiant/scripts/download_data/dl_datasets/files_tasks.py
  21. +2 −1 jiant/scripts/download_data/dl_datasets/hf_datasets_tasks.py
  22. +38 −19 jiant/scripts/download_data/dl_datasets/xtreme.py
  23. +2 −1 jiant/scripts/download_data/runscript.py
  24. +20 −1 jiant/scripts/download_data/utils.py
  25. +5 −2 jiant/scripts/preproc/export_glue_data.py
  26. +5 −2 jiant/shared/initialization.py
  27. +6 −0 jiant/shared/model_resolution.py
  28. +6 −2 jiant/shared/model_setup.py
  29. +10 −3 jiant/shared/runner.py
  30. +11 −2 jiant/tasks/core.py
  31. +60 −16 jiant/tasks/evaluate/core.py
  32. +3 −1 jiant/tasks/lib/acceptability_judgement/base.py
  33. +6 −1 jiant/tasks/lib/arct.py
  34. +9 −3 jiant/tasks/lib/bucc2018.py
  35. +25 −7 jiant/tasks/lib/ccg.py
  36. +1 −1 jiant/tasks/lib/commitmentbank.py
  37. +13 −3 jiant/tasks/lib/commonsenseqa.py
  38. +3 −1 jiant/tasks/lib/mlm_premasked.py
  39. +3 −1 jiant/tasks/lib/mlm_pretokenized.py
  40. +2 −1 jiant/tasks/lib/mlm_simple.py
  41. +3 −1 jiant/tasks/lib/mlqa.py
  42. +13 −4 jiant/tasks/lib/panx.py
  43. +6 −1 jiant/tasks/lib/ropes.py
  44. +17 −5 jiant/tasks/lib/tatoeba.py
  45. +2 −1 jiant/tasks/lib/templates/edge_probing_single_span.py
  46. +2 −1 jiant/tasks/lib/templates/edge_probing_two_span.py
  47. +2 −1 jiant/tasks/lib/templates/hacky_tokenization_matching.py
  48. +12 −4 jiant/tasks/lib/templates/mlm.py
  49. +9 −3 jiant/tasks/lib/templates/mlm_premasked.py
  50. +14 −5 jiant/tasks/lib/templates/shared.py
  51. +14 −3 jiant/tasks/lib/templates/squad_style/core.py
  52. +3 −1 jiant/tasks/lib/tydiqa.py
  53. +16 −5 jiant/tasks/lib/udpos.py
  54. +2 −1 jiant/tasks/lib/wsc.py
  55. +6 −2 jiant/tasks/lib/xnli.py
  56. +3 −1 jiant/tasks/lib/xquad.py
  57. +3 −1 jiant/tasks/retrieval.py
  58. +6 −1 jiant/utils/display.py
  59. +5 −1 jiant/utils/path_parse.py
  60. +9 −1 jiant/utils/python/filesystem.py
  61. +6 −3 jiant/utils/zconf/core.py
  62. +1 −1 requirements-dev.txt
  63. +2 −2 requirements-no-torch.txt
  64. +15 −7 setup.py
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ orbs:
jobs:
test:
docker:
- image: python:3.7
- image: python:3.8
steps:
- checkout
- restore_cache:
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
🚨**Update**🚨: As of 2021/10/17, the `jiant` project is no longer being actively maintained. This means there will be no plans to add new models, tasks, or features, or update support to new libraries.

<div align="center">

# `jiant` is an NLP toolkit
9 changes: 7 additions & 2 deletions jiant/proj/main/components/container_setup.py
Original file line number Diff line number Diff line change
@@ -76,7 +76,11 @@ def create_task_dict(task_config_dict: dict, verbose: bool = True) -> Dict[str,
if not task.name == task_name:
warnings.warn(
"task {} from {} has conflicting names: {}/{}. Using {}".format(
task_name, task_config_path, task_name, task.name, task_name,
task_name,
task_config_path,
task_name,
task.name,
task_name,
)
)
task.name = task_name
@@ -205,7 +209,8 @@ def create_jiant_task_container(
task_run_config = TaskRunConfig.from_dict(task_run_config)

num_train_examples_dict = get_num_train_examples(
task_cache_dict=task_cache_dict, train_task_list=task_run_config.train_task_list,
task_cache_dict=task_cache_dict,
train_task_list=task_run_config.train_task_list,
)
task_sampler = jiant_task_sampler.create_task_sampler(
sampler_config=sampler_config,
3 changes: 2 additions & 1 deletion jiant/proj/main/components/evaluate.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,8 @@
def write_val_results(val_results_dict, metrics_aggregator, output_dir, verbose=True):
full_results_to_write = {
"aggregated": jiant_task_sampler.compute_aggregate_major_metrics_from_results_dict(
metrics_aggregator=metrics_aggregator, results_dict=val_results_dict,
metrics_aggregator=metrics_aggregator,
results_dict=val_results_dict,
),
}
for task_name, task_results in val_results_dict.items():
7 changes: 5 additions & 2 deletions jiant/proj/main/components/task_sampler.py
Original file line number Diff line number Diff line change
@@ -137,7 +137,8 @@ def get_task_p(self, steps=None) -> np.ndarray:

for i, task_name in enumerate(self.task_names):
p_ls[i] = numexpr.evaluate(
self.task_to_unnormalized_prob_funcs_dict[task_name], local_dict={"t": t},
self.task_to_unnormalized_prob_funcs_dict[task_name],
local_dict={"t": t},
)
p_ls /= p_ls.sum()
return p_ls
@@ -171,7 +172,9 @@ def create_task_sampler(
elif sampler_type == "ProportionalMultiTaskSampler":
assert len(sampler_config) == 1
return ProportionalMultiTaskSampler(
task_dict=task_dict, rng=rng, task_to_num_examples_dict=task_to_num_examples_dict,
task_dict=task_dict,
rng=rng,
task_to_num_examples_dict=task_to_num_examples_dict,
)
elif sampler_type == "SpecifiedProbMultiTaskSampler":
assert len(sampler_config) == 2
3 changes: 2 additions & 1 deletion jiant/proj/main/components/write_configs.py
Original file line number Diff line number Diff line change
@@ -20,7 +20,8 @@ def write_configs(config_dict, base_path):
assert os.path.exists(path)
for config_key in config_keys:
py_io.write_json(
config_dict[config_key], os.path.join(base_path, f"{config_key}.json"),
config_dict[config_key],
os.path.join(base_path, f"{config_key}.json"),
)
py_io.write_json(config_dict, os.path.join(base_path, "full.json"))
py_io.write_json(
3 changes: 2 additions & 1 deletion jiant/proj/main/export_model.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@ class RunConfiguration(zconf.RunConfig):


def export_model(
hf_pretrained_model_name_or_path: str, output_base_path: str,
hf_pretrained_model_name_or_path: str,
output_base_path: str,
):
"""Retrieve model and tokenizer from Transformers and save all necessary data
Things saved:
10 changes: 7 additions & 3 deletions jiant/proj/main/metarunner.py
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ class ValState(ExtendedDataClassMixin):
def new(self):
# noinspection PyArgumentList
return self.__class__(
score=self.score, metrics=self.metrics, train_state=self.train_state.new(),
score=self.score,
metrics=self.metrics,
train_state=self.train_state.new(),
)

def to_dict(self):
@@ -104,7 +106,8 @@ def yield_train_step(self):
train_iterator = self.runner.run_train_context(verbose=self.verbose)
else:
train_iterator = self.runner.resume_train_context(
train_state=self.train_state, verbose=self.verbose,
train_state=self.train_state,
verbose=self.verbose,
)
for train_state in train_iterator:
self.train_state = train_state
@@ -242,7 +245,8 @@ def eval_save(self):
self.log_writer.write_entry("train_val_best", self.best_val_state.to_dict())
del self.best_state_dict
self.best_state_dict = copy_state_dict(
state_dict=get_model_for_saving(self.model).state_dict(), target_device=CPU_DEVICE,
state_dict=get_model_for_saving(self.model).state_dict(),
target_device=CPU_DEVICE,
)
if self.save_best_model:
self.save_best_model_with_metadata(val_metrics_dict=val_metrics_dict)
20 changes: 14 additions & 6 deletions jiant/proj/main/modeling/model_setup.py
Original file line number Diff line number Diff line change
@@ -105,14 +105,18 @@ def delegate_load(jiant_model, weights_dict: dict, load_mode: str):
"""
if load_mode == "from_transformers":
return load_encoder_from_transformers_weights(
encoder=jiant_model.encoder, weights_dict=weights_dict,
encoder=jiant_model.encoder,
weights_dict=weights_dict,
)
elif load_mode == "from_transformers_with_mlm":
remainder = load_encoder_from_transformers_weights(
encoder=jiant_model.encoder, weights_dict=weights_dict, return_remainder=True,
encoder=jiant_model.encoder,
weights_dict=weights_dict,
return_remainder=True,
)
load_lm_heads_from_transformers_weights(
jiant_model=jiant_model, weights_dict=remainder,
jiant_model=jiant_model,
weights_dict=remainder,
)
return
elif load_mode == "all":
@@ -121,11 +125,15 @@ def delegate_load(jiant_model, weights_dict: dict, load_mode: str):
return load_encoder_only(jiant_model=jiant_model, weights_dict=weights_dict)
elif load_mode == "partial_weights":
return load_partial_heads(
jiant_model=jiant_model, weights_dict=weights_dict, allow_missing_head_weights=True,
jiant_model=jiant_model,
weights_dict=weights_dict,
allow_missing_head_weights=True,
)
elif load_mode == "partial_heads":
return load_partial_heads(
jiant_model=jiant_model, weights_dict=weights_dict, allow_missing_head_model=True,
jiant_model=jiant_model,
weights_dict=weights_dict,
allow_missing_head_model=True,
)
elif load_mode == "partial":
return load_partial_heads(
@@ -157,7 +165,7 @@ def load_encoder_from_transformers_weights(
remainder_weights_dict = {}
load_weights_dict = {}
model_arch = ModelArchitectures.from_model_type(model_type=encoder.config.model_type)
encoder_prefix = model_arch.value + "."
encoder_prefix = model_arch.get_encoder_prefix() + "."
# Encoder
for k, v in weights_dict.items():
if k.startswith(encoder_prefix):
8 changes: 6 additions & 2 deletions jiant/proj/main/modeling/primary.py
Original file line number Diff line number Diff line change
@@ -75,7 +75,9 @@ def forward(self, batch: BatchMixin, task: Task, compute_loss: bool = False):
taskmodel_key = self.task_to_taskmodel_map[task_name]
taskmodel = self.taskmodels_dict[taskmodel_key]
return taskmodel(
batch=batch, tokenizer=self.tokenizer, compute_loss=compute_loss,
batch=batch,
tokenizer=self.tokenizer,
compute_loss=compute_loss,
).to_dict()


@@ -105,7 +107,9 @@ def wrap_jiant_forward(
is_multi_gpu = isinstance(jiant_model, nn.DataParallel)
model_output = construct_output_from_dict(
jiant_model(
batch=batch.to_dict() if is_multi_gpu else batch, task=task, compute_loss=compute_loss,
batch=batch.to_dict() if is_multi_gpu else batch,
task=task,
compute_loss=compute_loss,
)
)
if is_multi_gpu and compute_loss:
55 changes: 42 additions & 13 deletions jiant/proj/main/modeling/taskmodels.py
Original file line number Diff line number Diff line change
@@ -79,12 +79,17 @@ def __init__(self, task, encoder, head: heads.ClassificationHead, **kwargs):

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(pooled=encoder_output.pooled)
if compute_loss:
loss_fct = nn.CrossEntropyLoss()
loss = loss_fct(logits.view(-1, self.head.num_labels), batch.label_id.view(-1),)
loss = loss_fct(
logits.view(-1, self.head.num_labels),
batch.label_id.view(-1),
)
return LogitsAndLossOutput(logits=logits, loss=loss, other=encoder_output.other)
else:
return LogitsOutput(logits=logits, other=encoder_output.other)
@@ -97,7 +102,9 @@ def __init__(self, task, encoder, head: heads.RegressionHead, **kwargs):

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
# TODO: Abuse of notation - these aren't really logits (issue #1187)
logits = self.head(pooled=encoder_output.pooled)
@@ -133,7 +140,10 @@ def forward(self, batch, tokenizer, compute_loss: bool = False):
for j in range(len(encoder_output_other_ls[0])):
reshaped_outputs.append(
[
torch.stack([misc[j][layer_i] for misc in encoder_output_other_ls], dim=1,)
torch.stack(
[misc[j][layer_i] for misc in encoder_output_other_ls],
dim=1,
)
for layer_i in range(len(encoder_output_other_ls[0][0]))
]
)
@@ -168,12 +178,17 @@ def forward(self, batch, tokenizer, compute_loss: bool = False):
TYPE: Description
"""
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(unpooled=encoder_output.unpooled, spans=batch.spans)
if compute_loss:
loss_fct = nn.CrossEntropyLoss()
loss = loss_fct(logits.view(-1, self.head.num_labels), batch.label_id.view(-1),)
loss = loss_fct(
logits.view(-1, self.head.num_labels),
batch.label_id.view(-1),
)
return LogitsAndLossOutput(logits=logits, loss=loss, other=encoder_output.other)
else:
return LogitsOutput(logits=logits, other=encoder_output.other)
@@ -190,7 +205,9 @@ def __init__(self, task, encoder, head: heads.TokenClassificationHead, **kwargs)

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(unpooled=encoder_output.unpooled)
# Ensure logits in valid range is at least self.offset_margin higher than others
@@ -199,7 +216,8 @@ def forward(self, batch, tokenizer, compute_loss: bool = False):
if compute_loss:
loss_fct = nn.CrossEntropyLoss()
loss = loss_fct(
logits.transpose(dim0=1, dim1=2).flatten(end_dim=1), batch.gt_span_idxs.flatten(),
logits.transpose(dim0=1, dim1=2).flatten(end_dim=1),
batch.gt_span_idxs.flatten(),
)
return LogitsAndLossOutput(logits=logits, loss=loss, other=encoder_output.other)
else:
@@ -213,12 +231,17 @@ def __init__(self, task, encoder, head: heads.SpanComparisonHead, **kwargs):

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(unpooled=encoder_output.unpooled, spans=batch.spans)
if compute_loss:
loss_fct = nn.BCEWithLogitsLoss()
loss = loss_fct(logits.view(-1, self.head.num_labels), batch.label_ids.float(),)
loss = loss_fct(
logits.view(-1, self.head.num_labels),
batch.label_ids.float(),
)
return LogitsAndLossOutput(logits=logits, loss=loss, other=encoder_output.other)
else:
return LogitsOutput(logits=logits, other=encoder_output.other)
@@ -233,7 +256,9 @@ def __init__(self, task, encoder, head: heads.TokenClassificationHead, **kwargs)

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(unpooled=encoder_output.unpooled)
if compute_loss:
@@ -254,7 +279,9 @@ def __init__(self, task, encoder, head: heads.QAHead, **kwargs):

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)
logits = self.head(unpooled=encoder_output.unpooled)
if compute_loss:
@@ -300,7 +327,9 @@ def __init__(self, task, encoder, head: heads.AbstractPoolerHead, **kwargs):

def forward(self, batch, tokenizer, compute_loss: bool = False):
encoder_output = self.encoder.encode(
input_ids=batch.input_ids, segment_ids=batch.segment_ids, input_mask=batch.input_mask,
input_ids=batch.input_ids,
segment_ids=batch.segment_ids,
input_mask=batch.input_mask,
)

# A tuple of layers of hidden states
8 changes: 6 additions & 2 deletions jiant/proj/main/preprocessing.py
Original file line number Diff line number Diff line change
@@ -51,7 +51,9 @@ def smart_truncate(dataset: torch_utils.ListDataset, max_seq_length: int, verbos
for datum in maybe_tqdm(dataset.data, desc="Smart truncate data", verbose=verbose):
new_datum_ls.append(
smart_truncate_datum(
datum=datum, max_seq_length=max_seq_length, max_valid_length=max_valid_length,
datum=datum,
max_seq_length=max_seq_length,
max_valid_length=max_valid_length,
)
)
new_dataset = torch_utils.ListDataset(new_datum_ls)
@@ -70,7 +72,9 @@ def smart_truncate_cache(
for datum in maybe_tqdm(chunk, desc="Smart truncate chunk-datum", verbose=verbose):
new_chunk.append(
smart_truncate_datum(
datum=datum, max_seq_length=max_seq_length, max_valid_length=max_valid_length,
datum=datum,
max_seq_length=max_seq_length,
max_valid_length=max_valid_length,
)
)
torch.save(new_chunk, cache.get_chunk_path(chunk_i))
Loading