You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

dialog_intent_pipeline.py 1.2 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738
  1. from typing import Any, Dict, Optional
  2. from maas_lib.models.nlp import DialogIntentModel
  3. from maas_lib.preprocessors import DialogIntentPreprocessor
  4. from maas_lib.utils.constant import Tasks
  5. from ...base import Input, Pipeline
  6. from ...builder import PIPELINES
  7. __all__ = ['DialogIntentPipeline']
  8. @PIPELINES.register_module(Tasks.dialog_intent, module_name=r'space-intent')
  9. class DialogIntentPipeline(Pipeline):
  10. def __init__(self, model: DialogIntentModel,
  11. preprocessor: DialogIntentPreprocessor, **kwargs):
  12. """use `model` and `preprocessor` to create a nlp text classification pipeline for prediction
  13. Args:
  14. model (SequenceClassificationModel): a model instance
  15. preprocessor (SequenceClassificationPreprocessor): a preprocessor instance
  16. """
  17. super().__init__(model=model, preprocessor=preprocessor, **kwargs)
  18. self.model = model
  19. # self.tokenizer = preprocessor.tokenizer
  20. def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, str]:
  21. """process the prediction results
  22. Args:
  23. inputs (Dict[str, Any]): _description_
  24. Returns:
  25. Dict[str, str]: the prediction results
  26. """
  27. return inputs

致力于通过开放的社区合作,开源AI模型以及相关创新技术,推动基于模型即服务的生态繁荣发展