Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ src/transformers/models/t5gemma/configuration_*.py linguist-generated=true
src/transformers/models/t5gemma/modeling_*.py linguist-generated=true
src/transformers/models/t5gemma2/configuration_*.py linguist-generated=true
src/transformers/models/t5gemma2/modeling_*.py linguist-generated=true
src/transformers/models/telechat/configuration_*.py linguist-generated=true
src/transformers/models/telechat/modeling_*.py linguist-generated=true
src/transformers/models/timesfm/modeling_*.py linguist-generated=true
src/transformers/models/timesfm2_5/configuration_*.py linguist-generated=true
src/transformers/models/timesfm2_5/modeling_*.py linguist-generated=true
Expand Down
8 changes: 8 additions & 0 deletions docs/source/en/_toctree.yml
Comment thread
hmellor marked this conversation as resolved.
Resolved
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,10 @@
title: HYV4
- local: model_doc/ibert
title: I-BERT
- local: model_doc/internlm3
title: InternLM3
- local: model_doc/iquestcoder
title: IQuestCoder
- local: model_doc/jais2
title: Jais2
- local: model_doc/jamba
Expand Down Expand Up @@ -955,6 +959,10 @@
title: T5Gemma2
- local: model_doc/t5v1.1
title: T5v1.1
- local: model_doc/telechat
title: TeleChat
- local: model_doc/telechat3
title: TeleChat3
- local: model_doc/ul2
title: UL2
- local: model_doc/ultrabert
Expand Down
47 changes: 47 additions & 0 deletions docs/source/en/model_doc/internlm3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<!--Copyright 2026 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 contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was contributed to Hugging Face Transformers on 2026-11-10.*
<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>
</div>

# InternLM3

[InternLM3](https://huggingface.co/internlm/internlm3-8b-instruct) is an 8B instruction-tuned language model developed by [Shanghai AI Laboratory](https://huggingface.co/internlm). Its architecture is the same as [Llama](./llama). Its config names the biases of the query, key and value projections `qkv_bias` and those of the attention output projection and MLP layers `bias`; [`InternLM3Config`] loads them as `attention_bias` and `mlp_bias`, and requires them to be equal, as they are in the released checkpoints.

The auto classes load it with the Llama implementation ([`LlamaModel`], [`LlamaForCausalLM`], [`LlamaForSequenceClassification`], [`LlamaForQuestionAnswering`] and [`LlamaForTokenClassification`]), so only [`InternLM3Config`] is specific to InternLM3.

The example below demonstrates how to generate text with the [`AutoModelForCausalLM`] class.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("internlm/internlm3-8b-instruct")
model = AutoModelForCausalLM.from_pretrained("internlm/internlm3-8b-instruct", device_map="auto")

messages = [{"role": "user", "content": "Explain the Pythagorean theorem in one sentence."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
output = model.generate(**inputs.to(model.device), max_new_tokens=64)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1] :], skip_special_tokens=True))
```

## InternLM3Config

[[autodoc]] InternLM3Config
51 changes: 51 additions & 0 deletions docs/source/en/model_doc/iquestcoder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<!--Copyright 2026 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 contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was contributed to Hugging Face Transformers on 2026-11-10.*
<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>
</div>

# IQuestCoder

[IQuest-Coder-V1](https://huggingface.co/IQuestLab/IQuest-Coder-V1-40B-Instruct) is a family of code language models developed by [IQuest Lab](https://huggingface.co/IQuestLab), available in 7B, 14B and 40B sizes with base, instruct and thinking variants. Its architecture is the same as [Llama](./llama).

The looped `IQuest-Coder-V1-*-Loop-*` checkpoints use a different architecture and aren't supported by this model.
Comment thread
hmellor marked this conversation as resolved.
Resolved

The tokenizer is built from the checkpoints' SentencePiece model. Many of its pieces share the same score, and SentencePiece breaks those ties by position, which the `tokenizers` library can't reproduce, so a small fraction of texts tokenize differently from the original remote code.
Comment thread
hmellor marked this conversation as resolved.
Resolved

The auto classes load it with the Llama implementation ([`LlamaModel`], [`LlamaForCausalLM`], [`LlamaForSequenceClassification`], [`LlamaForQuestionAnswering`] and [`LlamaForTokenClassification`]), so only [`IQuestCoderConfig`] is specific to IQuestCoder.

The example below demonstrates how to generate text with the [`AutoModelForCausalLM`] class.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("IQuestLab/IQuest-Coder-V1-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("IQuestLab/IQuest-Coder-V1-7B-Instruct", device_map="auto")

messages = [{"role": "user", "content": "Write a Python function that checks whether a number is prime."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
output = model.generate(**inputs.to(model.device), max_new_tokens=128)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1] :], skip_special_tokens=True))
```

