Skip to content

Commit 2e0ee8e

Browse files
authored
Correct checkpoint`s URL for OPT Model. (#648)
1 parent 859a90f commit 2e0ee8e

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

mindnlp/models/opt/config_opt.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,15 @@
1515
""" OPT model configuration"""
1616

1717
from mindnlp.abc import PreTrainedConfig
18-
from mindnlp.configs import HF_CONFIG_URL_BASE
18+
from mindnlp.configs import MINDNLP_CONFIG_URL_BASE
1919

2020

2121
__all__ = ['OPTConfig']
2222

23-
OPT_SUPPORT_LIST = ["facebook/opt-350m"]
23+
OPT_SUPPORT_LIST = ["opt-350m"]
2424

25-
CONFIG_ARCHIVE_MAP = { # TODO: 替换链接
26-
# model: MINDNLP_CONFIG_URL_BASE.format('facebook', model) for model in OPT_SUPPORT_LIST
27-
model: HF_CONFIG_URL_BASE.format(model) for model in OPT_SUPPORT_LIST
25+
CONFIG_ARCHIVE_MAP = {
26+
model: MINDNLP_CONFIG_URL_BASE.format('opt', model) for model in OPT_SUPPORT_LIST
2827
}
2928

3029

mindnlp/models/opt/opt.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from mindspore.nn import CrossEntropyLoss, BCEWithLogitsLoss, MSELoss
2929
from mindspore.common.initializer import initializer, Normal
3030
from mindnlp.abc import PreTrainedModel
31-
from mindnlp.configs import HF_MODEL_URL_BASE
31+
from mindnlp.configs import MINDNLP_MODEL_URL_BASE
3232
from ..activations import ACT2FN
3333
from ..utils import Conv1D
3434
from .config_opt import OPTConfig, OPT_SUPPORT_LIST
@@ -41,9 +41,7 @@
4141
)
4242

4343
PRETRAINED_MODEL_ARCHIVE_MAP = {
44-
# TODO: 替换成MINDNLP
45-
# model: MINDNLP_MODEL_URL_BASE.format('gpt', model) for model in OPT_SUPPORT_LIST
46-
model: HF_MODEL_URL_BASE.format(model) for model in OPT_SUPPORT_LIST
44+
model: MINDNLP_MODEL_URL_BASE.format('opt', model) for model in OPT_SUPPORT_LIST
4745
}
4846

4947
__all__ = ['OPTAttention', 'OPTModel', 'OPTDecoder', 'OPTForCausalLM']

tests/ut/models/opt/test_modeling_opt.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def test_inference_no_head(self):
8282
Test inference
8383
"""
8484
model = OPTModel.from_pretrained(
85-
"facebook/opt-350m", from_pt=True, return_dict=True
85+
"opt-350m", from_pt=False, return_dict=True
8686
)
8787
input_ids = Tensor(
8888
[[0, 31414, 232, 328, 740, 1140, 12695, 69, 46078, 1588, 2]],
@@ -116,21 +116,21 @@ def setUp(self):
116116
Set up.
117117
"""
118118
super().setUp()
119-
self.path_model = "facebook/opt-350m"
119+
self.path_model = "opt-350m"
120120

121121
@pytest.mark.download
122122
def test_load_model(self):
123123
r"""
124124
Test load model
125125
"""
126-
_ = OPTForCausalLM.from_pretrained(self.path_model, from_pt=True)
126+
_ = OPTForCausalLM.from_pretrained(self.path_model, from_pt=False)
127127

128128
@pytest.mark.download
129129
def test_logits(self):
130130
r"""
131131
Test logits
132132
"""
133-
model = OPTForCausalLM.from_pretrained(self.path_model, from_pt=True)
133+
model = OPTForCausalLM.from_pretrained(self.path_model, from_pt=False)
134134
model = model.set_train(False)
135135
tokenizer = OPTTokenizer.from_pretrained(self.path_model)
136136

@@ -221,7 +221,7 @@ def test_generation_pre_attn_layer_norm(self):
221221
r"""
222222
Test Generation
223223
"""
224-
model_id = "facebook/opt-350m"
224+
model_id = "opt-350m"
225225

226226
EXPECTED_OUTPUTS = [
227227
"Today is a beautiful day and I want to",
@@ -251,7 +251,7 @@ def test_batch_generation(self):
251251
r"""
252252
Test batch generation
253253
"""
254-
model_id = "facebook/opt-350m"
254+
model_id = "opt-350m"
255255

256256
tokenizer = OPTTokenizer.from_pretrained(model_id)
257257
model = OPTForCausalLM.from_pretrained(model_id)
@@ -301,7 +301,7 @@ def test_generation_post_attn_layer_norm(self):
301301
r"""
302302
Test generation
303303
"""
304-
model_id = "facebook/opt-350m"
304+
model_id = "opt-350m"
305305

306306
EXPECTED_OUTPUTS = [
307307
"Today is a beautiful day and I want to",

0 commit comments

Comments
 (0)