THUDM / SwissArmyTransformer

SwissArmyTransformer is a flexible and powerful library to develop your own Transformer variants.
https://THUDM.github.io/SwissArmyTransformer
Apache License 2.0
987 stars 95 forks source link

dynamic loading #83

Closed 1049451037 closed 1 year ago

1049451037 commented 1 year ago

I made three modifications in this commit:

  1. Use Registry and MetaModel to support dynamic loading. Models inherent from BaseModel will automatically registered. Users can also add a @model_registry.register decorator to model to support AutoModel.from_pretrained.
  2. Add build_only argument to from_pretrained. This helps in some cases where users only want to build model using model_config.json without loading checkpoint weights.
  3. Fix some typo in README.md.

For use cases about 1, I think it may helpful for three cases:

  1. Users may want to load models with different model classes sometimes. So users don't need to add redundant if statements, just use AutoModel.
  2. There may be some third-party package based on sat under some other license in the future. They can also contribute to us without adding their models in model/official.
  3. When I want to debug a model locally, I don't need to install sat with -e option to put my model code to official.