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

torch engine support chatglm3 #1159

Merged
merged 3 commits into from
Feb 23, 2024
Merged

Conversation

grimoire
Copy link
Collaborator

ChatGLM3 shares most codes with ChatGLM2.

RMSNorm has been replaced with our triton kernel.

Fix batched inference.

Caution

I am not able to add model template in lmdeploy/model.py since the tokenizer can not encode special token to the special ids.

   def encode(self, s: str, bos: bool = False, eos: bool = False) -> List[int]:
       assert type(s) is str
       t = self.sp_model.encode(s)
       if bos:
           t = [self.bos_id] + t
       if eos:
           t = t + [self.eos_id]
       return t
   def decode(self, t: List[int]) -> str:
       text, buffer = "", []
       for token in t:
           if token in self.index_special_tokens:

               if buffer:
                   text += self.sp_model.decode(buffer)
                   buffer = []
               text += self.index_special_tokens[token]
           else:
               buffer.append(token)
       if buffer:
           text += self.sp_model.decode(buffer)
       return text

@lvhan028
Copy link
Collaborator

May remove the chat template in model.py if it doesn't work

Copy link
Collaborator

@lvhan028 lvhan028 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lvhan028
Copy link
Collaborator

The chat template of chatGLM models is still an issue. @AllentDan may follow it up.

@lvhan028 lvhan028 added enhancement New feature or request and removed improvement labels Feb 23, 2024
@AllentDan
Copy link
Collaborator

The chat template of chatGLM models is still an issue. @AllentDan may follow it up.

Encoding may not be the hardest part. It also influences incremental decoding.

@lvhan028 lvhan028 merged commit 65d94f6 into InternLM:main Feb 23, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants