Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support telechat2 #35415

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/source/en/_toctree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@
title: T5v1.1
- local: model_doc/tapex
title: TAPEX
- local: model_doc/telechat2
title: TeleChat2
- local: model_doc/transfo-xl
title: Transformer XL
- local: model_doc/ul2
Expand Down
38 changes: 38 additions & 0 deletions docs/source/en/model_doc/telechat2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!--Copyright 2024 The HuggingFace Team. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.

⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->

# TeleChat2

## Overview

The TeleChat2 model was proposed in [<INSERT PAPER NAME HERE>](<INSERT PAPER LINK HERE>) by <INSERT AUTHORS HERE>.
<INSERT SHORT SUMMARY HERE>

The abstract from the paper is the following:

*<INSERT PAPER ABSTRACT HERE>*

Tips:

<INSERT TIPS ABOUT MODEL HERE>

This model was contributed by [INSERT YOUR HF USERNAME HERE](https://huggingface.co/<INSERT YOUR HF USERNAME HERE>).
The original code can be found [here](<INSERT LINK TO GITHUB REPO HERE>).


## TeleChat2Config

[[autodoc]] TeleChat2Config
28 changes: 28 additions & 0 deletions src/transformers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@
"models.levit": ["LevitConfig"],
"models.lilt": ["LiltConfig"],
"models.llama": ["LlamaConfig"],
"models.telechat2": ["TeleChat2Config"],
"models.llava": [
"LlavaConfig",
"LlavaProcessor",
Expand Down Expand Up @@ -1032,6 +1033,7 @@
_import_structure["models.gpt_sw3"].append("GPTSw3Tokenizer")
_import_structure["models.layoutxlm"].append("LayoutXLMTokenizer")
_import_structure["models.llama"].append("LlamaTokenizer")
_import_structure["models.telechat2"].append("TeleChat2Tokenizer")
_import_structure["models.m2m_100"].append("M2M100Tokenizer")
_import_structure["models.marian"].append("MarianTokenizer")
_import_structure["models.mbart"].append("MBartTokenizer")
Expand Down Expand Up @@ -2643,6 +2645,16 @@
"LlamaPreTrainedModel",
]
)
_import_structure["models.telechat2"].extend(
[
"TeleChat2ForCausalLM",
"TeleChat2ForQuestionAnswering",
"TeleChat2ForSequenceClassification",
"TeleChat2ForTokenClassification",
"TeleChat2Model",
"TeleChat2PreTrainedModel",
]
)
_import_structure["models.llava"].extend(
[
"LlavaForConditionalGeneration",
Expand Down Expand Up @@ -4848,6 +4860,7 @@
)
_import_structure["models.gptj"].extend(["FlaxGPTJForCausalLM", "FlaxGPTJModel", "FlaxGPTJPreTrainedModel"])
_import_structure["models.llama"].extend(["FlaxLlamaForCausalLM", "FlaxLlamaModel", "FlaxLlamaPreTrainedModel"])
_import_structure["models.telechat2"].extend(["FlaxTeleChat2ForCausalLM", "FlaxTeleChat2Model", "FlaxTeleChat2PreTrainedModel"])
_import_structure["models.gemma"].extend(["FlaxGemmaForCausalLM", "FlaxGemmaModel", "FlaxGemmaPreTrainedModel"])
_import_structure["models.longt5"].extend(
[
Expand Down Expand Up @@ -5504,6 +5517,7 @@
from .models.levit import LevitConfig
from .models.lilt import LiltConfig
from .models.llama import LlamaConfig
from .models.telechat2 import TeleChat2Config
from .models.llava import (
LlavaConfig,
LlavaProcessor,
Expand Down Expand Up @@ -6051,6 +6065,7 @@
from .models.gpt_sw3 import GPTSw3Tokenizer
from .models.layoutxlm import LayoutXLMTokenizer
from .models.llama import LlamaTokenizer
from .models.telechat2 import TeleChat2Tokenizer
from .models.m2m_100 import M2M100Tokenizer
from .models.marian import MarianTokenizer
from .models.mbart import MBartTokenizer
Expand Down Expand Up @@ -7402,6 +7417,14 @@
LlamaModel,
LlamaPreTrainedModel,
)
from .models.telechat2 import (
TeleChat2ForCausalLM,
TeleChat2ForQuestionAnswering,
TeleChat2ForSequenceClassification,
TeleChat2ForTokenClassification,
TeleChat2Model,
TeleChat2PreTrainedModel,
)
from .models.llava import (
LlavaForConditionalGeneration,
LlavaPreTrainedModel,
Expand Down Expand Up @@ -9178,6 +9201,11 @@
FlaxLlamaModel,
FlaxLlamaPreTrainedModel,
)
from .models.telechat2 import (
FlaxTeleChat2ForCausalLM,
FlaxTeleChat2Model,
FlaxTeleChat2PreTrainedModel,
)
from .models.longt5 import (
FlaxLongT5ForConditionalGeneration,
FlaxLongT5Model,
Expand Down
1 change: 1 addition & 0 deletions src/transformers/convert_slow_tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ def converted(self) -> Tokenizer:
"SeamlessM4TTokenizer": SeamlessM4TConverter,
"SqueezeBertTokenizer": BertConverter,
"T5Tokenizer": T5Converter,
"TeleChat2Tokenizer": LlamaConverter,
"UdopTokenizer": UdopConverter,
"WhisperTokenizer": WhisperConverter,
"XLMRobertaTokenizer": XLMRobertaConverter,
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
levit,
lilt,
llama,
telechat2,
llava,
llava_next,
llava_next_video,
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/auto/configuration_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
("levit", "LevitConfig"),
("lilt", "LiltConfig"),
("llama", "LlamaConfig"),
("telechat2", "TeleChat2Config"),
("llava", "LlavaConfig"),
("llava_next", "LlavaNextConfig"),
("llava_next_video", "LlavaNextVideoConfig"),
Expand Down Expand Up @@ -473,6 +474,7 @@
("levit", "LeViT"),
("lilt", "LiLT"),
("llama", "LLaMA"),
("telechat2", "TeleChat2"),
("llama2", "Llama2"),
("llama3", "Llama3"),
("llava", "LLaVa"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/modeling_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@
("switch_transformers", "SwitchTransformersForConditionalGeneration"),
("t5", "T5ForConditionalGeneration"),
("tapas", "TapasForMaskedLM"),
("telechat2", "TeleChat2ForCausalLM"),
("transfo-xl", "TransfoXLLMHeadModel"),
("wav2vec2", "Wav2Vec2ForMaskedLM"),
("whisper", "WhisperForConditionalGeneration"),
Expand Down
1 change: 1 addition & 0 deletions src/transformers/models/auto/tokenization_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@
"LlamaTokenizerFast" if is_tokenizers_available() else None,
),
),
("telechat2", ("LlamaTokenizer", "LlamaTokenizerFast" if is_tokenizers_available() else None)),
("llava", ("LlamaTokenizer", "LlamaTokenizerFast" if is_tokenizers_available() else None)),
("llava_next", ("LlamaTokenizer", "LlamaTokenizerFast" if is_tokenizers_available() else None)),
("llava_next_video", ("LlamaTokenizer", "LlamaTokenizerFast" if is_tokenizers_available() else None)),
Expand Down
59 changes: 59 additions & 0 deletions src/transformers/models/telechat2/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Copyright 2024 EleutherAI and The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from typing import TYPE_CHECKING

from ...utils import (
OptionalDependencyNotAvailable,
_LazyModule,
is_torch_available,
)


_import_structure = {
"configuration_telechat2": ["TeleChat2Config"],
}

try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
_import_structure["modeling_telechat2"] = [
"TeleChat2PreTrainedModel",
"TeleChat2Model",
"TeleChat2ForCausalLM",
]


if TYPE_CHECKING:
from .configuration_telechat2 import TeleChat2Config

try:
if not is_torch_available():
raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
pass
else:
from .modeling_qwen2 import (
TeleChat2PreTrainedModel,
TeleChat2Model,
TeleChat2ForCausalLM,
)


else:
import sys

sys.modules[__name__] = _LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)
Loading