Views
No views yet
This is the result of the weight difference betweenLlama 13BandZhiXi-13B. You can click here to learn more.
initial phase introduced a knowledge extraction LLM based on LLaMA, dubbed ZhiXi (智析, which means intelligent analysis of data for knowledge extraction). To integrate the capacity of Chinese understanding into the language models without compromising their inherent knowledge, we firstly (1) use Chinese corpora for the full-scale pre-training with LLaMA (13B), augment the language model's understanding of Chinese and improve its knowledge richness while retaining its original English and code capacities; Then (2) we fine-tune the model obtained from the first step with an instruction dataset, thus bolstering the language model's understanding of human instructions for knowledge extraction.ZhiXi-13B-Diff. If you have downloaded ZhiXi-13B-Diff-fp16, there may be some variations in the effects.| Model Name | Train Method | Weight Type | Size | Download Link | Notes |
|---|---|---|---|---|---|
| ZhiXi-13B-Diff | Full Pretraining | Differential Weights | 48GB | HuggingFace GoogleDrive | Restoring the pre-trained weights (i.e. ZhiXi-13B) needs to match the weights of LLaMA-13B, please refer to here for specific instructions. |
| ZhiXi-13B-Diff-fp16 | Full Pretraining | Differential Weights(fp16) | 24GB | HuggingFace Google Drive | The main difference with ZhiXi-13B-Diff is the adoption of the fp16 format for storage, which reduces memory usage. However, it may result in slight differences in the weights obtained from our actual training, which can slightly impact performance. For specific usage instructions, please refer to here for specific instructions. |
| ZhiXi-13B-LoRA | LoRA Instruction-tuning | LoRA Weights | 251MB | HuggingFace GoogleDrive | It needs to be used with ZhiXi-13B. For specific instructions, please refer to here. |
| ZhiXi-7B Series | Coming soon | Coming soon | Coming soon | Coming soon | Coming soon |
1conda create -n knowlm python=3.9 -y
2conda activate knowlm
3pip install torch==1.12.0+cu116 torchvision==0.13.0+cu116 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu116
4pip install -r requirements.txt2.2, which involves merging LLaMA-13B with KnowLM-13B-Diff, requires approximately 100GB of RAM, with no demand for VRAM (this is due to the memory overhead caused by our merging strategy. For your convenience, we have provided the fp16 weights at this link: https://huggingface.co/zjunlp/zhixi-13b-diff-fp16. fp16 weights require less memory but may slightly impact performance. We will improve our merging approach in future updates, and we are currently developing a 7B model as well, so stay tuned). For step 2.4, which involves inference using ZhiXi, a minimum of 26GB of VRAM is required.meta. In this case, we are using the 13B version of the model, so you only need to download the 13B version. Once downloaded, the file directory will be as follows:1|-- 13B
2| |-- checklist.chk
3| |-- consolidated.00.pth
4| |-- consolidated.01.pth
5| |-- params.json
6|-- llama.sh
7|-- tokenizer.model
8|-- tokenizer_checklist.chkKnowLM-13B-Diff file (assuming it is saved in the ./knowlm-diff folder):python tools/download.py --specify --repo_name openkg/knowlm-13b-diff --download_path ./knowlm-diff:exclamation:Noted. If the download is interrupted, please repeat the command mentioned above. HuggingFace provides the functionality of resumable downloads, allowing you to resume the download from where it was interrupted.
./ and you want the converted files to be stored in ./converted):python convert_llama_weights_to_hf.py --input_dir ./ --model_size 13B --output_dir ./converted./tools/weight_diff.py, execute the following command, and you will get the complete KnowLM weight:python tools/weight_diff.py recover --path_raw ./converted --path_diff ./knowlm-diff --path_tuned ./knowlm --check_integrity_naively False./knowlm folder../tools/download.py, execute the following command to get the LoRA weight (assuming the saved path is located at ./LoRA):python tools/download.py --download_path ./lora --specify --repo_name openkg/knowlm-13b-lora./lora folder.python examples/generate_finetune.py --base_model ./knowlm --interactivepython examples/generate_finetune_web.py --base_model ./knowlmpython examples/generate_lora_web.py --base_model ./knowlm --lora_weights ./lorainstruction is a required parameter, while input is an optional parameter. For general tasks (such as the examples provided in section 1.3), you can directly enter the input in the instruction field. For information extraction tasks (as shown in the example in section 1.2), please enter the instruction in the instruction field and the sentence to be extracted in the input field. We provide an information extraction prompt in section 2.5.examples/generate_lora.py file and update the examples and hyperparameters in the variable cases.The following figures illustrates the entire training process and dataset construction. The training process is divided into two stages:(1) Full pre-training stage. The purpose of this stage is to enhance the model's Chinese language proficiency and knowledge base.(2) Instruction tuning stage using LoRA. This stage enables the model to understand human instructions and generate appropriate responses.

