Unify model loading and REST APIs and improve CLI #241
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.
The primary goal of this PR is to unify the way we load different types of models, to minimize special-casing and simplify workflows where we want to compare different model types. Now all of our model types can be loaded with
AutoModel.from_pretrained()
, including CNN and LSTM models. Creating a new model is also standardized now—see the example notebook for drug review sentiment classification for a step-by-step training guide supporting all four model types.REST APIs
Our new model loading system solves the main issue with #239, where there was no obvious way to support loading different types of models. As such, this PR incorporates the changes in #239, but supporting all model types.
Updated arguments system and CLI
Now that every model has its own config class, it's redundant to also have a
CnlpModelArgs
dataclass. Additionally, theCnlpDataArgs
class was only really being used to initialize aCnlpDataset
. Both of these arguments dataclasses have been removed in this PR.The only thing those dataclasses were really useful for is having everything in one place for the CLI... but the UX of the existing CLI was... lacking. Since the args classes were being removed anyway, I took the opportunity to switch to
typer
for our CLI. Here's a before and after of what it looks like runningcnlpt train --help
: Before | After