Downloads · 30 days
233
0% of all-time downloads
shibing624/chinese-alpaca-plus-13b-hf
chinese-alpaca-plus-13b-hf is a text generation model from shibing624. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as other.
Downloads · 30 days
233
0% of all-time downloads
All-time downloads
74.1K
Public
Repo size
52.8 GB
Likes
35
Public
Click a slice to open those files.
.bin26.4 GB · 100%
From the Hugging Face model README
发布中文LLaMA-Plus, Alpaca-Plus 13B版本模型
发布中文LLaMA-Plus, Alpaca-Plus 13B版本,改进点如下:
本模型是 decapoda-research/llama-13b-hf 底座模型 合并 ziqingyang/chinese-llama-plus-lora-13b 和 ziqingyang/chinese-alpaca-plus-lora-13b 两个LoRA权重, 并转化为HuggingFace版本权重(.bin文件),可以直接使用或者继续训练。
test case:
| input_text | predict |
|---|---|
| 为什么天空是蓝色的? | 天空是蓝色的是因为大气中的气体分子散射了太阳光中的短波长蓝光,使得我们看到的天空呈现出蓝色。 |
本项目开源在textgen项目:textgen,可支持llama模型,通过如下命令调用:
Install package:
pip install -U textgen
from textgen import GptModel
model = GptModel("llama", "shibing624/chinese-alpaca-plus-13b-hf")
r = model.predict(["用一句话描述地球为什么是独一无二的。"])
print(r) # ['地球是独一无二的,因为它拥有独特的大气层、水循环、生物多样性以及其他自然资源,这些都使它成为一个独特的生命支持系统。']
Without textgen, you can use the model like this:
First, you pass your input through the transformer model, then you get the generated sentence.
Install package:
pip install sentencepiece
pip install transformers>=4.28.0
import torch
import transformers
from transformers import LlamaTokenizer, LlamaForCausalLM
def generate_prompt(text):
return f"""Below is an instruction that describes a task. Write a response that appropriately completes the request.
### Instruction:
{text}
### Response:"""
tokenizer = LlamaTokenizer.from_pretrained('shibing624/chinese-alpaca-plus-13b-hf')
model = LlamaForCausalLM.from_pretrained('shibing624/chinese-alpaca-plus-13b-hf').half().cuda()
model.eval()
text = '为什么天空是蓝色的?'
prompt = generate_prompt(text)
input_ids = tokenizer.encode(prompt, return_tensors='pt').to('cuda')
with torch.no_grad():
output_ids = model.generate(
input_ids=input_ids,
max_new_tokens=128,
temperature=1,
top_k=40,
top_p=0.9,
repetition_penalty=1.15
).cuda()
output = tokenizer.decode(output_ids[0], skip_special_tokens=True)
print(output.replace(text, '').strip())
output:
为什么天空是蓝色的?
天空是蓝色的是因为大气中的气体分子散射了太阳光中的短波长蓝光,使得我们看到的天空呈现出蓝色。
release合并后的模型权重,一步到位直接使用,省电、减少碳排放。
基于 多LoRA权重合并(适用于Chinese-Alpaca-Plus )方法手动合并而成,具体是使用 decapoda-research/llama-13b-hf 底座模型 合并 ziqingyang/chinese-llama-plus-lora-13b 和 ziqingyang/chinese-alpaca-plus-lora-13b 两个LoRA权重 得到,并转化为HuggingFace版本权重(.bin文件)。
HuggingFace版本权重(.bin文件)可用于:
PyTorch版本权重(.pth文件)可用于:
PyTorch版本权重(.pth文件)链接:shibing624/chinese-alpaca-plus-13b-pth
模型文件组成:
chinese-alpaca-plus-13b-hf
|-- config.json
|-- generation_config.json
|-- LICENSE
|-- pytorch_model-00001-of-00003.bin
|-- pytorch_model-00002-of-00003.bin
|-- pytorch_model-00003-of-00003.bin
|-- pytorch_model.bin.index.json
|-- README.md
|-- special_tokens_map.json
|-- tokenizer_config.json
`-- tokenizer.model
硬件要求:25G显存
我整理部分公开微调数据集:
如果需要训练LLaMA模型,请参考https://github.com/shibing624/textgen
@software{textgen,
author = {Xu Ming},
title = {textgen: Implementation of language model finetune},
year = {2023},
url = {https://github.com/shibing624/textgen},
}
Detailed results can be found here
| Metric | Value |
|---|---|
| Avg. | 46.63 |
| ARC (25-shot) | 53.16 |
| HellaSwag (10-shot) | 73.51 |
| MMLU (5-shot) | 48.81 |
| TruthfulQA (0-shot) | 45.32 |
| Winogrande (5-shot) | 75.06 |
| GSM8K (5-shot) | 2.12 |
| DROP (3-shot) | 28.45 |