Pile dataset, we crawled code data from GitHub and LeetCode. A portion of the data was used for pre-training, while another portion was used for fine-tuning with instructions.1024, while most documents are much longer than this. Therefore, we need to partition these documents. We designed a greedy algorithm to split the documents, with the goal of ensuring that each sample consists of complete sentences and minimizing the number of segments while maximizing the length of each sample. Additionally, due to the diversity of data sources, we developed a comprehensive data preprocessing tool that can process and merge data from various sources. Finally, considering the large amount of data, loading it directly into memory would impose excessive hardware pressure. Therefore, we referred to DeepSpeed-Megatron and used the mmap method to process and load the data. This involves loading the indices into memory and accessing the corresponding data on disk when needed.Trainer in conjunction with Deepspeed ZeRO3 (it was observed that strategy ZeRO2 had slower speeds in a multi-node, multi-GPU setup). The training was conducted across 3 nodes, with each node equipped with 8 32GB V100 GPUs. The table below showcases our training speeds:| Parameter | Values |
|---|---|
| micro batch size | 20 |
| gradient accumulation | 3 |
| global batch size | 20*3*24=1440 |
| Time-consuming of a step | 260s |
alpaca dataset CoT dataset and code dataset are in English. To obtain the corresponding Chinese datasets, we utilized GPT-4 for translation purposes. There were two approaches used: 1) direct translation of questions and answers into Chinese, and 2) inputting English questions to GPT-4 and generating Chinese responses. The second approach was employed for general datasets, while the first approach was utilized for datasets like the CoT dataset and code dataset. These datasets are readily available online.CoNLL, ACE, CASIS, and others to construct corresponding English instructions for generating the required training format. For the Chinese part, for NER and EE tasks, we utilized open-source datasets such as DualEE, PEOPLE DAILY, and others, and then created corresponding Chinese instructions to synthesize the required training format. As for the RE task, we built a dataset called KG2Instruction. Specifically, we used Chinese Wikipedia data and BERT for Chinese entity recognition. We then aligned the recognized entities with the Wikipedia index. Due to potential ambiguity (i.e., a Chinese entity may have multiple indexes, such as apple referring to both a fruit and a company), we devised a strategy to disambiguate the entities. Subsequently, we used a distantly supervised method to generate possible triplets and applied predefined rules to filter out illegal or incorrect triplets. Finally, with the help of crowdsourcing, we refined the obtained triplets. Following that, we constructed corresponding Chinese instructions to generate the required training format.| Dataset | Number |
|---|---|
| COT Datasets (Chinese, English) | 202333 |
| General Datasets (Chinese, English) | 105216 |
| Code Datasets (Chinese, English) | 44688 |
| Information Extraction Datasets (English) | 537429 |
| Information Extraction Datasets (Chinese) | 486768 |
do_sample=True. It could also be due to the order of execution. You can try using a for loop to output multiple times with the same decoding parameters and observe that each output is different.1@article{deepke-llm,
2 author = {Ningyu Zhang, Jintian Zhang, Xiaohan Wang, Honghao Gui, Yinuo Jiang, Xiang Chen, Shengyu Mao, Shuofei Qiao, Zhen Bi, Jing Chen, Xiaozhuan Liang, Yixin Ou, Ruinan Fang, Zekun Xi, Xin Xu, Liankuan Tao, Lei Li, Peng Wang, Zhoubo Li, Guozhou Zheng, Huajun Chen},
3 title = {DeepKE-LLM: A Large Language Model Based Knowledge Extraction Toolkit},
4 year = {2023},
5 publisher = {GitHub},
6 journal = {GitHub repository},
7 howpublished = {\url{https://github.com/}},
8}