-
Notifications
You must be signed in to change notification settings - Fork 18
text input that could be read as NA/None is now read as a string #215
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
spencerthomas1722
wants to merge
11
commits into
main
Choose a base branch
from
data_bugfix
base: main
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
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2bd994a
text input that could be read as NA/None is now read as a string
spencerthomas1722 60a1a72
re-implement support for cnlpt models
spencerthomas1722 37d0634
implement weight_classes for tagging tasks
spencerthomas1722 9455668
implement continued training with pretrained models
spencerthomas1722 dc10519
add methods for removing/adding classifier heads for cnlpt models
spencerthomas1722 2c3ebd7
add_task_classifier now accommodates relation tasks
spencerthomas1722 c5e07da
allow for evaluation of spans
spencerthomas1722 fb292d5
bug fixes
spencerthomas1722 5d78b86
add tlink rest functionality
spencerthomas1722 cf01bba
--error analysis shows all predictions, not just errors
spencerthomas1722 a2e0ad5
implement class_weights for relex task
spencerthomas1722 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 |
|---|---|---|
|
|
@@ -309,7 +309,10 @@ def main( | |
| dataset.tasks_to_labels[task] = dataset.tasks_to_labels[task][1:] + [ | ||
| dataset.tasks_to_labels[task][0] | ||
| ] | ||
| labels = dataset.processed_dataset["train"][task] | ||
| if tagger[task]: | ||
| labels = [token_label for sent in dataset.processed_dataset["train"][task] for token_label in sent.split()] | ||
| else: | ||
| labels = dataset.processed_dataset["train"][task] | ||
| weights = [] | ||
| label_counts = Counter(labels) | ||
| for label in dataset.tasks_to_labels[task]: | ||
|
|
@@ -478,25 +481,13 @@ def main( | |
| # in this case we're looking at a fine-tuned model (?) | ||
| character_level=data_args.character_level, | ||
| ) | ||
|
|
||
| if training_args.do_train: | ||
| # Setting 1) only load weights from the encoder | ||
| raise NotImplementedError( | ||
| "This functionality has not been restored yet" | ||
| ) | ||
| model = CnlpModelForClassification( | ||
| model_path=model_args.encoder_name, | ||
| config=config, | ||
| cache_dir=model_args.cache_dir, | ||
| tagger=tagger, | ||
| relations=relations, | ||
| class_weights=dataset.class_weights, | ||
| final_task_weight=training_args.final_task_weight, | ||
| use_prior_tasks=model_args.use_prior_tasks, | ||
| argument_regularization=model_args.arg_reg, | ||
| ) | ||
| delattr(model, "classifiers") | ||
| delattr(model, "feature_extractors") | ||
| if training_args.do_train: | ||
| tempmodel = tempfile.NamedTemporaryFile(dir=model_args.cache_dir) | ||
| torch.save(model.state_dict(), tempmodel) | ||
|
|
@@ -511,7 +502,6 @@ def main( | |
| freeze=training_args.freeze, | ||
| bias_fit=training_args.bias_fit, | ||
| ) | ||
|
|
||
| else: | ||
| # This only works when model_args.encoder_name is one of the | ||
| # model card from https://huggingface.co/models | ||
|
|
@@ -675,7 +665,7 @@ def compute_metrics_fn(p: EvalPrediction): | |
| model.best_eval_results = metrics | ||
| if trainer.is_world_process_zero(): | ||
| if training_args.do_train: | ||
| trainer.save_model() | ||
| trainer.save_model() # NOTE: a RobertaConfig is loaded here. why? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. did you want to keep this in here? |
||
| tokenizer.save_pretrained(training_args.output_dir) | ||
| if model_name == "cnn" or model_name == "lstm": | ||
| with open( | ||
|
|
@@ -884,7 +874,7 @@ def compute_metrics_fn(p: EvalPrediction): | |
|
|
||
| out_table = process_prediction( | ||
| task_names=dataset.tasks, | ||
| error_analysis=False, | ||
| error_analysis=training_args.error_analysis, | ||
| output_prob=training_args.output_prob, | ||
| character_level=data_args.character_level, | ||
| task_to_label_packet=task_to_label_packet, | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this definition will load a fine-tuned cnlpt model as an encoder, but re-initialize the classifier head. This would be the expected behavior for some use cases, but missing some use cases. I think we want to edit this to explicitly handle the two different cases (even if one still throws an exception), rather than having the user guess what might be happening. We should force them to specify whether to keep or ignore existing classifiers (as in the hier model).