Skip to content

ChatGLMModel缺少set_input_embeddings接口,导致调用transformer.PreTrainedModel.resize_token_embeddings时候 raise NotImplementedError #340

Closed

Description

@5grs

System Info / 系統信息

def set_input_embeddings(self, value: nn.Module):
"""
Set model's input embeddings.

    Args:
        value (`nn.Module`): A module mapping vocabulary to hidden states.
    """

    base_model = getattr(self, self.base_model_prefix, self)
    if base_model is not self:
        base_model.set_input_embeddings(value)
    else:
        raise NotImplementedError

PreTrainedModel.set_input_embeddings内的问题,首次self: ChatGLMForConditionalGeneration,获取base_model: ChatGLMModel,因为ChatGLMModel内无set_input_embeddings导致再次跳入PreTrainedModel.set_input_embeddings,导致走到 raise NotImplementedError

Reproduction / 复现过程

model = AutoModel.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)

tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm3-6b", trust_remote_code=True)

model.resize_token_embeddings(len(tokenizer)) # 崩溃

Expected behavior / 期待表现

如果不准备提供 resize_token_embeddings 能力,建议给个提示。

Activity

  1. zRzRzRzRzRzRzR commented on Nov 17, 2023

    @zRzRzRzRzRzRzR
    Member

    收到,我们确认一下情况

  2. added
    enhancement
    on Nov 21, 2023
  3. locked and limited conversation to collaborators on Nov 24, 2023
  4. converted this issue into a discussion #434 on Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions