HuggingFace镜像/solar-sft-qlora-openmind
模型介绍文件和版本分析
下载使用量0

solar-sft-qlor

在 Openmind 中的使用

import torch
from openmind import AutoTokenizer, AutoModelForCausalLM, is_torch_npu_available
from openmind_hub import snapshot_download
import argparse
import time

def parse_args():
    parser = argparse.ArgumentParser()
    parser.add_argument(
        "--model_name_or_path",
        type=str,
        help="Path to model",
        default="jeffding/solar-sft-qlora-openmind",
    )
    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"
        
    tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
    # Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and might cause OOM Error.
    model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, trust_remote_code=True).to(device)
    
    start_time = time.time()
    
    model = model.eval()
    inputs = tokenizer(["Give me a short introduction to large language model."], return_tensors="pt")
    for k,v in inputs.items():
        inputs[k] = v.to(device)
    gen_kwargs = {"max_length": 1000, "top_p": 0.8, "temperature": 0.8, "do_sample": True, "repetition_penalty": 1.0}
    output = model.generate(**inputs, **gen_kwargs)
    output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
    print(output)
    
    end_time = time.time()
    print(f"硬件环境:{device},推理执行时间:{end_time - start_time}秒")

if __name__ == "__main__":
    main()
  • 仅用于练习
  • 使用 transformers、peft、bitsandbytes 进行训练
  • 通过 https://github.com/davidkim205/kollm_evaluation 进行评估
任务版本号筛选条件零样本数指标数值标准误差
kobest_wic1无0准确率0.5056±0.0141
无0F1分数0.4170±不适用
kobest_sentineg1无0准确率0.8791±0.0164
无0F1分数0.8779±不适用
kobest_hellaswag1无0准确率0.4540±0.0223
无0F1分数0.4522±不适用
无0归一化准确率0.5600±0.0222
kobest_copa1无0准确率0.6540±0.0151
无0F1分数0.6535±不适用
kobest_boolq1无0准确率0.5135±0.0133
无0F1分数0.3592±不适用
ko_truthfulqa2无0准确率0.2938±0.0159
ko_hellaswag1无0准确率0.3816±0.0048
无0归一化准确率0.5171±0.0050
ko_common_gen1无0准确率0.8095±0.0100
无0归一化准确率0.8095±0.0100
ko_arc_easy1无0准确率0.3311±0.0138
无0归一化准确率0.4053±0.0143