The Wayback Machine - https://web.archive.org/web/20210119225543/https://github.com/microsoft/nlp-recipes/pull/586
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

update utils and examples #586

Merged
merged 12 commits into from May 13, 2020
Merged

update utils and examples #586

merged 12 commits into from May 13, 2020

Conversation

@saidbleik
Copy link
Collaborator

@saidbleik saidbleik commented May 5, 2020

Description

  • Updated NER example to improve usability based on feedback.
  • Switched to automodels in transformers to support a wider range of pre-trained models

Checklist:

  • My code follows the code style of this project, as detailed in our contribution guidelines.
  • I have added tests.
  • I have updated the documentation accordingly.
@review-notebook-app
Copy link

@review-notebook-app review-notebook-app bot commented May 5, 2020

Check out this pull request on  ReviewNB

Review Jupyter notebook visual diffs & provide feedback on notebooks.


Powered by ReviewNB

@saidbleik saidbleik requested a review from sharatsc May 5, 2020
@saidbleik saidbleik requested a review from daden-ms May 5, 2020
@@ -77,7 +87,7 @@ def get_inputs(batch, device, model_name, train_mode=True):
Labels are only returned when train_mode is True.
"""
batch = tuple(t.to(device) for t in batch)
if model_name.split("-")[0] in ["bert", "distilbert"]:
if model_name in list(TC_MODEL_CLASS):

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

model_name is not optional in this function. The documentation needs to be changed.

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

can do_lower_case be handled within the function, instead of being passed as an argument to avoid mismatch?

"Text after tokenization with length {} has been truncated".format(
len(new_tokens)
)
)
new_tokens = new_tokens[:max_len]
new_labels = new_labels[:max_len]

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

function fit_to_block_size and build_mask from abstractive_summarization_bertsum.py (originally from huggingface's transformers) can be reused here and probably much easier to comprehend.

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

I feel processing the dataset per example is much cleaner way to see what preprocessing is needed. Also if you choose to process the dataset one example at a time, there is no need to return a TensorDataset, a list of dictionary suffices, and in your get_inputs function, you can specify the field, instead of using the index 0, 1 to track what the inputs requires. It's up to you to decide whether you want to make this change or not.

@@ -398,7 +405,9 @@ def fit(

# init scheduler
scheduler = Transformer.get_default_scheduler(
optimizer=self.optimizer, warmup_steps=warmup_steps, num_training_steps=max_steps
optimizer=self.optimizer,

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

should we use dataset instead of dataloader to make it consistent with other transformer models?

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

same for predict function

This comment has been minimized.

@daden-ms

daden-ms May 6, 2020
Collaborator

can the predict function take the label_map to provide the entity labels directly without having the users call the get_predicted_token_labels?

Copy link
Collaborator

@daden-ms daden-ms left a comment

Nice work. I put in some comments and might require significant changes. It's up to you to decide whether you want to make those changes or not, The PR looks great by itself.

@saidbleik saidbleik changed the title update NER example update utils and examples May 8, 2020
saidbleik added 8 commits May 8, 2020
Copy link
Collaborator

@daden-ms daden-ms left a comment

looks good to me. Just one last comment, do we want to check-in the output of the cells in the Jupiter notebooks?

@saidbleik
Copy link
Collaborator Author

@saidbleik saidbleik commented May 11, 2020

looks good to me. Just one last comment, do we want to check-in the output of the cells in the Jupiter notebooks?

In general, yes. The NER notebook now includes cells' output.

@saidbleik saidbleik merged commit e02e3b5 into staging May 13, 2020
4 of 5 checks passed
4 of 5 checks passed
gpu_unit_tests_linux #20200512.1 failed
Details
cpu_unit_tests_linux #20200512.1 succeeded
Details
license/cla All CLA requirements met.
Details
notebooks_cpu_unit_tests_linux Build #20200512.1 succeeded
Details
notebooks_gpu_unit_tests_linux Build #20200512.1 succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.