Skip to content

Commit 9a88568

Browse files
authored
Add opt model (#1069)
1 parent f95a148 commit 9a88568

File tree

8 files changed

+1774
-0
lines changed

8 files changed

+1774
-0
lines changed

mindone/transformers/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@
334334
MvpModel,
335335
MvpPreTrainedModel,
336336
)
337+
from .models.opt import (
338+
OPTForCausalLM,
339+
OPTForQuestionAnswering,
340+
OPTForSequenceClassification,
341+
OPTModel,
342+
OPTPreTrainedModel,
343+
)
337344
from .models.paligemma import PaliGemmaForConditionalGeneration, PaliGemmaPreTrainedModel
338345
from .models.persimmon import (
339346
PersimmonForCausalLM,

mindone/transformers/models/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
mobilebert,
5959
mpt,
6060
mvp,
61+
opt,
6162
paligemma,
6263
persimmon,
6364
phi,

mindone/transformers/models/auto/configuration_auto.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
("qwen2_audio", "Qwen2AudioConfig"),
9191
("qwen2_audio_encoder", "Qwen2AudioEncoderConfig"),
9292
("qwen2_vl", "Qwen2VLConfig"),
93+
("opt", "OPTConfig"),
9394
("roberta", "RobertaConfig"),
9495
("recurrent_gemma", "RecurrentGemmaConfig"),
9596
("rembert", "RemBertConfig"),
@@ -186,6 +187,7 @@
186187
("wav2vec2", "Wav2Vec2"),
187188
("whisper", "Whisper"),
188189
("convbert", "ConvBERT"),
190+
("opt", "OPT"),
189191
("xlm-roberta", "XLM-RoBERTa"),
190192
("xlm-roberta-xl", "XLM-RoBERTa-XL"),
191193
("cohere2", "Cohere2"),

mindone/transformers/models/auto/modeling_auto.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
("clip_text_model", "CLIPTextModel"),
5151
("clip_vision_model", "CLIPVisionModel"),
5252
("deberta", "DebertaModel"),
53+
("opt", "OPTModel"),
5354
("deberta-v2", "DebertaV2Model"),
5455
("dpt", "DPTModel"),
5556
("gemma", "GemmaModel"),
@@ -168,6 +169,7 @@
168169
("bart", "BartForCausalLM"),
169170
("camembert", "CamembertForCausalLM"),
170171
("mvp", "MvpForCausalLM"),
172+
("opt", "OPTForCausalLM"),
171173
("bert", "BertLMHeadModel"),
172174
("bert-generation", "BertGenerationDecoder"),
173175
("gemma", "GemmaForCausalLM"),
@@ -360,6 +362,7 @@
360362
("albert", "AlbertForSequenceClassification"),
361363
("bart", "BartForSequenceClassification"),
362364
("camembert", "CamembertForSequenceClassification"),
365+
("opt", "OPTForSequenceClassification"),
363366
("bert", "BertForSequenceClassification"),
364367
("mvp", "MvpForSequenceClassification"),
365368
("roberta", "RobertaForSequenceClassification"),
@@ -395,6 +398,7 @@
395398
# Model for Question Answering mapping
396399
("albert", "AlbertForQuestionAnswering"),
397400
("bart", "BartForQuestionAnswering"),
401+
("opt", "OPTForQuestionAnswering"),
398402
("bert", "BertForQuestionAnswering"),
399403
("camembert", "CamembertForQuestionAnswering"),
400404
("mvp", "MvpForQuestionAnswering"),
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Copyright 2024 The HuggingFace Team. All rights reserved.
2+
#
3+
# This code is adapted from https://github.com/huggingface/transformers
4+
# with modifications to run transformers on mindspore.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
from .modeling_opt import (
18+
OPTForCausalLM,
19+
OPTForQuestionAnswering,
20+
OPTForSequenceClassification,
21+
OPTModel,
22+
OPTPreTrainedModel,
23+
)

0 commit comments

Comments
 (0)