Skip to content

Commit

Permalink
Use system token to discriminate ChatGLM3 from ChatGLM2
Browse files Browse the repository at this point in the history
  • Loading branch information
li-plus committed Mar 13, 2024
1 parent e539592 commit 4040cb7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions chatglm_cpp/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,8 +487,9 @@ def convert(f: BinaryIO, model_name_or_path: str, lora_model_name_or_path: Optio

if model.config.model_type == "chatglm":
if hasattr(model.config, "multi_query_attention"):
# hack: ChatGLM3 shares the same architecture and model config with ChatGLM2, so I have to check transformers_version to discriminate one from the other
if model.config.transformers_version == "4.27.1" and model.config.seq_length <= 32768: # fix: Fixed a conversion error caused by a version recognition error
# ChatGLM3 shares the same architecture and model config with ChatGLM2, but its tokenizer further supports system prompts,
# so we can check system token to discriminate ChatGLM3 from ChatGLM2.
if "<|system|>" not in tokenizer.tokenizer.special_tokens:
ChatGLM2Converter.convert(f, model, tokenizer, ggml_type)
else:
ChatGLM3Converter.convert(f, model, tokenizer, ggml_type)
Expand Down

0 comments on commit 4040cb7

Please sign in to comment.