Unverified Commit 4cfb118f authored by lvhan028's avatar lvhan028 Committed by GitHub
Browse files

add puyu model for internal use (#105)

* add puyu model for internal use

* get/set session

* update

* add docstring
parent 4b3458f7
...@@ -96,6 +96,35 @@ class Llama: ...@@ -96,6 +96,35 @@ class Llama:
return None return None
@MODELS.register_module(name='puyu')
class Puyu:
"""Chat template of puyu model.This is only for internal usage in Shanghai
AI Laboratory."""
def __init__(self):
self.system = """meta instruction
You are an AI assistant whose name is InternLM (书生·浦语).
- 书生·浦语 is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.
- 书生·浦语 can understand and communicate fluently in the language chosen by the user such as English and 中文.
conversation""" # noqa: E501
self.user = '<|Human|>'
self.eoh = 'െ'
self.assistant = '<|Assistant|>'
def get_prompt(self, prompt, sequence_start=True):
if sequence_start:
return f'<bos>{self.system}\n' \
f'{self.user}:{prompt}{self.eoh}\n' \
f'{self.assistant}:'
else:
return f'\n{self.user}:{prompt}{self.eoh}\n{self.assistant}:'
@property
def stop_words(self):
"""Return the stop-words' token ids."""
return [45623]
def main(model_name: str = 'test'): def main(model_name: str = 'test'):
assert model_name in MODELS.module_dict.keys(), \ assert model_name in MODELS.module_dict.keys(), \
f"'{model_name}' is not supported. " \ f"'{model_name}' is not supported. " \
......
...@@ -263,6 +263,16 @@ class Chatbot: ...@@ -263,6 +263,16 @@ class Chatbot:
"""reset session.""" """reset session."""
self._session = None self._session = None
@property
def session(self):
"""get session."""
return self._session
@session.setter
def session(self, value):
"""set session."""
self._session = value
def _get_bos(self): def _get_bos(self):
"""return bos token id.""" """return bos token id."""
token_ids, _ = self.preprocess('<BOS>') token_ids, _ = self.preprocess('<BOS>')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment