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

changed aquila prediction #544

Merged
merged 2 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions flagai/model/aquila2/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def get_conversation_template(model_path: str) -> Conversation:
return get_conv_template("aquila-v1")
elif "aquila-chat" in model_path:
return get_conv_template("aquila-chat")
elif "aquila-legacy" in model_path:
return get_conv_template("aquila-legacy")
else:
return get_conv_template("aquila")

Expand All @@ -182,6 +184,21 @@ def get_conversation_template(model_path: str) -> Conversation:
)
)

register_conv_template(
Conversation(
name="aquila-legacy",
system_message="A chat between a curious human and an artificial intelligence assistant. "
"The assistant gives helpful, detailed, and polite answers to the human's questions.\n\n",
roles=("### Human: ", "### Assistant: ", "System"),
messages=(),
offset=0,
sep_style=SeparatorStyle.NO_COLON_TWO,
sep="\n",
sep2="</s>",
stop_str=["</s>", "[UNK]"],
)
)

register_conv_template(
Conversation(
name="aquila",
Expand Down
16 changes: 13 additions & 3 deletions flagai/model/aquila2/modeling_aquila.py
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,23 @@ def predict(self, text, tokenizer=None,
max_gen_len=200, top_p=0.95,
seed=1234, topk=100,
temperature=0.9,
sft=True, convo_template = "aquila-chat",
device = "cuda"):
sft=True, convo_template = "",
device = "cuda",
model_name="AquilaChat2-7B",
**kwargs):

vocab = tokenizer.get_vocab()
#device = device

id2word = {v:k for k, v in vocab.items()}



template_map = {"AquilaChat2-7B": "aquila-v1",
"AquilaChat2-34B": "aquila-legacy",
"AquilaChat2-7B-16K": "aquila",
"AquilaChat2-34B-16K": "aquila-v1"}
if not convo_template:
convo_template=template_map.get(model_name, "aquila-chat")

set_random_seed(seed)
if temperature == 0:
Expand Down
Loading