Add ChatGLM support (#1256)

---------

Co-authored-by: oobabooga <112222186+oobabooga@users.noreply.github.com>
This commit is contained in:
Forkoz 2023-04-16 22:15:03 +00:00 committed by GitHub
parent 6a03ad0824
commit c6fe1ced01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 10 deletions

View file

@ -49,7 +49,8 @@ def generate_chat_prompt(user_input, state, **kwargs):
string = shared.history['internal'][i][0]
if string not in ['', '<|BEGIN-VISIBLE-CHAT|>']:
rows.insert(1, f"{prefix1}{string.strip()}{state['end_of_turn']}\n")
this_prefix1 = prefix1.replace('<|round|>', f'{i}') # for ChatGLM
rows.insert(1, f"{this_prefix1}{string.strip()}{state['end_of_turn']}\n")
i -= 1
@ -60,7 +61,8 @@ def generate_chat_prompt(user_input, state, **kwargs):
# Adding the user message
if len(user_input) > 0:
rows.append(f"{prefix1}{user_input}{state['end_of_turn']}\n")
this_prefix1 = prefix1.replace('<|round|>', f'{len(shared.history["internal"])}') # for ChatGLM
rows.append(f"{this_prefix1}{user_input}{state['end_of_turn']}\n")
# Adding the Character prefix
rows.append(apply_extensions(f"{prefix2.strip() if not is_instruct else prefix2}", "bot_prefix"))