## IQuestCoderConfig

[[autodoc]] IQuestCoderConfig
64 changes: 64 additions & 0 deletions docs/source/en/model_doc/telechat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--Copyright 2026 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 contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was contributed to Hugging Face Transformers on 2026-11-10.*
<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>
</div>

# TeleChat

[TeleChat](https://huggingface.co/Tele-AI) is a family of language models developed by [China Telecom Artificial Intelligence Technology](https://huggingface.co/Tele-AI), covering TeleChat (1B to 12B), TeleChat2 (3B to 115B) and TeleChat2.5 (35B and 115B). TeleChat3 is a separate model, see [TeleChat3](./telechat3).

Its architecture is the same as [Llama](./llama), except that:

- only the attention output projection and the down projection of the MLP have biases;
- once the sequence grows beyond `training_seqlen`, RoPE is rescaled with a stepwise NTK scaling of its base and the cos/sin are scaled by `0.1 * ln(seq_len / training_seqlen) + 1`.

The original checkpoints use different parameter names and fuse the key and value projections per head (`[k_0, v_0, k_1, v_1, ...]`). They are converted when the model is loaded, and `save_pretrained` writes the original layout back.
Comment thread
hmellor marked this conversation as resolved.
Resolved

TeleChat-52B uses a different architecture and isn't supported by this model.

The example below demonstrates how to generate text with the [`AutoModelForCausalLM`] class.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("Tele-AI/TeleChat2-3B")
model = AutoModelForCausalLM.from_pretrained("Tele-AI/TeleChat2-3B", device_map="auto")

messages = [{"role": "user", "content": "Explain the Pythagorean theorem in one sentence."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
output = model.generate(**inputs.to(model.device), max_new_tokens=64)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1] :], skip_special_tokens=True))
```

## TeleChatConfig

[[autodoc]] TeleChatConfig

## TeleChatModel

[[autodoc]] TeleChatModel
- forward

## TeleChatForCausalLM

[[autodoc]] TeleChatForCausalLM
- forward
49 changes: 49 additions & 0 deletions docs/source/en/model_doc/telechat3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<!--Copyright 2026 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 contains specific syntax for our doc-builder (similar to MDX) that may not be
rendered properly in your Markdown viewer.

-->
*This model was contributed to Hugging Face Transformers on 2026-11-10.*
<div style="float: right;">
<div class="flex flex-wrap space-x-1">
<img alt="FlashAttention" src="https://img.shields.io/badge/%E2%9A%A1%EF%B8%8E%20FlashAttention-eae0c8?style=flat">
<img alt="SDPA" src="https://img.shields.io/badge/SDPA-DE3412?style=flat&logo=pytorch&logoColor=white">
</div>
</div>

# TeleChat3

[TeleChat3](https://huggingface.co/Tele-AI/TeleChat3-36B-Thinking) is a family of 36B reasoning language models developed by [China Telecom Artificial Intelligence Technology](https://huggingface.co/Tele-AI), including the general-purpose TeleChat3-36B-Thinking and the code-focused TeleChat3-Coder-36B-Thinking. Its architecture is the same as [Llama](./llama).

The original checkpoints use a custom `"telechat3-yarn"` RoPE type, which is YaRN with 0.07 instead of 0.1 as the coefficient of its default attention factor. [`TeleChat3Config`] converts it to `"yarn"` with an explicit `attention_factor` when the config is loaded.

The auto classes load it with the Llama implementation ([`LlamaModel`], [`LlamaForCausalLM`], [`LlamaForSequenceClassification`], [`LlamaForQuestionAnswering`] and [`LlamaForTokenClassification`]), so only [`TeleChat3Config`] is specific to TeleChat3.

The example below demonstrates how to generate text with the [`AutoModelForCausalLM`] class.

```python
from transformers import AutoModelForCausalLM, AutoTokenizer


