text_ranking.py 1.1 KB

12345678910111213141516171819202122232425
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. from modelscope.metainfo import Models
  3. from modelscope.models.builder import MODELS
  4. from modelscope.models.nlp import ModelForTextRanking
  5. from modelscope.utils import logger as logging
  6. from modelscope.utils.constant import Tasks
  7. logger = logging.get_logger()
  8. @MODELS.register_module(Tasks.text_ranking, module_name=Models.bert)
  9. class BertForTextRanking(ModelForTextRanking):
  10. r"""Bert Model transformer with a sequence classification/regression head on top
  11. (a linear layer on top of the pooled output) e.g. for GLUE tasks.
  12. This model inherits from :class:`SequenceClassificationModel`. Check the superclass documentation for the generic
  13. methods the library implements for all its model (such as downloading or saving, resizing the input embeddings,
  14. pruning heads etc.)
  15. This model is also a PyTorch `torch.nn.Module <https://pytorch.org/docs/stable/nn.html#torch.nn.Module>`__
  16. subclass. Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to
  17. general usage and behavior.
  18. """
  19. base_model_type = 'bert'