Skip to content

Commit

Permalink
Add Lemur model (#2584)
Browse files Browse the repository at this point in the history
Co-authored-by: Roberto Ugolotti <Roberto.UGOLOTTI@ec.europa.eu>
  • Loading branch information
ugolotti and Roberto Ugolotti authored Oct 24, 2023
1 parent 582f48b commit 220257a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/model_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [HuggingFaceH4/starchat-beta](https://huggingface.co/HuggingFaceH4/starchat-beta)
- [HuggingFaceH4/zephyr-7b-alpha](https://huggingface.co/HuggingFaceH4/zephyr-7b-alpha)
- [Xwin-LM/Xwin-LM-7B-V0.1](https://huggingface.co/Xwin-LM/Xwin-LM-70B-V0.1)
- [OpenLemur/lemur-70b-chat-v1](https://huggingface.co/OpenLemur/lemur-70b-chat-v1)
- Any [EleutherAI](https://huggingface.co/EleutherAI) pythia model such as [pythia-6.9b](https://huggingface.co/EleutherAI/pythia-6.9b)
- Any [Peft](https://github.com/huggingface/peft) adapter trained on top of a
model above. To activate, must have `peft` in the model path. Note: If
Expand Down
15 changes: 15 additions & 0 deletions fastchat/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,21 @@ def get_conv_template(name: str) -> Conversation:
)
)

# Lemur-70b-chat default template
# reference: https://huggingface.co/OpenLemur/lemur-70b-chat-v1#generation
register_conv_template(
Conversation(
name="lemur-70b-chat",
system_template="""<|im_start|>system
{system_message}""",
system_message="""You are a helpful, respectful, and honest assistant.""",
roles=("<|im_start|>user", "<|im_start|>assistant"),
sep_style=SeparatorStyle.CHATML,
sep="<|im_end|>",
stop_token_ids=[32002, 0],
)
)

# MPT-30b-instruct default template
# reference: https://huggingface.co/mosaicml/mpt-30b-instruct#formatting
register_conv_template(
Expand Down
13 changes: 13 additions & 0 deletions fastchat/model/model_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1681,6 +1681,18 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("vicuna_v1.1")


class LemurAdapter(BaseModelAdapter):
"""The model adapter for OpenLemur/lemur-70b-chat-v1"""

use_fast_tokenizer = False

def match(self, model_path: str):
return "lemur-70b-chat" in model_path.lower()

def get_default_conv_template(self, model_path: str) -> Conversation:
return get_conv_template("lemur-70b-chat")


# Note: the registration order matters.
# The one registered earlier has a higher matching priority.
register_model_adapter(PeftModelAdapter)
Expand Down Expand Up @@ -1742,6 +1754,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
register_model_adapter(Llama2ChangAdapter)
register_model_adapter(ZephyrAdapter)
register_model_adapter(XwinLMAdapter)
register_model_adapter(LemurAdapter)

# After all adapters, try the default base adapter.
register_model_adapter(BaseModelAdapter)
7 changes: 7 additions & 0 deletions fastchat/model/model_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,13 @@ def get_model_info(name: str) -> ModelInfo:
"Chat models developed by Xwin-LM team",
)

register_model_info(
["lemur-70b-chat"],
"Lemur-Chat",
"https://huggingface.co/OpenLemur/lemur-70b-chat-v1",
"an openly accessible language model optimized for both natural language and coding capabilities ",
)

register_model_info(
["Mistral-7B-OpenOrca"],
"Open-Orca",
Expand Down

0 comments on commit 220257a

Please sign in to comment.