Edit model card

ZhiLu是一个基于中文Alpaca2-13B进行二次训练的金融大模型,我们使用大量中英文语料进行增量预训练,同时使用高质量指令数据进行对齐。

模型训练的目标是在保持通用能力的前提下,显著提升金融领域的能力。具体细节参考:ZhiLu-github仓库

ZhiLu-LoRA-13B-Instruct

本仓库提供ZhiLu的LoRA模块,提供给已有Alpaca-2-13B模型的用户。

用户在使用前,可使用peft库进行加载,或与Alpaca-2-13B进行合并得到完整模型,合并代码及具体细节参考:ZhiLu-github仓库

数据质量

我们收集了各类数据,包括上市公司公告、财经新闻、上市公司年度报告、新闻、金融资讯、社区问答、维基百科等高质量数据。

模型训练的总token数为14.69B,通用语料与金融预料比例约为2:1,中英配比约为2:1。

模型训练

ZhiLu使用LoRA进行高效训练(含emb/lm-head),使用FlashAttention-2技术进行加速训练,公布了LoRA模块(本仓库)和Full Model

快速使用

import torch
from transformers import LlamaForCausalLM, LlamaTokenizer
from peft import PeftModel
model_name_or_path = ""
peft_model_path = ""
tokenizer = LlamaTokenizer.from_pretrained(model_name_or_path, use_fast=False, legacy=True)
model = LlamaForCausalLM.from_pretrained(model_name_or_path, torch_dtype=torch.bfloat16,device_map="auto")
if peft_model_path is not None:
    model = PeftModel.from_pretrained(
            model,
            peft_model_path,
            torch_dtype=(
            torch.bfloat16
            if torch.cuda.is_bf16_supported()
            else torch.float32
        ),
    )
inputs = tokenizer("什么是A股?", return_tensors="pt").to("cuda")
outputs = model.generate(**inputs, max_new_tokens=64, repetition_penalty=1.1)
outputs = tokenizer.decode(outputs.cpu()[0][len(inputs.input_ids[0]):], skip_special_tokens=True)
print(outputs)
Downloads last month
0
Unable to determine this model's library. Check the docs .