Skip to content

Commit 01a007a

Browse files
authored
Add TinyLlama (#2889)
1 parent 722ab02 commit 01a007a

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

docs/model_support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- [project-baize/baize-v2-7b](https://huggingface.co/project-baize/baize-v2-7b)
4848
- [Qwen/Qwen-7B-Chat](https://huggingface.co/Qwen/Qwen-7B-Chat)
4949
- [rishiraj/CatPPT](https://huggingface.co/rishiraj/CatPPT)
50+
- [TinyLlama/TinyLlama-1.1B-Chat-v1.0](https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0)
5051
- [Salesforce/codet5p-6b](https://huggingface.co/Salesforce/codet5p-6b)
5152
- [StabilityAI/stablelm-tuned-alpha-7b](https://huggingface.co/stabilityai/stablelm-tuned-alpha-7b)
5253
- [THUDM/chatglm-6b](https://huggingface.co/THUDM/chatglm-6b)

fastchat/conversation.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,20 @@ def get_conv_template(name: str) -> Conversation:
13531353
)
13541354
)
13551355

1356+
# TinyLlama template
1357+
# reference: https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0
1358+
register_conv_template(
1359+
Conversation(
1360+
name="TinyLlama",
1361+
system_template="<|system|>\n{system_message}",
1362+
roles=("<|user|>", "<|assistant|>"),
1363+
sep_style=SeparatorStyle.CHATML,
1364+
sep="</s>",
1365+
stop_token_ids=[2],
1366+
stop_str="</s>",
1367+
)
1368+
)
1369+
13561370
# Orca-2 template
13571371
# reference: https://huggingface.co/microsoft/Orca-2-7b
13581372
register_conv_template(

fastchat/model/model_adapter.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1948,6 +1948,16 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
19481948
return get_conv_template("catppt")
19491949

19501950

1951+
class TinyLlamaAdapter(BaseModelAdapter):
1952+
"""The model adapter for TinyLlama (e.g. TinyLlama/TinyLlama-1.1B-Chat-v1.0)"""
1953+
1954+
def match(self, model_path: str):
1955+
return "TinyLlama" in model_path.lower()
1956+
1957+
def get_default_conv_template(self, model_path: str) -> Conversation:
1958+
return get_conv_template("TinyLlama")
1959+
1960+
19511961
class XwinLMAdapter(BaseModelAdapter):
19521962
"""The model adapter for Xwin-LM V0.1 and V0.2 series of models(e.g., Xwin-LM/Xwin-LM-70B-V0.1)"""
19531963

@@ -2139,6 +2149,7 @@ def get_default_conv_template(self, model_path: str) -> Conversation:
21392149
register_model_adapter(Llama2ChangAdapter)
21402150
register_model_adapter(ZephyrAdapter)
21412151
register_model_adapter(CatPPTAdapter)
2152+
register_model_adapter(TinyLlamaAdapter)
21422153
register_model_adapter(XwinLMAdapter)
21432154
register_model_adapter(LemurAdapter)
21442155
register_model_adapter(PygmalionAdapter)

fastchat/model/model_registry.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ def get_model_info(name: str) -> ModelInfo:
175175
"a chatbot fine-tuned from a SLERP merged model by Rishiraj Acharya",
176176
)
177177

178+
register_model_info(
179+
["TinyLlama"],
180+
"TinyLlama",
181+
"https://huggingface.co/TinyLlama/TinyLlama-1.1B-Chat-v1.0",
182+
"The TinyLlama project is an open endeavor to pretrain a 1.1B Llama model on 3 trillion tokens.",
183+
)
184+
178185
register_model_info(
179186
["qwen-14b-chat"],
180187
"Qwen",

0 commit comments

Comments
 (0)