tokenizer = AutoTokenizer.from_pretrained("Tele-AI/TeleChat3-36B-Thinking")
model = AutoModelForCausalLM.from_pretrained("Tele-AI/TeleChat3-36B-Thinking", device_map="auto")

messages = [{"role": "user", "content": "Explain the Pythagorean theorem in one sentence."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt", return_dict=True)
output = model.generate(**inputs.to(model.device), max_new_tokens=256)
print(tokenizer.decode(output[0][inputs["input_ids"].shape[1] :], skip_special_tokens=True))
```

## TeleChat3Config

[[autodoc]] TeleChat3Config
16 changes: 16 additions & 0 deletions src/transformers/conversion_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,22 @@ def _build_checkpoint_conversion_mapping():
target_patterns="LayerNorm.bias",
),
],
"telechat": [
# Targets are escaped and guarded so that, reversed for saving, they only match whole names. `(?<![^.])` matches
# at the start of a key or after a dot, so these also apply to base-model-only checkpoints (Tele-AI/telechat-7B)
WeightRenaming(r"^transformer\.", r"model\."),
WeightRenaming(r"(?<![^.])h\.", r"(?<![^.])layers\."),
WeightRenaming(r"(?<![^.])word_embeddings\.", r"(?<![^.])embed_tokens\."),
WeightRenaming(r"(?<![^.])ln_f\.", r"(?<![^.])norm\."),
WeightRenaming(r"self_attention\.query\.", r"self_attn\.q_proj\."),
# Keys and values are fused per head, i.e. `[k_0, v_0, k_1, v_1, ...]`
WeightConverter(
"self_attention.key_value.weight",
["self_attn.k_proj.weight", "self_attn.v_proj.weight"],
operations=[Interleave(dim=0, block_size_attribute="head_dim"), Chunk(dim=0)],
),
WeightRenaming(r"self_attention\.dense\.", r"self_attn\.o_proj\."),
],
"sapiens2": [
WeightRenaming(r"^cls_token", r"embeddings.cls_token"),
WeightRenaming(r"^storage_tokens", r"embeddings.register_tokens"),
Expand Down
20 changes: 15 additions & 5 deletions src/transformers/core_model_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,30 +226,40 @@ def reverse_op(self) -> ConversionOps:


class Interleave(ConversionOps):
"""Deinterleaves a tensor along `dim` by splitting in two and transposing. Reshapes param back to its original size."""
"""Deinterleaves a tensor along `dim` by splitting in two and transposing. Reshapes param back to its original size.

def __init__(self, dim: int = 0, inverse: bool = False):
By default the two halves alternate element by element. With `block_size_attribute`, a config field, they alternate
in blocks of that size instead, e.g. `[k_0, v_0, k_1, v_1, ...]` for keys and values fused per head of `head_dim`.
Comment thread
hmellor marked this conversation as resolved.
Resolved
"""

def __init__(self, dim: int = 0, inverse: bool = False, block_size_attribute: str | None = None):
self.dim = dim
self.inverse = inverse
self.block_size_attribute = block_size_attribute

def convert(self, input_dict, source_patterns, target_patterns, **kwargs):
tensor = next(iter(input_dict.values()))
tensor = tensor[0] if isinstance(tensor, list) else tensor

block_size = 1
if self.block_size_attribute is not None:
block_size = getattr(kwargs["config"].get_text_config(), self.block_size_attribute)

# Split into two in given dim and transpose to interleave along it
shape = list(tensor.shape)
num_blocks = shape[self.dim] // (2 * block_size)
if self.inverse:
shape[self.dim : self.dim + 1] = [2, shape[self.dim] // 2]
shape[self.dim : self.dim + 1] = [2, num_blocks, block_size]
else:
shape[self.dim : self.dim + 1] = [shape[self.dim] // 2, 2]
shape[self.dim : self.dim + 1] = [num_blocks, 2, block_size]

tensor = tensor.reshape(shape).transpose(self.dim, self.dim + 1).reshape(tensor.shape).contiguous()
return {target_patterns[0]: tensor}

@property
def reverse_op(self) -> ConversionOps:
# can use the same dim and it will inverse it back
return Interleave(self.dim, inverse=not self.inverse)
return Interleave(self.dim, inverse=not self.inverse, block_size_attribute=self.block_size_attribute)


class MergeModulelist(ConversionOps):
Expand Down
4 changes: 4 additions & 0 deletions src/transformers/models/__init__.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/transformers/models/auto/auto_mappings.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading