Skip to content

Commit

Permalink
Using aquila-v2 template.
Browse files Browse the repository at this point in the history
Signed-off-by: ldwang <[email protected]>
  • Loading branch information
ldwang committed Nov 28, 2023
1 parent 994ee63 commit 5f35072
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flagai/model/aquila2/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def get_conversation_template(model_path: str) -> Conversation:
sep_style=SeparatorStyle.NO_COLON_TWO,
sep="",
sep2="</s>",
stop_str=["</s>", "<|endoftext|>"],
stop_str=["</s>", "<|endoftext|>", "<|startofpiece|>", "<|endofpiece|>"],
)
)

Expand Down
1 change: 1 addition & 0 deletions flagai/model/aquila2/modeling_aquila.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ def predict(self, text, tokenizer=None,

template_map = {"AquilaChat2-7B": "aquila-v1",
"AquilaChat2-34B": "aquila-legacy",
"AquilaChat2-70B": "aquila-v2",
"AquilaChat2-7B-16K": "aquila",
"AquilaChat2-34B-16K": "aquila"}
if not convo_template:
Expand Down
12 changes: 12 additions & 0 deletions flagai/model/aquila2_hf/AquilaChat2-70B.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
model_info = "BAAI/AquilaChat2-70B"
tokenizer = AutoTokenizer.from_pretrained(model_info, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_info, trust_remote_code=True, torch_dtype=torch.bfloat16)
model.eval()
text = "请给出10个要到北京旅游的理由。"
from predict import predict
out = predict(model, text, tokenizer=tokenizer, max_gen_len=200, top_p=0.95,
seed=1234, topk=100, temperature=0.9, sft=True,
model_name="AquilaChat2-70B")
print(out)
3 changes: 2 additions & 1 deletion flagai/model/aquila2_hf/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def get_conversation_template(model_path: str) -> Conversation:
sep_style=SeparatorStyle.NO_COLON_TWO,
sep="",
sep2="</s>",
stop_str=["</s>", "<|endoftext|>"],
stop_str=["</s>", "<|endoftext|>", "<|startofpiece|>", "<|endofpiece|>"],
)
)

Expand Down Expand Up @@ -374,6 +374,7 @@ def predict(model, text, tokenizer=None,

template_map = {"AquilaChat2-7B": "aquila-v1",
"AquilaChat2-34B": "aquila-legacy",
"AquilaChat2-70B": "aquila-v2",
"AquilaChat2-7B-16K": "aquila",
"AquilaChat2-34B-16K": "aquila"}
if not convo_template:
Expand Down

0 comments on commit 5f35072

Please sign in to comment.