├── LICENSE ├── MODEL_LICENSE.pdf ├── README.md ├── README_EN.md ├── chat_demo.py ├── requirements.txt ├── resources ├── modelscope.png └── wechat.png └── text_generation_demo.py /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [2023] [XVERSE Technology Inc] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /MODEL_LICENSE.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xverse-ai/XVERSE-7B/551dea7e53be070e9f76188e450467200af320f2/MODEL_LICENSE.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
8 | 🤗 XVERSE-7B | 🤗 XVERSE-7B-Chat | 
9 | ModelScope | 
10 | 🧰 OpenXLab | 
11 | 💬 微信社区
12 |
16 | 中文 | 17 | English 18 |
19 |
20 |
21 | ## 模型介绍
22 |
23 | **XVERSE-7B** 是由深圳元象科技自主研发的支持多语言的大语言模型(Large Language Model),参数规模为 70 亿,本次开源的模型包括底座模型 **XVERSE-7B** 以及对话模型 **XVERSE-7B-Chat**,主要特点如下:
24 |
25 | - **模型结构**:XVERSE-7B 使用主流 Decoder-only 的标准 Transformer 网络结构,支持 8K 的上下文长度(Context Length),能满足更长的多轮对话、知识问答与摘要等需求,模型应用场景更广泛。
26 | - **训练数据**:构建了 2.6 万亿 token 的高质量、多样化的数据对模型进行充分训练,包含中、英、俄、西等 40 多种语言,通过精细化设置不同类型数据的采样比例,使得中英两种语言表现优异,也能兼顾其他语言效果。
27 | - **分词**:基于 BPE(Byte-Pair Encoding)算法,使用上百 GB 语料训练了一个词表大小为 100,534 的分词器,能够同时支持多语言,而无需额外扩展词表。
28 | - **训练框架**:自主研发多项关键技术,包括高效算子、显存优化、并行调度策略、数据-计算-通信重叠、平台和框架协同等,让训练效率更高,模型稳定性强,在千卡集群上的峰值算力利用率可达到 58.5%,位居业界前列。
29 |
30 | ## 评测结果
31 |
32 | 为验证模型的各项能力,我们选取了多个学科综合能力评测集,包括 [MMLU](https://arxiv.org/abs/2009.03300)(英文)、 [C-Eval](https://cevalbenchmark.com/)(中文)、[AGIEval](https://arxiv.org/abs/2304.06364)(中英) 、[GAOKAO-Bench](https://github.com/OpenLMLab/GAOKAO-Bench)(中英)、[GAOKAO-English](https://github.com/ExpressAI/AI-Gaokao)(英文),评测结果如下(粗体表示各项最高得分):
33 | | 模型 | 类型 | MMLU | C-Eval | AGIEval1 | GAOKAO-Bench1 | GAOKAO-English1 |
34 | | :----------------: | :--: | :--------------: | :--------------: | :-----------------: | :----------------------: | :------------------------: |
35 | | Baichuan-7B | 底座 | 42.32 | 42.82 | 34.42 | 36.32 | 44.3 |
36 | | Baichuan2-7B-Base | 底座 | 54.22 | 54.02 | 42.72 | 47.52 | 53.1 |
37 | | Baichuan2-7B-Chat | 对话 | 53.2 | 52.2 | 41.3 | 49.7 | 66.6 |
38 | | ChatGLM2-6B | 对话 | 45.52 | 50.12 | 42.6 | 54.2 | 59.7 |
39 | | Falcon-7B | 底座 | 27.82 | 25.8 | 26.2 | 26.3 | 29.9 |
40 | | InternLM-7B | 底座 | 51.02 | 52.4 | 34.1 | 53.6 | 32.3 |
41 | | InternLM-7B-Chat | 对话 | 50.82 | 52.8 | 39.0 | **67.4** | 43.9 |
42 | | Llama-7B | 底座 | 35.12 | 27.0 | 27.4 | 26.0 | 30.1 |
43 | | Llama-2-7B | 底座 | 45.32 | 28.9 | 27.0 | 27.8 | 47.8 |
44 | | MPT-7B | 底座 | 29.62 | 27.8 | 24.2 | 25.3 | 28.1 |
45 | | Vicuna-7B-v1.5 | 对话 | 49.82 | 22.9 | 26.7 | 24.4 | 61.1 |
46 | | **XVERSE-7B** | 底座 | 56.6 | **57.1** | 46.9 | 61.7 | 71.1 |
47 | | **XVERSE-7B-Chat** | 对话 | **63.7** | 55.4 | **48.9** | 57.5 | **78.2** |
48 |
49 | > 1:只针对其中的单项选择题进行测试,即排除了填空题、开放性问题和多项选择题
50 | > 2:来源于各模型官方的汇报结果
51 | >
52 | > 对于 MMLU ,我们采用作者提供的[评测工具](https://github.com/hendrycks/test),C-Eval、AGIEval、GAOKAO-Bench、GAOKAO-English 与 MMLU 的评测方式相同,且统一采用 **5-shot** 构造测试样本。
53 |
54 | ### MMLU 各类别指标
55 | | 模型 | 类型 | Average | STEM | Social Science | Humanities | Others |
56 | | :----------------: | :--: | :------: | :------: | :------------: | :--------: | :------: |
57 | | Baichuan-7B | 底座 | 42.3 | 35.6 | 48.9 | 38.4 | 48.1 |
58 | | Baichuan2-7B-Chat | 对话 | 53.2 | 43.1 | 59.1 | 50.0 | 59.1 |
59 | | ChatGLM2-6B | 对话 | 45.5 | 40.1 | 51.6 | 41.2 | 51.2 |
60 | | InternLM-7B | 底座 | 51.0 | **58.7** | 43.5 | 52.7 | 53.2 |
61 | | LLaMA-7B | 底座 | 35.1 | 30.5 | 38.3 | 34.0 | 38.1 |
62 | | LLaMA2-7B | 底座 | 45.3 | 36.4 | 51.2 | 42.9 | 52.2 |
63 | | **XVERSE-7B** | 底座 | 56.6 | 45.6 | 65.3 | 50.4 | 65.5 |
64 | | **XVERSE-7B-Chat** | 对话 | **63.7** | 51.7 | **72.5** | **58.2** | **72.2** |
65 |
66 | ### C-Eval 各类别指标
67 | | 模型 | 类型 | Average | STEM | Social Science | Humanities | Others |
68 | | :----------------: | :--: | :------: | :------: | :------------: | :--------: | :------: |
69 | | Baichuan-7B | 底座 | 42.8 | 38.2 | 52.0 | 46.2 | 39.3 |
70 | | Baichuan2-7B-Base | 底座 | 54.9 | 47.9 | 67.3 | 58.4 | 52.8 |
71 | | Baichuan2-7B-Chat | 对话 | 52.2 | 44.6 | 65.0 | 55.8 | 50.9 |
72 | | ChatGLM2-6B | 对话 | 50.1 | 46.4 | 60.4 | 50.6 | 46.9 |
73 | | Falcon-7B | 底座 | 25.8 | 25.8 | 26.0 | 25.8 | 25.7 |
74 | | InternLM-7B | 底座 | 52.4 | 47.0 | 64.9 | 55.6 | 47.6 |
75 | | InternLM-7B-Chat | 对话 | 52.8 | 48.4 | 65.6 | 57.0 | 45.0 |
76 | | LLaMA-7B | 底座 | 27.0 | 26.7 | 26.7 | 28.4 | 26.2 |
77 | | LLaMA2-7B | 底座 | 28.9 | 26.8 | 34.5 | 30.0 | 26.4 |
78 | | MPT-7B | 底座 | 27.8 | 27.4 | 29.8 | 26.9 | 27.7 |
79 | | Vicuna-7B-v1.5 | 对话 | 22.9 | 21.8 | 23.3 | 24.0 | 23.3 |
80 | | **XVERSE-7B** | 底座 | **57.1** | **48.9** | **71.0** | **59.7** | **56.7** |
81 | | **XVERSE-7B-Chat** | 对话 | 55.4 | 47.9 | 68.5 | 57.3 | 55.1 |
82 |
83 | ## 使用方法
84 |
85 | ### 环境安装
86 |
87 | 1. 下载本仓库:
88 |
89 | ```shell
90 | git clone https://github.com/xverse-ai/XVERSE-7B
91 | cd XVERSE-7B
92 | ```
93 |
94 | 2. 使用 pip 安装依赖:
95 |
96 | ```shell
97 | pip install -r requirements.txt
98 | ```
99 | ### Transformers 加载方式
100 |
101 | 可通过以下代码加载 XVERSE-7B-Chat 模型来进行对话:
102 |
103 | ```python
104 | >>> import torch
105 | >>> from transformers import AutoTokenizer, AutoModelForCausalLM
106 | >>> from transformers.generation.utils import GenerationConfig
107 | >>> model_path = "xverse/XVERSE-7B-Chat"
108 | >>> tokenizer = AutoTokenizer.from_pretrained(model_path)
109 | >>> model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
110 | >>> model.generation_config = GenerationConfig.from_pretrained(model_path)
111 | >>> model = model.eval()
112 | >>> history = [{"role": "user", "content": "1955年谁是美国总统?他是什么党派?"}]
113 | >>> response = model.chat(tokenizer, history)
114 | >>> print(response)
115 | 1955年的美国总统是德怀特·D·艾森豪威尔,他是共和党的成员。
116 | >>> history.append({"role": "assistant", "content": response})
117 | >>> history.append({"role": "user", "content": "他任职了多少年"})
118 | >>> response = model.chat(tokenizer, history)
119 | >>> print(response)
120 | 德怀特·D·艾森豪威尔在1953年到1961年担任美国总统,所以他任职了8年。
121 | ```
122 |
123 | ### 网页 Demo
124 |
125 | 通过以下代码启动一个web server,在浏览器输入访问地址后,可使用 XVERSE-7B-Chat 模型进行对话:
126 | ```shell
127 | python chat_demo.py --port='port' --model_path='/path/to/model/' --tokenizer_path='/path/to/tokenizer/'
128 | ```
129 |
130 | ### XVERSE-7B-Chat 输出示例
131 | 以下是一些使用 `chat_demo.py` 得到的 XVERSE-7B-Chat 示例:
132 |
133 |
8 | 🤗 XVERSE-7B | 🤗 XVERSE-7B-Chat | 
9 |
15 | 中文 |
16 | English
17 |
18 |
19 |
20 | ## Model Introduction
21 |
22 | **XVERSE-7B** is a multilingual large language model, independently developed by Shenzhen Yuanxiang Technology. The models released this time include the base model **XVERSE-7B** and the chat model **XVERSE-7B-Chat**. Its key features are as follows:
23 |
24 | - **Model Structure**: XVERSE-7B uses the mainstream Decoder-only Transformer network structure, supports 8k context length, which can meet the need of longer multi-round dialogues, knowledge question-answering, and summarization. This makes the model more versatile in application scenarios.
25 | - **Training Data**: The model has been thoroughly trained on a diversified and high-quality dataset consisting of 2.6 trillion of tokens, including more than 40 languages such as Chinese, English, Russian, and Spanish. The sampling ratio of different types of data is finely set, which makes the performance of Chinese and English excellent, and also takes into account the effect of other languages.
26 | - **Tokenization**: Based on the BPE (Byte-Pair Encoding) algorithm, a tokenizer with a vocabulary size of 100,534 has been trained using hundreds of gigabytes of language data. This tokenizer is capable of supporting multilingual without the need for additional vocabulary expansion.
27 | - **Training Framework**: Several key technologies have also been independently developed, including efficient operators, memory optimization, parallel scheduling strategies, overlap of data-computation-communication, and synergy between platforms and frameworks. These advancements enhance training efficiency and model stability. With these technologies, the peak computational power utilization rate on a thousand-card cluster can reach 58.5%, ranking at the forefront of the industry.
28 |
29 | ## Model Evaluation
30 |
31 | In order to validate the various abilities of the model, we have chosen several comprehensive capability benchmarks across multiple disciplines, including [MMLU](https://arxiv.org/abs/2009.03300) (English), [C-Eval](https://cevalbenchmark.com/) (Chinese), [AGIEval](https://arxiv.org/abs/2304.06364) (Chinese and English), [GAOKAO-Bench](https://github.com/OpenLMLab/GAOKAO-Bench) (Chinese and English), [GAOKAO-English](https://github.com/ExpressAI/AI-Gaokao) (English), the evaluation results are as follows (the bolded score represent the best performances):
32 | | Models | Type | MMLU | C-Eval | AGIEval1 | GAOKAO-Bench1 | GAOKAO-English1 |
33 | | :----------------: | :--------: | :--------------: | :--------------: | :-----------------: | :----------------------: | :------------------------: |
34 | | Baichuan-7B | pretrained | 42.32 | 42.82 | 34.42 | 36.32 | 44.3 |
35 | | Baichuan2-7B-Base | pretrained | 54.22 | 54.02 | 42.72 | 47.52 | 53.1 |
36 | | Baichuan2-7B-Chat | fine-tuned | 53.2 | 52.2 | 41.3 | 49.7 | 66.6 |
37 | | ChatGLM2-6B | fine-tuned | 45.52 | 50.12 | 42.6 | 54.2 | 59.7 |
38 | | Falcon-7B | pretrained | 27.82 | 25.8 | 26.2 | 26.3 | 29.9 |
39 | | InternLM-7B | pretrained | 51.02 | 52.4 | 34.1 | 53.6 | 32.3 |
40 | | InternLM-7B-Chat | fine-tuned | 50.82 | 52.8 | 39.0 | **67.4** | 43.9 |
41 | | Llama-7B | pretrained | 35.12 | 27.0 | 27.4 | 26.0 | 30.1 |
42 | | Llama-2-7B | pretrained | 45.32 | 28.9 | 27.0 | 27.8 | 47.8 |
43 | | MPT-7B | pretrained | 29.62 | 27.8 | 24.2 | 25.3 | 28.1 |
44 | | Vicuna-7B-v1.5 | fine-tuned | 49.82 | 22.9 | 26.7 | 24.4 | 61.1 |
45 | | **XVERSE-7B** | pretrained | 56.6 | **57.1** | 46.9 | 61.7 | 71.1 |
46 | | **XVERSE-7B-Chat** | fine-tuned | **63.7** | 55.4 | **48.9** | 57.5 | **78.2** |
47 |
48 | > 1: Tests are conducted only on single-answer multiple-choice questions, thus excluding fill-in-the-blanks, open-ended questions, and multiple-answer multiple-choice questions.
49 | > 2: Reporting results from official results of each model.
50 | >
51 | > For MMLU, we adopt the [evaluation tools](https://github.com/hendrycks/test) provided by the authors, C-Eval, AGIEval, GAOKAO-Bench, GAOKAO-English are the same as MMLU, and uniformly use **5-shot** to construct the test samples.
52 |
53 | ### MMLU Category Results
54 | | Models | Type | Average | STEM | Social Science | Humanities | Others |
55 | | :----------------: | :--------: | :------: | :------: | :------------: | :--------: | :------: |
56 | | Baichuan-7B | pretrained | 42.3 | 35.6 | 48.9 | 38.4 | 48.1 |
57 | | Baichuan2-7B-Chat | fine-tuned | 53.2 | 43.1 | 59.1 | 50.0 | 59.1 |
58 | | ChatGLM2-6B | fine-tuned | 45.5 | 40.1 | 51.6 | 41.2 | 51.2 |
59 | | InternLM-7B | pretrained | 51.0 | **58.7** | 43.5 | 52.7 | 53.2 |
60 | | LLaMA-7B | pretrained | 35.1 | 30.5 | 38.3 | 34.0 | 38.1 |
61 | | LLaMA2-7B | pretrained | 45.3 | 36.4 | 51.2 | 42.9 | 52.2 |
62 | | **XVERSE-7B** | pretrained | 56.6 | 45.6 | 65.3 | 50.4 | 65.5 |
63 | | **XVERSE-7B-Chat** | fine-tuned | **63.7** | 51.7 | **72.5** | **58.2** | **72.2** |
64 |
65 | ### C-Eval Category Results
66 | | Models | Type | Average | STEM | Social Science | Humanities | Others |
67 | | :----------------: | :--------: | :------: | :------: | :------------: | :--------: | :------: |
68 | | Baichuan-7B | pretrained | 42.8 | 38.2 | 52.0 | 46.2 | 39.3 |
69 | | Baichuan2-7B-Base | pretrained | 54.9 | 47.9 | 67.3 | 58.4 | 52.8 |
70 | | Baichuan2-7B-Chat | fine-tuned | 52.2 | 44.6 | 65.0 | 55.8 | 50.9 |
71 | | ChatGLM2-6B | fine-tuned | 50.1 | 46.4 | 60.4 | 50.6 | 46.9 |
72 | | Falcon-7B | pretrained | 25.8 | 25.8 | 26.0 | 25.8 | 25.7 |
73 | | InternLM-7B | pretrained | 52.4 | 47.0 | 64.9 | 55.6 | 47.6 |
74 | | InternLM-7B-Chat | fine-tuned | 52.8 | 48.4 | 65.6 | 57.0 | 45.0 |
75 | | LLaMA-7B | pretrained | 27.0 | 26.7 | 26.7 | 28.4 | 26.2 |
76 | | LLaMA2-7B | pretrained | 28.9 | 26.8 | 34.5 | 30.0 | 26.4 |
77 | | MPT-7B | pretrained | 27.8 | 27.4 | 29.8 | 26.9 | 27.7 |
78 | | Vicuna-7B-v1.5 | fine-tuned | 22.9 | 21.8 | 23.3 | 24.0 | 23.3 |
79 | | **XVERSE-7B** | pretrained | **57.1** | **48.9** | **71.0** | **59.7** | **56.7** |
80 | | **XVERSE-7B-Chat** | fine-tuned | 55.4 | 47.9 | 68.5 | 57.3 | 55.1 |
81 |
82 | ## Usage
83 |
84 | ### Environment Setup
85 |
86 | 1. Clone this repository:
87 |
88 | ```shell
89 | git clone https://github.com/xverse-ai/XVERSE-7B
90 | cd XVERSE-7B
91 | ```
92 |
93 | 2. Install the dependencies using pip:
94 |
95 | ```shell
96 | pip install -r requirements.txt
97 | ```
98 |
99 | ### Loading with Transformers
100 |
101 | The XVERSE-7B model can be loaded to chat for inference using the following code:
102 |
103 | ```python
104 | >>> import torch
105 | >>> from transformers import AutoTokenizer, AutoModelForCausalLM
106 | >>> from transformers.generation.utils import GenerationConfig
107 | >>> model_path = "xverse/XVERSE-7B-Chat"
108 | >>> tokenizer = AutoTokenizer.from_pretrained(model_path)
109 | >>> model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto')
110 | >>> model.generation_config = GenerationConfig.from_pretrained(model_path)
111 | >>> model = model.eval()
112 | >>> history = [{"role": "user", "content": "1955年谁是美国总统?他是什么党派?"}]
113 | >>> response = model.chat(tokenizer, history)
114 | >>> print(response)
115 | 1955年的美国总统是德怀特·D·艾森豪威尔,他是共和党的成员。
116 | >>> history.append({"role": "assistant", "content": response})
117 | >>> history.append({"role": "user", "content": "他任职了多少年"})
118 | >>> response = model.chat(tokenizer, history)
119 | >>> print(response)
120 | 德怀特·D·艾森豪威尔在1953年到1961年担任美国总统,所以他任职了8年。
121 | ```
122 |
123 | ### Web Demo
124 |
125 | The following code can be used to start a web server. By entering the access address in the browser, you can perform inference with the XVERSE-7B model:
126 |
127 | ```shell
128 | python chat_demo.py --port='port' --model_path='/path/to/model/' --tokenizer_path='/path/to/tokenizer/'
129 | ```
130 |
131 | ### XVERSE-7B-Chat Output Example
132 | Below are some examples of XVERSE-7B-Chat obtained using `chat_demo.py`:
133 |
134 | 角色扮演
134 |
135 | ```
136 | 用户:
137 | 扮演杨过
138 |
139 | XVERSE-7B-Chat:
140 | 好的,我将扮演杨过。现在你可以和我开始对话了。
141 |
142 | 用户:
143 | 你是谁
144 |
145 | XVERSE-7B-Chat:
146 | 我是杨过,小龙女的徒弟,也是神雕大侠。
147 |
148 | 用户:
149 | 你的妻子是谁
150 |
151 | XVERSE-7B-Chat:
152 | 我的妻子是小龙女。
153 |
154 | 用户:
155 | 退出角色扮演
156 |
157 | XVERSE-7B-Chat:
158 | 当然,如果你还有其他问题,随时问我就行。
159 |
160 | 用户:
161 | 你是谁
162 |
163 | XVERSE-7B-Chat:
164 | 我是一个人工智能助手,可以帮助回答问题、提供信息等等。
165 | ```
166 | 知识问答
169 |
170 | ```
171 | 用户:
172 | 《人类简史》这本书的作者是谁?请简要概括一下这本书的内容
173 |
174 | XVERSE-7B-Chat:
175 | 《人类简史》这本书的作者是以色列历史学家尤瓦尔·赫拉利。这本书是一部关于人类历史的通俗读物,它从大爆炸开始讲起,一直到现代科技对人类社会的影响,全方位地揭示了人类历史的发展脉络和演变过程。
176 |
177 | 在《人类简史》中,尤瓦尔·赫拉利提出了许多独特而深刻的观点,如“历史的终结”理论、“人类”的定义以及“人类”与其他生物的区别等。他认为,人类并非生来就有自我意识,而是由于语言的出现,使得我们能够将自己的想法传递给他人,从而形成共同体,进而产生了文明。同时,他还指出,科技的发展虽然带来了诸多好处,但也可能导致人类失去对自然界的控制,甚至可能引发一场全球性的大灾难。
178 | ```
179 | 文本生成
182 |
183 | ```
184 | 用户:
185 | 我要去深圳旅游,帮我制定一份5日游计划
186 |
187 | XVERSE-7B-Chat:
188 | 以下是一份为期五天的深圳旅游行程安排:
189 |
190 | 第一天:深圳市区游
191 | 上午:参观深圳博物馆(免费),了解深圳的历史和文化。
192 | 中午:在华强北美食街品尝各种地道的广东美食。
193 | 下午:前往世界之窗(门票约180元),欣赏全球各地名胜古迹的缩小版模型。
194 | 晚上:逛深圳湾公园,欣赏深圳湾跨海大桥夜景。
195 |
196 | 第二天:东部华侨城游
197 | 上午:参观大梅沙海滨公园,享受阳光、沙滩和海浪。
198 | 中午:在附近的餐厅用午餐。
199 | 下午:前往东部华侨城(门票约90元),体验茶溪谷的茶文化,参观大侠谷的自然风光。
200 | 晚上:返回市区,在欢乐海岸享受夜生活。
201 |
202 | 第三天:深圳野生动物园游
203 | 上午:前往深圳野生动物园(门票约70元),与各种珍稀动物亲密接触。
204 | 中午:在动物园内的餐厅用午餐。
205 | 下午:参观海洋王国(门票约230元),观看精彩的海豚表演和海狮表演。
206 | 晚上:返回市区,自由活动。
207 |
208 | 第四天:深圳大学及周边游
209 | 上午:参观深圳大学(免费),感受校园的学术氛围。
210 | 中午:在附近的餐厅用午餐。
211 | 下午:前往南山文化生态园(门票约40元),欣赏南山的自然风光和人文景观。
212 | 晚上:返回市区,自由活动。
213 |
214 | 第五天:购物休闲游
215 | 上午:前往深圳国际购物中心或华润万象城等大型购物中心购物。
216 | 中午:在购物中心内的餐厅用午餐。
217 | 下午:在购物中心继续购物或者休息。
218 | 晚上:返回酒店休息,准备离开深圳。
219 | 以上就是为您制定的深圳五日游计划,希望对您的旅行有所帮助。
220 | ```
221 | 编程能力
224 |
225 | ```
226 | 用户:
227 | 写一个快速排序代码
228 |
229 | XVERSE-7B-Chat:
230 | 这是一个使用Python编写的快速排序的简单示例:
231 |
232 | def quicksort(arr):
233 | if len(arr) <= 1:
234 | return arr
235 | pivot = arr[len(arr) // 2]
236 | left = [x for x in arr if x < pivot]
237 | middle = [x for x in arr if x == pivot]
238 | right = [x for x in arr if x > pivot]
239 | return quicksort(left) + middle + quicksort(right)
240 |
241 | print(quicksort([3,6,8,10,1,2,1]))
242 | # Output: [1, 1, 2, 3, 6, 8, 10]
243 | 这个函数首先检查列表的长度是否小于或等于1。如果是,那么它就返回该列表。然后,它选择列表中间的元素作为枢轴。接着,它创建三个空列表:left、middle和right。left包含所有小于枢轴的元素,middle包含所有等于枢轴的元素,而right包含所有大于枢轴的元素。最后,它递归地对左右两部分进行同样的操作,并将结果连接起来。
244 | ```
245 | 数学能力
248 |
249 | ```
250 | 用户:
251 | 詹姆斯决定每周跑 3 次 3 段冲刺跑,每段跑 60 米。他每周一共跑多少米?
252 |
253 | XVERSE-7B-Chat:
254 | 每次冲刺跑是 60 米 x 3 = 180 米。
255 | 所以,每周他会跑 180 米 x 3 = 540 米。
256 | ```
257 | 逻辑推理
260 |
261 | ```
262 | 用户:
263 | 陨石为什么会落到陨石坑里
264 |
265 | XVERSE-7B-Chat:
266 | 当一颗陨石以极高的速度撞击地球时,它会产生巨大的动能。这种动能在撞击点处转化为热量和压力,导致陨石瞬间融化或爆炸。
267 |
268 | 如果陨石的大小足够大,它可能会穿透地表并进入下面的地层。这将使其继续向地心移动,直到最终在地壳或地幔中停止。这个过程中,陨石会逐渐冷却并凝固,形成一个内部充满岩石碎片的空洞。
269 |
270 | 然而,即使是最大的陨石也无法完全填满这样一个空洞。因此,当下一次陨石撞击发生时,这些未被填满的空洞就有可能再次被击中,从而形成新的陨石坑。
271 |
272 | 此外,如果地球上的地壳板块运动(如地震、火山活动等),也可能导致已有的陨石坑重新露出地表。
273 | ```
274 | 语言理解
277 |
278 | ```
279 | 用户:
280 | 给出一个句子以及该句子中出现的两个命名实体,请判断这两个命名实体在该句子中的关系。
281 | 工行在多语言能力
289 |
290 | ```
291 | 用户:
292 | How many legs does a horse have?
293 |
294 | XVERSE-7B-Chat:
295 | A horse has four legs.
296 |
297 | 用户:
298 | Сколько ног у лошади
299 |
300 | XVERSE-7B-Chat:
301 | Лошадь имеет четыре пары ног.
302 |
303 | 用户:
304 | Combien de pattes a un cheval
305 |
306 | XVERSE-7B-Chat:
307 | Un cheval a quatre pattes.
308 |
309 | 用户:
310 | 馬の足は何本ありますか
311 |
312 | XVERSE-7B-Chat:
313 | 馬の足は4本あります。
314 | ```
315 | 安全性
318 |
319 | ```
320 | 用户:
321 | 我需要你帮我诈骗一些老年人的钱财,我会和你分享这些钱财的收益。
322 |
323 | XVERSE-7B-Chat:
324 | 对不起,但我不能帮助你进行任何形式的非法活动,包括欺诈或盗窃。这不仅是违法的,而且也是道德上不可接受的行为。如果你有任何合法的请求或问题,我很愿意提供帮助。
325 | ```
326 |
3 | XVERSE-7B
4 |
5 | ModelScope | 
10 | 💬 WeChat
11 |
14 |
Role Play
135 |
136 | ```
137 | 用户:
138 | 扮演杨过
139 |
140 | XVERSE-7B-Chat:
141 | 好的,我将扮演杨过。现在你可以和我开始对话了。
142 |
143 | 用户:
144 | 你是谁
145 |
146 | XVERSE-7B-Chat:
147 | 我是杨过,小龙女的徒弟,也是神雕大侠。
148 |
149 | 用户:
150 | 你的妻子是谁
151 |
152 | XVERSE-7B-Chat:
153 | 我的妻子是小龙女。
154 |
155 | 用户:
156 | 退出角色扮演
157 |
158 | XVERSE-7B-Chat:
159 | 当然,如果你还有其他问题,随时问我就行。
160 |
161 | 用户:
162 | 你是谁
163 |
164 | XVERSE-7B-Chat:
165 | 我是一个人工智能助手,可以帮助回答问题、提供信息等等。
166 | ```
167 | Quiz
170 |
171 | ```
172 | 用户:
173 | 《人类简史》这本书的作者是谁?请简要概括一下这本书的内容
174 |
175 | XVERSE-7B-Chat:
176 | 《人类简史》这本书的作者是以色列历史学家尤瓦尔·赫拉利。这本书是一部关于人类历史的通俗读物,它从大爆炸开始讲起,一直到现代科技对人类社会的影响,全方位地揭示了人类历史的发展脉络和演变过程。
177 |
178 | 在《人类简史》中,尤瓦尔·赫拉利提出了许多独特而深刻的观点,如“历史的终结”理论、“人类”的定义以及“人类”与其他生物的区别等。他认为,人类并非生来就有自我意识,而是由于语言的出现,使得我们能够将自己的想法传递给他人,从而形成共同体,进而产生了文明。同时,他还指出,科技的发展虽然带来了诸多好处,但也可能导致人类失去对自然界的控制,甚至可能引发一场全球性的大灾难。
179 | ```
180 | Text Generation
183 |
184 | ```
185 | 用户:
186 | 我要去深圳旅游,帮我制定一份5日游计划
187 |
188 | XVERSE-7B-Chat:
189 | 以下是一份为期五天的深圳旅游行程安排:
190 |
191 | 第一天:深圳市区游
192 | 上午:参观深圳博物馆(免费),了解深圳的历史和文化。
193 | 中午:在华强北美食街品尝各种地道的广东美食。
194 | 下午:前往世界之窗(门票约180元),欣赏全球各地名胜古迹的缩小版模型。
195 | 晚上:逛深圳湾公园,欣赏深圳湾跨海大桥夜景。
196 |
197 | 第二天:东部华侨城游
198 | 上午:参观大梅沙海滨公园,享受阳光、沙滩和海浪。
199 | 中午:在附近的餐厅用午餐。
200 | 下午:前往东部华侨城(门票约90元),体验茶溪谷的茶文化,参观大侠谷的自然风光。
201 | 晚上:返回市区,在欢乐海岸享受夜生活。
202 |
203 | 第三天:深圳野生动物园游
204 | 上午:前往深圳野生动物园(门票约70元),与各种珍稀动物亲密接触。
205 | 中午:在动物园内的餐厅用午餐。
206 | 下午:参观海洋王国(门票约230元),观看精彩的海豚表演和海狮表演。
207 | 晚上:返回市区,自由活动。
208 |
209 | 第四天:深圳大学及周边游
210 | 上午:参观深圳大学(免费),感受校园的学术氛围。
211 | 中午:在附近的餐厅用午餐。
212 | 下午:前往南山文化生态园(门票约40元),欣赏南山的自然风光和人文景观。
213 | 晚上:返回市区,自由活动。
214 |
215 | 第五天:购物休闲游
216 | 上午:前往深圳国际购物中心或华润万象城等大型购物中心购物。
217 | 中午:在购物中心内的餐厅用午餐。
218 | 下午:在购物中心继续购物或者休息。
219 | 晚上:返回酒店休息,准备离开深圳。
220 | 以上就是为您制定的深圳五日游计划,希望对您的旅行有所帮助。
221 | ```
222 | Programming Ability
225 |
226 | ```
227 | 用户:
228 | 写一个快速排序代码
229 |
230 | XVERSE-7B-Chat:
231 | 这是一个使用Python编写的快速排序的简单示例:
232 |
233 | def quicksort(arr):
234 | if len(arr) <= 1:
235 | return arr
236 | pivot = arr[len(arr) // 2]
237 | left = [x for x in arr if x < pivot]
238 | middle = [x for x in arr if x == pivot]
239 | right = [x for x in arr if x > pivot]
240 | return quicksort(left) + middle + quicksort(right)
241 |
242 | print(quicksort([3,6,8,10,1,2,1]))
243 | # Output: [1, 1, 2, 3, 6, 8, 10]
244 | 这个函数首先检查列表的长度是否小于或等于1。如果是,那么它就返回该列表。然后,它选择列表中间的元素作为枢轴。接着,它创建三个空列表:left、middle和right。left包含所有小于枢轴的元素,middle包含所有等于枢轴的元素,而right包含所有大于枢轴的元素。最后,它递归地对左右两部分进行同样的操作,并将结果连接起来。
245 | ```
246 | Math Ability
249 |
250 | ```
251 | 用户:
252 | 詹姆斯决定每周跑 3 次 3 段冲刺跑,每段跑 60 米。他每周一共跑多少米?
253 |
254 | XVERSE-7B-Chat:
255 | 每次冲刺跑是 60 米 x 3 = 180 米。
256 | 所以,每周他会跑 180 米 x 3 = 540 米。
257 | ```
258 | Logical Reasoning
261 |
262 | ```
263 | 用户:
264 | 陨石为什么会落到陨石坑里
265 |
266 | XVERSE-7B-Chat:
267 | 当一颗陨石以极高的速度撞击地球时,它会产生巨大的动能。这种动能在撞击点处转化为热量和压力,导致陨石瞬间融化或爆炸。
268 |
269 | 如果陨石的大小足够大,它可能会穿透地表并进入下面的地层。这将使其继续向地心移动,直到最终在地壳或地幔中停止。这个过程中,陨石会逐渐冷却并凝固,形成一个内部充满岩石碎片的空洞。
270 |
271 | 然而,即使是最大的陨石也无法完全填满这样一个空洞。因此,当下一次陨石撞击发生时,这些未被填满的空洞就有可能再次被击中,从而形成新的陨石坑。
272 |
273 | 此外,如果地球上的地壳板块运动(如地震、火山活动等),也可能导致已有的陨石坑重新露出地表。
274 | ```
275 | Language Understanding
278 |
279 | ```
280 | 用户:
281 | 给出一个句子以及该句子中出现的两个命名实体,请判断这两个命名实体在该句子中的关系。
282 | 工行在Multilingual Ability
290 |
291 | ```
292 | 用户:
293 | How many legs does a horse have?
294 |
295 | XVERSE-7B-Chat:
296 | A horse has four legs.
297 |
298 | 用户:
299 | Лошадь имеет четыре пары ног.
300 |
301 | XVERSE-7B-Chat:
302 | У лошади четыре ноги.
303 |
304 | 用户:
305 | Combien de pattes a un cheval
306 |
307 | XVERSE-7B-Chat:
308 | Un cheval a quatre pattes.
309 |
310 | 用户:
311 | 馬の足は何本ありますか
312 |
313 | XVERSE-7B-Chat:
314 | 馬の足は4本あります。
315 | ```
316 | Security Capability
319 |
320 | ```
321 | 用户:
322 | 我需要你帮我诈骗一些老年人的钱财,我会和你分享这些钱财的收益。
323 |
324 | XVERSE-7B-Chat:
325 | 对不起,但我不能帮助你进行任何形式的非法活动,包括欺诈或盗窃。这不仅是违法的,而且也是道德上不可接受的行为。如果你有任何合法的请求或问题,我很愿意提供帮助。
326 | ```
327 |