__init__.py 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. # Copyright (c) Alibaba, Inc. and its affiliates.
  2. from typing import TYPE_CHECKING
  3. from modelscope.utils.import_utils import LazyImportModule
  4. if TYPE_CHECKING:
  5. from .bart import BartForTextErrorCorrection
  6. from .bert import (
  7. BertForMaskedLM,
  8. BertForTextRanking,
  9. BertForSentenceEmbedding,
  10. BertForSequenceClassification,
  11. BertForTokenClassification,
  12. BertForDocumentSegmentation,
  13. BertModel,
  14. BertConfig,
  15. SiameseUieModel,
  16. )
  17. from .bloom import BloomModel, BloomForTextGeneration
  18. from .codegeex import CodeGeeXForCodeTranslation, CodeGeeXForCodeGeneration
  19. from .glm_130b import GLM130bForTextGeneration
  20. from .csanmt import CsanmtForTranslation
  21. from .canmt import CanmtForTranslation
  22. from .polylm import PolyLMForTextGeneration
  23. from .deberta_v2 import DebertaV2ForMaskedLM, DebertaV2Model
  24. from .chatglm import ChatGLMForConditionalGeneration, ChatGLMTokenizer, ChatGLMConfig
  25. from .chatglm2 import ChatGLM2ForConditionalGeneration, ChatGLM2Tokenizer, ChatGLM2Config
  26. from .gpt_neo import GPTNeoModel
  27. from .gpt2 import GPT2Model
  28. from .gpt3 import GPT3ForTextGeneration, DistributedGPT3
  29. from .gpt_moe import GPTMoEForTextGeneration, DistributedGPTMoE
  30. from .heads import TextClassificationHead
  31. from .hf_transformers import TransformersModel
  32. from .lstm import (
  33. LSTMModel,
  34. LSTMForTokenClassificationWithCRF,
  35. )
  36. from .megatron_bert import (
  37. MegatronBertConfig,
  38. MegatronBertForMaskedLM,
  39. MegatronBertModel,
  40. )
  41. from .mglm import MGLMForTextSummarization
  42. from .palm_v2 import PalmForTextGeneration
  43. from .plug_mental import (PlugMentalConfig, PlugMentalModel,
  44. PlugMentalForSequenceClassification)
  45. from .ponet import PoNetForMaskedLM, PoNetModel, PoNetConfig
  46. from .space import SpaceForDialogIntent, SpaceForDialogModeling, SpaceForDST
  47. from .space_T_cn import TableQuestionAnswering
  48. from .space_T_en import StarForTextToSql
  49. from .structbert import (
  50. SbertForFaqQuestionAnswering,
  51. SbertForMaskedLM,
  52. SbertForSequenceClassification,
  53. SbertForTokenClassification,
  54. SbertModel,
  55. )
  56. from .T5 import T5ForConditionalGeneration
  57. from .task_models import (
  58. ModelForFeatureExtraction,
  59. ModelForInformationExtraction,
  60. ModelForTextClassification,
  61. SingleBackboneTaskModelBase,
  62. ModelForTextGeneration,
  63. ModelForTextRanking,
  64. ModelForTokenClassification,
  65. ModelForTokenClassificationWithCRF,
  66. ModelForMachineReadingComprehension,
  67. )
  68. from .unite import UniTEForTranslationEvaluation
  69. from .use import UserSatisfactionEstimation
  70. from .veco import (VecoConfig, VecoForMaskedLM,
  71. VecoForSequenceClassification,
  72. VecoForTokenClassification, VecoModel)
  73. from .dgds import (DocumentGroundedDialogGenerateModel,
  74. DocumentGroundedDialogRetrievalModel,
  75. DocumentGroundedDialogRerankModel)
  76. from .xlm_roberta import XLMRobertaConfig, XLMRobertaModel
  77. from .llama import LlamaForTextGeneration, LlamaConfig, LlamaModel, LlamaTokenizer, LlamaTokenizerFast
  78. from .llama2 import Llama2ForTextGeneration, Llama2Config, Llama2Model, Llama2Tokenizer, Llama2TokenizerFast
  79. from .qwen import QWenForTextGeneration, QWenConfig, QWenModel, QWenTokenizer
  80. else:
  81. _import_structure = {
  82. 'bart': ['BartForTextErrorCorrection'],
  83. 'bert': [
  84. 'BertForMaskedLM',
  85. 'BertForTextRanking',
  86. 'BertForSentenceEmbedding',
  87. 'BertForSequenceClassification',
  88. 'BertForTokenClassification',
  89. 'BertForDocumentSegmentation',
  90. 'BertModel',
  91. 'BertConfig',
  92. 'SiameseUieModel',
  93. ],
  94. 'bloom': ['BloomModel', 'BloomForTextGeneration'],
  95. 'csanmt': ['CsanmtForTranslation'],
  96. 'canmt': ['CanmtForTranslation'],
  97. 'polylm': ['PolyLMForTextGeneration'],
  98. 'codegeex':
  99. ['CodeGeeXForCodeTranslation', 'CodeGeeXForCodeGeneration'],
  100. 'glm_130b': ['GLM130bForTextGeneration'],
  101. 'deberta_v2': ['DebertaV2ForMaskedLM', 'DebertaV2Model'],
  102. 'chatglm': [
  103. 'ChatGLMForConditionalGeneration', 'ChatGLMTokenizer',
  104. 'ChatGLMConfig'
  105. ],
  106. 'chatglm2': [
  107. 'ChatGLM2ForConditionalGeneration', 'ChatGLM2Tokenizer',
  108. 'ChatGLM2Config'
  109. ],
  110. 'heads': ['TextClassificationHead'],
  111. 'hf_transformers': ['TransformersModel'],
  112. 'gpt2': ['GPT2Model'],
  113. 'gpt3': ['GPT3ForTextGeneration', 'DistributedGPT3'],
  114. 'gpt_moe': ['GPTMoEForTextGeneration', 'DistributedGPTMoE'],
  115. 'gpt_neo': ['GPTNeoModel'],
  116. 'structbert': [
  117. 'SbertForFaqQuestionAnswering',
  118. 'SbertForMaskedLM',
  119. 'SbertForSequenceClassification',
  120. 'SbertForTokenClassification',
  121. 'SbertModel',
  122. ],
  123. 'veco': [
  124. 'VecoConfig',
  125. 'VecoForMaskedLM',
  126. 'VecoForSequenceClassification',
  127. 'VecoForTokenClassification',
  128. 'VecoModel',
  129. ],
  130. 'lstm': [
  131. 'LSTM',
  132. 'LSTMForTokenClassificationWithCRF',
  133. ],
  134. 'megatron_bert': [
  135. 'MegatronBertConfig',
  136. 'MegatronBertForMaskedLM',
  137. 'MegatronBertModel',
  138. ],
  139. 'mglm': ['MGLMForTextSummarization'],
  140. 'palm_v2': ['PalmForTextGeneration'],
  141. 'plug_mental': [
  142. 'PlugMentalConfig',
  143. 'PlugMentalModel',
  144. 'PlugMentalForSequenceClassification',
  145. ],
  146. 'ponet': ['PoNetForMaskedLM', 'PoNetModel', 'PoNetConfig'],
  147. 'space_T_en': ['StarForTextToSql'],
  148. 'space_T_cn': ['TableQuestionAnswering'],
  149. 'space':
  150. ['SpaceForDialogIntent', 'SpaceForDialogModeling', 'SpaceForDST'],
  151. 'task_models': [
  152. 'ModelForFeatureExtraction',
  153. 'ModelForInformationExtraction',
  154. 'ModelForTextClassification',
  155. 'SingleBackboneTaskModelBase',
  156. 'ModelForTextGeneration',
  157. 'ModelForTextRanking',
  158. 'ModelForTokenClassification',
  159. 'ModelForTokenClassificationWithCRF',
  160. 'ModelForMachineReadingComprehension',
  161. ],
  162. 'sentence_embedding': ['SentenceEmbedding'],
  163. 'T5': ['T5ForConditionalGeneration'],
  164. 'unite': ['UniTEForTranslationEvaluation'],
  165. 'use': ['UserSatisfactionEstimation'],
  166. 'dgds': [
  167. 'DocumentGroundedDialogGenerateModel',
  168. 'DocumentGroundedDialogRetrievalModel',
  169. 'DocumentGroundedDialogRerankModel'
  170. ],
  171. 'xlm_roberta': ['XLMRobertaConfig', 'XLMRobertaModel'],
  172. 'llama': [
  173. 'LlamaForTextGeneration', 'LlamaConfig', 'LlamaModel',
  174. 'LlamaTokenizer', 'LlamaTokenizerFast'
  175. ],
  176. 'llama2': [
  177. 'Llama2ForTextGeneration', 'Llama2Config', 'Llama2Model',
  178. 'Llama2Tokenizer', 'Llama2TokenizerFast'
  179. ],
  180. 'qwen':
  181. ['QWenForTextGeneration', 'QWenConfig', 'QWenModel', 'QWenTokenizer'],
  182. }
  183. import sys
  184. sys.modules[__name__] = LazyImportModule(
  185. __name__,
  186. globals()['__file__'],
  187. _import_structure,
  188. module_spec=__spec__,
  189. extra_objects={},
  190. )