Skip to content

Conversation

@ypwhs
Copy link
Contributor

@ypwhs ypwhs commented Mar 24, 2023

tokenizer.eos_token_id outputs 20002, but the eos_token_id defined in the config.json of ChatGLM-6B is 150005, so it needs to be changed to 150005.

image

{
  "_name_or_path": "THUDM/chatglm-6b",
  "architectures": [
    "ChatGLMModel"
  ],
  "auto_map": {
    "AutoConfig": "configuration_chatglm.ChatGLMConfig",
    "AutoModel": "modeling_chatglm.ChatGLMForConditionalGeneration",
    "AutoModelForSeq2SeqLM": "modeling_chatglm.ChatGLMForConditionalGeneration"
  },
  "bos_token_id": 150004,
  "eos_token_id": 150005,
  "hidden_size": 4096,
  "inner_hidden_size": 16384,
  "layernorm_epsilon": 1e-05,
  "max_sequence_length": 2048,
  "model_type": "chatglm",
  "num_attention_heads": 32,
  "num_layers": 28,
  "position_encoding_2d": true,
  "torch_dtype": "float16",
  "transformers_version": "4.23.1",
  "use_cache": true,
  "vocab_size": 150528
}

@mymusise
Copy link
Owner

Thanks for this PR!

It looks like a bug in ChatGLM Tokenizer config, this may be the reason for not stopping when generating sentences.
#55 #60

But I'd instead read eos_token_id from the config file than a magic number

config = AutoConfig.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto')
config.eos_token_id

@ypwhs
Copy link
Contributor Author

ypwhs commented Mar 24, 2023

Thanks for this PR!

It looks like a bug in ChatGLM Tokenizer config, this may be the reason for not stopping when generating sentences. #55 #60

But I'd instead read eos_token_id from the config file than a magic number

config = AutoConfig.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto')
config.eos_token_id

Your solution is better.

@ypwhs ypwhs closed this Mar 24, 2023
@ypwhs ypwhs mentioned this pull request Mar 24, 2023
@dumpmemory
Copy link

Screen Shot 2023-03-24 at 6 40 22 PM
It should be 150005. please check stream_chat function

@ypwhs ypwhs deleted the patch-1 branch March 27, 2023 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants