license: gpl-3.0
tags:
- text2text-generation
pipeline_tag: text2text-generation
language:
- zh
- en
Considering LLaMA's license constraints, the model is for research and learning only. Please strictly respect LLaMA's usage policy. We are not allowed to publish weights for LLaMA, of course, even finetuned, but there is no problem publishing the difference, a patch that we suggest to apply to the files. The encryption is a simple XOR between files, ensuring that only the people that have access to the original weights (from completely legal sources, of course) can transform them into finetuned weights. You can find the decrypt code on https://github.com/LianjiaTech/BELLE/tree/main/models .
Model Card for Model ID
Welcome
If you find this model helpful, please like this model and star us on https://github.com/LianjiaTech/BELLE !
Update
A new checkpoint trained with learning rate of 5e-6 is uploaded. In our evaluation, llama trained with smaller lr achieved better performance.
Model description
BELLE-LLAMA-7B-0.6M-enc is based on LLAMA 7B and finetuned with 0.6M Chinese data combined with 50,000 pieces of English data from the open source Stanford-Alpaca, resulting in good Chinese instruction understanding and response generation capabilities.
The code of Chinese data generation and other detailed information can be found in our Github project repository: https://github.com/LianjiaTech/BELLE.
Training hyper-parameters
Parameter | Value |
---|---|
Batch size | 16 |
Learning rate | 5e-6 |
Epochs | 3 |
Weight_decay | 0.0 |
Warmup_rate | 0.03 |
LR_scheduler | cosine |
Download, Convert & Check
- After you git clone this model
md5sum ./*
340aa9ee27fa7931ccbabcc30f2f8a27 ./config.json.db303d8f096e427bd21ff97bb169c84fb3ae11336a644e3da3506419d44f6429.enc
f9b33d359f17a437f6c24b4de6f2272e ./generation_config.json.fd7ff399e5568cc21a0a8414f43df88ef7c424995b9b97a90563165d2cf79efd.enc
5f8dc6a1cffe09cbcaccf9276b50e1ca ./pytorch_model.bin.e928a21ab00c6c5a6621be5fe6e5d55103249b73d6374f178b086903ff468db6.enc
1ab707fa9b0c4be294fd0b867d73e919 ./special_tokens_map.json.44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a.enc
ff291fcfa4e0048ca4ff262312faad83 ./tokenizer_config.json.ef7ef410b9b909949e96f172b17cbf7c68b11761c632715fa05a6088c0c2b9ac.enc
39ec1b33fbf9a0934a8ae0f9a24c7163 ./tokenizer.model.9e556afd44213b6bd1be2b850ebbbd98f5481437a8021afaf58ee7fb1818d347.enc
- Decrypt the files using the scripts in https://github.com/LianjiaTech/BELLE/tree/main/models
You can use the following command in Bash. Please replace "/path/to_encrypted" with the path where you stored your encrypted file, replace "/path/to_original_llama_7B" with the path where you stored your original llama7B file, and replace "/path/to_finetuned_model" with the path where you want to save your final trained model.
mkdir /path/to_finetuned_model
for f in "/path/to_encrypted"/*; \
do if [ -f "$f" ]; then \
python3 decrypt.py "$f" "/path/to_original_llama_7B/consolidated.00.pth" "/path/to_finetuned_model/"; \
fi; \
done
After executing the aforementioned command, you will obtain the following files.
./config.json
./generation_config.json
./pytorch_model.bin
./special_tokens_map.json
./tokenizer_config.json
./tokenizer.model
- Check md5sum
You can verify the integrity of these files by performing an MD5 checksum to ensure their complete recovery. Here are the MD5 checksums for the relevant files:
md5sum ./*
32490e7229fb82c643e3a7b8d04a6c4b ./config.json
2917a1cafb895cf57e746cfd7696bfe5 ./generation_config.json
220097cda1c2fdce7162fcf1116eead3 ./pytorch_model.bin
99914b932bd37a50b983c5e7c90ae93b ./special_tokens_map.json
5526ad31f4928acb5219e295e5ff81ce ./tokenizer_config.json
eeec4125e9c7560836b4873b6f8e3025 ./tokenizer.model
Use model
Please note that the input should be formatted as follows in both training and inference.
Human: {input} \n\nAssistant:
In order to load BELLE-LLAMA-7B-0.6M-enc with huggingface transformers, please install the main version, as the latest stable version doesn't support LLAMA (as of March 26, 2023).
pip install git+https://github.com/huggingface/transformers
After you decrypt the files, BELLE-LLAMA-7B-0.6M can be easily loaded with LlamaForCausalLM.
from transformers import LlamaForCausalLM, AutoTokenizer
import torch
ckpt = '/path/to_finetuned_model/'
device = torch.device('cuda')
model = LlamaForCausalLM.from_pretrained(ckpt, device_map='auto', low_cpu_mem_usage=True)
tokenizer = AutoTokenizer.from_pretrained(ckpt)
prompt = "Human: 写一首中文歌曲,赞美大自然 \n\nAssistant: "
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)
generate_ids = model.generate(input_ids, max_new_tokens=500, do_sample = True, top_k = 30, top_p = 0.85, temperature = 0.5, repetition_penalty=1., eos_token_id=2, bos_token_id=1, pad_token_id=0)
output = tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
response = output[len(prompt):]
Limitations
There still exists a few issues in the model trained on current base model and data:
The model might generate factual errors when asked to follow instructions related to facts.
Occasionally generates harmful responses since the model still struggles to identify potential harmful instructions.
Needs improvements on reasoning and coding.
Since the model still has its limitations, we require developers only use the open-sourced code, data, model and any other artifacts generated via this project for research purposes. Commercial use and other potential harmful use cases are not allowed.
Citation
Please cite us when using our code, data or model.
@misc{BELLE,
author = {Yunjie Ji, Yong Deng, Yan Gong, Yiping Peng, Qiang Niu, Baochang Ma, Xiangang Li},
title = {BELLE: Be Everyone's Large Language model Engine},
year = {2023},
publisher = {GitHub},
journal = {GitHub repository},
howpublished = {\url{https://github.com/LianjiaTech/BELLE}},
}