Browse Source

fix

master
suluyan 3 years ago
parent
commit
102943923e
3 changed files with 5 additions and 4 deletions
  1. +1
    -0
      modelscope/metainfo.py
  2. +4
    -3
      modelscope/models/nlp/masked_language_model.py
  3. +0
    -1
      tests/pipelines/test_fill_mask.py

+ 1
- 0
modelscope/metainfo.py View File

@@ -15,6 +15,7 @@ class Models(object):
bert = 'bert' bert = 'bert'
palm = 'palm-v2' palm = 'palm-v2'
structbert = 'structbert' structbert = 'structbert'
veco = 'veco'


# audio models # audio models
sambert_hifi_16k = 'sambert-hifi-16k' sambert_hifi_16k = 'sambert-hifi-16k'


+ 4
- 3
modelscope/models/nlp/masked_language_model.py View File

@@ -2,7 +2,8 @@ from typing import Any, Dict, Optional, Union


import numpy as np import numpy as np


from ...utils.constant import Tasks
from modelscope.metainfo import Models
from modelscope.utils.constant import Tasks
from ..base import Model, Tensor from ..base import Model, Tensor
from ..builder import MODELS from ..builder import MODELS


@@ -36,14 +37,14 @@ class AliceMindBaseForMaskedLM(Model):
return {'logits': rst['logits'], 'input_ids': inputs['input_ids']} return {'logits': rst['logits'], 'input_ids': inputs['input_ids']}




@MODELS.register_module(Tasks.fill_mask, module_name=r'sbert')
@MODELS.register_module(Tasks.fill_mask, module_name=Models.structbert)
class StructBertForMaskedLM(AliceMindBaseForMaskedLM): class StructBertForMaskedLM(AliceMindBaseForMaskedLM):
# The StructBert for MaskedLM uses the same underlying model structure # The StructBert for MaskedLM uses the same underlying model structure
# as the base model class. # as the base model class.
pass pass




@MODELS.register_module(Tasks.fill_mask, module_name=r'veco')
@MODELS.register_module(Tasks.fill_mask, module_name=Models.veco)
class VecoForMaskedLM(AliceMindBaseForMaskedLM): class VecoForMaskedLM(AliceMindBaseForMaskedLM):
# The Veco for MaskedLM uses the same underlying model structure # The Veco for MaskedLM uses the same underlying model structure
# as the base model class. # as the base model class.


+ 0
- 1
tests/pipelines/test_fill_mask.py View File

@@ -10,7 +10,6 @@ from modelscope.models.nlp import StructBertForMaskedLM, VecoForMaskedLM
from modelscope.pipelines import FillMaskPipeline, pipeline from modelscope.pipelines import FillMaskPipeline, pipeline
from modelscope.preprocessors import FillMaskPreprocessor from modelscope.preprocessors import FillMaskPreprocessor
from modelscope.utils.constant import Tasks from modelscope.utils.constant import Tasks
from modelscope.utils.hub import get_model_cache_dir
from modelscope.utils.test_utils import test_level from modelscope.utils.test_utils import test_level






Loading…
Cancel
Save