Recently, based on the open source project ymcui/Chinese-LLaMA-Alpaca , I have completed my own Chinese model fine-tuning work, and formed two tools to share with everyone. ymcui/Chinese-LLaMA-Alpaca
Fine-tuning files in the form of build instructions
If it is used for fine-tuning, the fine-tuning data must first be prepared. If the target application is question answering, the data needs to be prepared in the question-and-answer format. So I wrote the first tool for reading data from xlsx files and forming question and answer data in json format.
[
{
"instruction": "系统操作员,用户说:",
"input": "我想查询我的xx记录",
"output": "response:\n请稍后,正在对接相关服务\ncommand:\nsearch(\"xx查询接口\")"
},
....
]
The content of the JSON file is an array of objects, and each object in the array contains the contents of the three fields instruction, input, and output, corresponding to the prompt, input, and output in a dialog.
Therefore, our tool is mainly responsible for scanning all xlsx files from the directory, reading the content in it, and forming the content in this format line by line.
Perform merge operations online
After forming the data file, we merged using Google Colab online. What we share here is the overall merge script
mege-chinese-llama/Online merge Chinese model.ipynb at main baijiafan/mege-chinese-llama (github.com) https://github.com/baijiafan/mege-chinese-llama/blob/main/%E5% 9C%A8%E7%BA%BF%E5%90%88%E5%B9%B6%E4%B8%AD%E6%96%87%E6%A8%A1%E5%9E%8B.ipynb This script contains Some branch steps, please follow the instructions to choose different branches when using.
include
1) For the first execution, perform the merging steps of ymcui/Chinese-LLaMA-Alpaca to form a Chinese basic model and store it in Google Drive
2) At other times, you don’t need to perform the above steps, and directly load the relevant model from Google Drive
and options such as choosing a different storage method.
The above script will form a fine-tuned Lora model based on the fine-tuned text and the basic model, which can be merged locally to form the final Chinese fine-tuned model.
Why is there no direct online merge? My suggestion is to copy the lora model back to the local area for merging. First, because the merging equipment requirements are not high, it can be completed locally. In addition, because the size of the lora model is smaller than the complete model, the original merging model of my 7B version is here. At about 16G, the fine-tuning weight is about 1.5G, which is a lot worse. In this way, it is easier to download the fine-tuning model in the domestic environment.