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

Add code sample docstrings and checkpoint reference for GLM models #34360

Merged
merged 3 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
9 changes: 9 additions & 0 deletions src/transformers/models/glm/modeling_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
)
from ...modeling_utils import PreTrainedModel
from ...utils import (
add_code_sample_docstrings,
add_start_docstrings,
add_start_docstrings_to_model_forward,
is_flash_attn_2_available,
Expand All @@ -54,6 +55,9 @@
from ...modeling_flash_attention_utils import _flash_attention_forward


_CHECKPOINT_FOR_DOC = "THUDM/glm-4-9b-chat"
h3110Fr13nd marked this conversation as resolved.
Show resolved Hide resolved


class GlmRMSNorm(nn.Module):
def __init__(self, hidden_size, eps=1e-6):
"""
Expand Down Expand Up @@ -1222,6 +1226,11 @@ def set_input_embeddings(self, value):
self.model.embed_tokens = value

@add_start_docstrings_to_model_forward(GLM_INPUTS_DOCSTRING)
@add_code_sample_docstrings(
checkpoint=_CHECKPOINT_FOR_DOC,
output_type=TokenClassifierOutput,
config_class=_CONFIG_FOR_DOC,
)
def forward(
self,
input_ids: Optional[torch.LongTensor] = None,
Expand Down
2 changes: 2 additions & 0 deletions src/transformers/models/glm/modular_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
from .configuration_glm import GlmConfig


_CHECKPOINT_FOR_DOC = "THUDM/glm-4-9b-chat"

logger = logging.get_logger(__name__)


Expand Down
Loading