yingda.chen wenmeng.zwm 3 years ago
parent
commit
043e498e01
13 changed files with 21 additions and 28 deletions
  1. +2
    -2
      LICENSE
  2. +5
    -11
      docs/README.md
  3. +1
    -1
      docs/source/conf.py
  4. +1
    -1
      docs/source/tutorials/pipeline.md
  5. +1
    -1
      maas_lib/models/base.py
  6. +0
    -1
      maas_lib/models/builder.py
  7. +1
    -1
      maas_lib/models/nlp/sequence_classification_model.py
  8. +2
    -2
      maas_lib/pipelines/base.py
  9. +2
    -2
      maas_lib/pipelines/nlp/sequence_classification_pipeline.py
  10. +1
    -1
      maas_lib/preprocessors/builder.py
  11. +2
    -2
      maas_lib/utils/constant.py
  12. +1
    -1
      maas_lib/utils/registry.py
  13. +2
    -2
      setup.py

+ 2
- 2
LICENSE View File

@@ -1,4 +1,4 @@
Copyright 2022-2023 Alibaba PAI. All rights reserved.
Copyright 2022-2023 Alibaba MaaS. All rights reserved.


Apache License Apache License
Version 2.0, January 2004 Version 2.0, January 2004
@@ -188,7 +188,7 @@ Copyright 2022-2023 Alibaba PAI. All rights reserved.
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.


Copyright 2020-2022 Alibaba PAI.
Copyright 2020-2022 Alibaba MaaS.


Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.


+ 5
- 11
docs/README.md View File

@@ -1,23 +1,17 @@
## maintain docs ## maintain docs
1. install requirements needed to build docs
1. build docs
```shell ```shell
# in maas_lib root dir
pip install requirements/docs.txt
# in root directory:
make docs
``` ```


2. build docs
```shell
# in maas_lib/docs dir
bash build_docs.sh
```

3. doc string format
2. doc string format


We adopt the google style docstring format as the standard, please refer to the following documents. We adopt the google style docstring format as the standard, please refer to the following documents.
1. Google Python style guide docstring [link](http://google.github.io/styleguide/pyguide.html#381-docstrings) 1. Google Python style guide docstring [link](http://google.github.io/styleguide/pyguide.html#381-docstrings)
2. Google docstring example [link](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html) 2. Google docstring example [link](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html)
3. sample:torch.nn.modules.conv [link](https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv1d) 3. sample:torch.nn.modules.conv [link](https://pytorch.org/docs/stable/_modules/torch/nn/modules/conv.html#Conv1d)
4. load fucntion as an example:
4. load function as an example:


```python ```python
def load(file, file_format=None, **kwargs): def load(file, file_format=None, **kwargs):


+ 1
- 1
docs/source/conf.py View File

@@ -19,7 +19,7 @@ sys.path.insert(0, os.path.abspath('../../'))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------


project = 'maas_lib' project = 'maas_lib'
copyright = '2022-2023, Alibaba PAI'
copyright = '2022-2023, Alibaba MaaS'
author = 'maas_lib Authors' author = 'maas_lib Authors'
version_file = '../../maas_lib/version.py' version_file = '../../maas_lib/version.py'




+ 1
- 1
docs/source/tutorials/pipeline.md View File

@@ -63,7 +63,7 @@ pipeline函数支持传入实例化的预处理对象、模型对象,从而支
wget https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/easynlp_modelzoo/alibaba-pai/bert-base-sst2.zip && unzip bert-base-sst2.zip wget https://atp-modelzoo-sh.oss-cn-shanghai.aliyuncs.com/release/easynlp_modelzoo/alibaba-pai/bert-base-sst2.zip && unzip bert-base-sst2.zip
``` ```


创建tokenzier和模型
创建tokenizer和模型
```python ```python
>>> from maas_lib.models.nlp import SequenceClassificationModel >>> from maas_lib.models.nlp import SequenceClassificationModel
>>> path = 'bert-base-sst2' >>> path = 'bert-base-sst2'


+ 1
- 1
maas_lib/models/base.py View File

@@ -26,4 +26,4 @@ class Model(ABC):


@classmethod @classmethod
def from_pretrained(cls, model_name_or_path: str, *model_args, **kwargs): def from_pretrained(cls, model_name_or_path: str, *model_args, **kwargs):
raise NotImplementedError('from_preatrained has not been implemented')
raise NotImplementedError('from_pretrained has not been implemented')

+ 0
- 1
maas_lib/models/builder.py View File

@@ -1,7 +1,6 @@
# Copyright (c) Alibaba, Inc. and its affiliates. # Copyright (c) Alibaba, Inc. and its affiliates.


from maas_lib.utils.config import ConfigDict from maas_lib.utils.config import ConfigDict
from maas_lib.utils.constant import Tasks
from maas_lib.utils.registry import Registry, build_from_cfg from maas_lib.utils.registry import Registry, build_from_cfg


MODELS = Registry('models') MODELS = Registry('models')


+ 1
- 1
maas_lib/models/nlp/sequence_classification_model.py View File

@@ -21,7 +21,7 @@ class SequenceClassificationModel(Model):
**kwargs): **kwargs):
# Model.__init__(self, model_dir, model_cls, first_sequence, *args, **kwargs) # Model.__init__(self, model_dir, model_cls, first_sequence, *args, **kwargs)
# Predictor.__init__(self, *args, **kwargs) # Predictor.__init__(self, *args, **kwargs)
"""initilize the sequence classification model from the `model_dir` path.
"""initialize the sequence classification model from the `model_dir` path.


Args: Args:
model_dir (str): the model path. model_dir (str): the model path.


+ 2
- 2
maas_lib/pipelines/base.py View File

@@ -25,10 +25,10 @@ class Pipeline(ABC):


def __call__(self, input: Union[Input, List[Input]], *args, def __call__(self, input: Union[Input, List[Input]], *args,
**post_kwargs) -> Dict[str, Any]: **post_kwargs) -> Dict[str, Any]:
# moodel provider should leave it as it is
# model provider should leave it as it is
# maas library developer will handle this function # maas library developer will handle this function


# simple show case, need to support iterator type for both tensorflow and pytorch
# simple showcase, need to support iterator type for both tensorflow and pytorch
# input_dict = self._handle_input(input) # input_dict = self._handle_input(input)
if isinstance(input, list): if isinstance(input, list):
output = [] output = []


+ 2
- 2
maas_lib/pipelines/nlp/sequence_classification_pipeline.py View File

@@ -39,13 +39,13 @@ class SequenceClassificationPipeline(Pipeline):
} }


def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, str]: def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, str]:
"""process the predict results
"""process the prediction results


Args: Args:
inputs (Dict[str, Any]): _description_ inputs (Dict[str, Any]): _description_


Returns: Returns:
Dict[str, str]: the predict results
Dict[str, str]: the prediction results
""" """


probs = inputs['probabilities'] probs = inputs['probabilities']


+ 1
- 1
maas_lib/preprocessors/builder.py View File

@@ -10,7 +10,7 @@ PREPROCESSORS = Registry('preprocessors')
def build_preprocessor(cfg: ConfigDict, def build_preprocessor(cfg: ConfigDict,
field_name: str = None, field_name: str = None,
default_args: dict = None): default_args: dict = None):
""" build preprocesor given model config dict
""" build preprocessor given model config dict


Args: Args:
cfg (:obj:`ConfigDict`): config dict for model object. cfg (:obj:`ConfigDict`): config dict for model object.


+ 2
- 2
maas_lib/utils/constant.py View File

@@ -35,10 +35,10 @@ class Tasks(object):
relation_extraction = 'relation-extraction' relation_extraction = 'relation-extraction'
zero_shot = 'zero-shot' zero_shot = 'zero-shot'
translation = 'translation' translation = 'translation'
token_classificatio = 'token-classification'
token_classification = 'token-classification'
conversational = 'conversational' conversational = 'conversational'
text_generation = 'text-generation' text_generation = 'text-generation'
table_question_answ = 'table-question-answering'
table_question_answering = 'table-question-answering'
feature_extraction = 'feature-extraction' feature_extraction = 'feature-extraction'
sentence_similarity = 'sentence-similarity' sentence_similarity = 'sentence-similarity'
fill_mask = 'fill-mask ' fill_mask = 'fill-mask '


+ 1
- 1
maas_lib/utils/registry.py View File

@@ -118,7 +118,7 @@ class Registry(object):
module_cls=module_cls) module_cls=module_cls)
return module_cls return module_cls


# if module_cls is None, should return a dectorator function
# if module_cls is None, should return a decorator function
def _register(module_cls): def _register(module_cls):
self._register_module( self._register_module(
group_key=group_key, group_key=group_key,


+ 2
- 2
setup.py View File

@@ -162,10 +162,10 @@ if __name__ == '__main__':
description='', description='',
long_description=readme(), long_description=readme(),
long_description_content_type='text/markdown', long_description_content_type='text/markdown',
author='Alibaba PAI team',
author='Alibaba MaaS team',
author_email='maas_lib@list.alibaba-inc.com', author_email='maas_lib@list.alibaba-inc.com',
keywords='', keywords='',
url='https://github.com/alibaba/EasyCV.git',
url='TBD',
packages=find_packages(exclude=('configs', 'tools', 'demo')), packages=find_packages(exclude=('configs', 'tools', 'demo')),
include_package_data=True, include_package_data=True,
classifiers=[ classifiers=[


Loading…
Cancel
Save