from openmind import AutoTokenizer, AutoModelForCausalLM, is_torch_npu_available
from openmind_hub import snapshot_download
import torch.nn.functional as F
from torch import Tensor
import openmind
import torch
import argparse
import sys
import time
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument(
"--model_name_or_path",
type=str,
help="Path to model",
default= "zhouhui/Mozaic-7B",
)
args = parser.parse_args()
return args
def main():
args = parse_args()
model_path = args.model_name_or_path
if is_torch_npu_available():
device = "npu:0"
else:
device = "cpu"
#device = "cpu"
start_time = time.time()
model = AutoModelForCausalLM.from_pretrained(model_path).to(device)
tokenizer = AutoTokenizer.from_pretrained(model_path)
model.eval()
prompt = "Hello, who are you?"
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
outputs = model.generate(input_ids=input_ids, max_length=100)
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(response)
end_time = time.time()
print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")
if __name__ == "__main__":
main()We were curious to see what happens if one uses:
The underlying model that I used was /Weyaxi/OpenHermes-2.5-neural-chat-v3-3-Slerp.
Dataset: /argilla/distilabel-intel-orca-dpo-pairs
The dataset was roughly ~3000 samples but they were high quality (according to the chosen_score).
The following filters were applied to the original dataset:
dataset = dataset.filter(
lambda r:
r["status"] != "tie" and
r["chosen_score"] >= 8 and
not r["in_gsm8k_train"]
)I decided to go with the ChatML which is used for OpenHermes2.5 By the way I integreated the chat template into the models tokenizer.
<|im_start|>system
{system}<|im_end|>
<|im_start|>user
{user}<|im_end|>
<|im_start|>assistant
{asistant}<|im_end|>Detailed results can be found here
| Metric | Value |
|---|---|
| Avg. | 71.71 |
| AI2 Reasoning Challenge (25-Shot) | 68.94 |
| HellaSwag (10-Shot) | 86.45 |
| MMLU (5-Shot) | 63.97 |
| TruthfulQA (0-shot) | 64.01 |
| Winogrande (5-shot) | 79.95 |
| GSM8k (5-shot) | 66.94 |