Fix issues with minification (Closes #300) #307
Merged
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.
This PR fixes issues that arise from using
this.constructor.name
orthis.name
to determine which model should be instantiated when doingfrom_pretrained
, after minification. This is because the class names are changed to things likett
orte
and so do not correspond to their correct names (#283). We overcome this limitation by storing a bidirectional mapping from class names (e.g.,'BertForSequenceClassification'
) and the class name (could beBertForSequenceClassification
if unminified, or, say,te
if minified). Although this does require a bit more boilerplate when adding new models, it should reduce issues that arise in future.One solution (which I did not go for) is to simply not minify class names. However, this would require all users of the library to do the same, and may defeat the purposes of minification. It also increases bundle size, which is not ideal.