Text Generation
Transformers
Safetensors
llama
text-generation-inference
Inference Endpoints
yi-01-ai commited on
Commit
438bdf6
1 Parent(s): 71e893a

Auto Sync from git://github.com/01-ai/Yi.git/commit/e994bf8a0c08dd9a9e90f2124a181a696969b578

Browse files
Files changed (1) hide show
  1. README.md +772 -232
README.md CHANGED
@@ -71,38 +71,41 @@ pipeline_tag: text-generation
71
  <details open>
72
  <summary></b>📕 Table of Contents</b></summary>
73
 
74
- - [🟢 What is Yi?](#-what-is-yi)
75
- - [📌 Introduction](#-introduction)
76
- - [🎯 Models](#-models)
77
  - [Chat models](#chat-models)
78
  - [Base models](#base-models)
79
  - [Other info](#other-info)
80
- - [🎉 News](#-news)
81
- - [🟢 How to use Yi?](#-how-to-use-yi)
82
  - [Quick start](#quick-start)
83
- - [Choose your path](#choose-your-parth)
84
- - [Tutorial](#tutorial)
85
- - [Fine tune](#fine-tune)
 
 
 
 
86
  - [Quantization](#quantization)
87
- - [Deployment](https://github.com/01-ai/Yi/blob/main/docs/deployment.md)
88
- - [Learning hub](https://github.com/01-ai/Yi/blob/main/docs/learning_hub.md)
89
- - [🟢 Why Yi?](#-why-yi)
90
- - [🌎 Ecosystem](#-ecosystem)
91
- - [💦 Upstream](#-upstream)
92
- - [🌊 Downstream](#-downstream)
93
- - [🔗 Serving](#-serving)
94
- - [⚙️ Quantitation](#️-quantitation)
95
- - [🛠️ Fine-tuning](#️-fine-tuning)
96
  - [API](#api)
97
- - [📌 Benchmarks](#-benchmarks)
98
- - [📊 Base model performance](#-base-model-performance)
99
- - [📊 Chat model performance](#-chat-model-performance)
100
- - [📊 Quantized chat model performance](#-quantized-chat-model-performance)
101
- - [🟢 Who can use Yi?](#-who-can-use-yi)
102
- - [🟢 Misc.](#-misc)
103
- - [Ackknowledgements](#acknowledgments)
104
- - [📡 Disclaimer](#-disclaimer)
105
- - [🪪 License](#-license)
106
 
107
  </details>
108
 
@@ -115,71 +118,55 @@ pipeline_tag: text-generation
115
  - 🤖 The Yi series models are the next generation of open-source large language models trained from scratch by [01.AI](https://01.ai/).
116
 
117
  - 🙌 Targeted as a bilingual language model and trained on 3T multilingual corpus, the Yi series models become one of the strongest LLM worldwide, showing promise in language understanding, commonsense reasoning, reading comprehension, and more. For example,
118
-
119
- - For English language capability, the Yi series models ranked 2nd (just behind GPT-4), outperforming other LLMs (such as LLaMA2-chat-70B, Claude 2, and ChatGPT) on the [AlpacaEval Leaderboard](https://tatsu-lab.github.io/alpaca_eval/) in Dec 2023.
120
 
121
- - For Chinese language capability, the Yi series models landed in 2nd place (following GPT4), surpassing other LLMs (such as Baidu ERNIE, Qwen, and Baichuan) on the [SuperCLUE](https://www.superclueai.com/) in Oct 2023.
122
-
123
- - 🙏 (Credits to LLaMA) Thanks to the Transformer and LLaMA open-source communities, as they reducing the efforts required to build from scratch and enabling the utilization of the same tools within the AI ecosystem. If you're interested in Yi's adoption of LLaMA architecture and license usage policy, see [Yi's relation with LLaMA](https://github.com/01-ai/Yi/blob/main/docs/yi_relation_llama.md).
124
-
125
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
126
-
127
- ## 🎯 Models
128
-
129
- Yi models come in multiple sizes and cater to different use cases. You can also fine-tune Yi models to meet your specific requirements.
130
-
131
- For detailed deployment requirements, see [hardware requirements](https://github.com/01-ai/Yi/blob/main/docs/deployment.md#hardware-requirements).
132
-
133
- ### Chat models
134
-
135
- | Model | Download
136
- |---|---
137
- Yi-6B-Chat| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat/summary)
138
- Yi-6B-Chat-4bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat-4bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat-4bits/summary)
139
- Yi-6B-Chat-8bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat-8bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat-8bits/summary)
140
- Yi-34B-Chat | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat/summary)
141
- Yi-34B-Chat-4bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat-4bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat-4bits/summary)
142
- Yi-34B-Chat-8bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat-8bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat-8bits/summary)
143
 
144
- <sub><sup> - 4-bit series models are quantized by AWQ. <br> - 8-bit series models are quantized by GPTQ <br> - All quantized models have a low barrier to use since they can be deployed on consumer-grade GPUs (e.g., 3090, 4090). </sup></sub>
 
 
 
 
145
 
146
- ### Base models
147
 
148
- | Model | Download |
149
- |---|---|
150
- Yi-6B| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B/summary)
151
- Yi-6B-200K | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-200K) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-200K/summary)
152
- Yi-34B| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B/summary)
153
- Yi-34B-200K|• [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-200K) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-200K/summary)
154
 
155
- <sub><sup> - 200k is roughly equivalent to 400,000 Chinese characters. </sup></sub>
156
 
157
- ### Other info
158
 
159
- - For chat and base models:
160
 
161
- - 6B series models are suitable for personal and academic use.
 
 
162
 
163
- - 34B series models suitable for personal, academic, and commercial (particularly for small and medium-sized enterprises) purposes. It's a cost-effective solution that's affordable and equipped with emergent ability.
 
 
164
 
165
- - The **default context window** is **4k tokens**.
166
-
167
- - The pretrained tokens are 3T.
168
-
169
- - The training data are up to June 2023.
170
 
171
- - For chat models:
172
-
173
- - For detailed chat model limitations, see [limitations of chat model](https://github.com/01-ai/Yi/blob/main/docs/README_legacy.md#limitations-of-chat-model).
 
 
174
 
175
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
 
 
176
 
177
- ## 🎉 News
178
 
179
  <details>
180
- <summary>🎯 <b>2023/11/23</b>: The chat models are open to public.</summary>
181
-
182
- This release contains two chat models based on previously released base models, two 8-bit models quantized by GPTQ, and two 4-bit models quantized by AWQ.
183
 
184
  - `Yi-34B-Chat`
185
  - `Yi-34B-Chat-4bits`
@@ -195,47 +182,109 @@ You can try some of them interactively at:
195
  </details>
196
 
197
  <details>
198
- <summary>🔔 <b>2023/11/23</b>: The Yi Series Models Community License Agreement is updated to v2.1.</summary>
199
  </details>
200
 
201
  <details>
202
  <summary>🔥 <b>2023/11/08</b>: Invited test of Yi-34B chat model.</summary>
203
-
204
- Application form:
205
 
206
  - [English](https://cn.mikecrm.com/l91ODJf)
207
  - [Chinese](https://cn.mikecrm.com/gnEZjiQ)
208
-
209
  </details>
210
 
211
  <details>
212
- <summary>🎯 <b>2023/11/05</b>: The base model of <code>Yi-6B-200K</code> and <code>Yi-34B-200K</code>.</summary>
213
-
214
- This release contains two base models with the same parameter sizes as the previous
215
  release, except that the context window is extended to 200K.
216
-
217
  </details>
218
 
219
  <details>
220
- <summary>🎯 <b>2023/11/02</b>: The base model of <code>Yi-6B</code> and <code>Yi-34B</code>.</summary>
221
-
222
- The first public release contains two bilingual (English/Chinese) base models
223
  with the parameter sizes of 6B and 34B. Both of them are trained with 4K
224
  sequence length and can be extended to 32K during inference time.
225
 
226
  </details>
227
 
228
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
 
230
  # 🟢 How to use Yi?
231
 
232
  - [Quick start](#quick-start)
233
- - [Choose your path](#choose-your-parth)
234
- - [Tutorial](#tutorial)
235
- - [Fine tune](#fine-tune)
 
 
 
 
236
  - [Quantization](#quantization)
237
- - [Deployment](https://github.com/01-ai/Yi/blob/main/docs/deployment.md)
238
- - [Learning hub](https://github.com/01-ai/Yi/blob/main/docs/learning_hub.md)
239
 
240
  ## Quick start
241
 
@@ -245,18 +294,18 @@ Getting up and running with Yi models is simple with multiple choices available.
245
 
246
  Select one of the following paths to begin your journey with Yi!
247
 
248
- ![Quick start - Choose your path](./assets/img/quick_start_path.png)
249
 
250
  #### 🎯 Deploy Yi locally
251
 
252
  If you prefer to deploy Yi models locally,
253
 
254
  - 🙋‍♀️ and you have **sufficient** resources (for example, NVIDIA A800 80GB), you can choose one of the following methods:
255
- - [pip](#tutorial)
256
- - [Docker](https://github.com/01-ai/Yi/blob/main/docs/README_legacy.md#11-docker)
257
- - [conda-lock](https://github.com/01-ai/Yi/blob/main/docs/README_legacy.md#12-local-development-environment)
258
 
259
- - 🙋‍♀️ and you have **limited** resources (for example, a MacBook Pro), you can use [llama.cpp](https://github.com/01-ai/Yi/blob/main/docs/yi_llama.cpp.md).
260
 
261
  #### 🎯 Not to deploy Yi locally
262
 
@@ -290,18 +339,21 @@ If you want to chat with Yi with more customizable options (e.g., system prompt,
290
  - [Yi-34B-Chat](https://platform.lingyiwanwu.com/) (Yi official beta)
291
  - Access is available through a whitelist. Welcome to apply (fill out a form in [English](https://cn.mikecrm.com/l91ODJf) or [Chinese](https://cn.mikecrm.com/gnEZjiQ)).
292
 
293
- ## Tutorial
 
 
294
 
295
- This tutorial guides you through every step of running Yi (Yi-34B-Chat) locally and then performing inference.
296
 
297
- ### Step 0: Prerequistes
298
 
299
- - This tutorial assumes you are running the **Yi-34B-Chat** with an **A800 (80G)** GPU.
300
- - For detailed deployment requirements to run Yi models, see [hardware requirements]( https://github.com/01-ai/Yi/blob/main/docs/deployment.md).
301
 
302
- - Make sure Python 3.10 or later version is installed.
 
 
303
 
304
- ### Step 1: Prepare environment
305
 
306
  To set up the environment and install the required packages, execute the following command.
307
 
@@ -311,7 +363,7 @@ cd yi
311
  pip install -r requirements.txt
312
  ```
313
 
314
- ### Step 2: Download Yi model
315
 
316
  You can download the weights and tokenizer of Yi models from the following sources:
317
 
@@ -319,11 +371,11 @@ You can download the weights and tokenizer of Yi models from the following sourc
319
  - [ModelScope](https://www.modelscope.cn/organization/01ai/)
320
  - [WiseModel](https://wisemodel.cn/organization/01.AI)
321
 
322
- ### Step 3: Perform inference
323
 
324
  You can perform inference with Yi chat or base models as below.
325
 
326
- #### Perform inference with Yi chat model
327
 
328
  1. Create a file named `quick_start.py` and copy the following content to it.
329
 
@@ -366,31 +418,273 @@ You can perform inference with Yi chat or base models as below.
366
  Hello! How can I assist you today?
367
  ```
368
 
369
- #### Perform inference with Yi base model
370
 
371
- The steps are similar to [Run Yi chat model](#run-yi-chat-model).
372
 
373
- You can use the existing file [`text_generation.py`](https://github.com/01-ai/Yi/tree/main/demo).
374
 
375
- ```bash
376
- python demo/text_generation.py --model <your-model-path>
377
- ```
 
 
 
 
 
 
378
 
379
- Then you can see an output similar to the one below. 🥳
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  <details>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
382
 
383
- <summary>Output</summary>
384
 
 
 
385
  <br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
386
 
387
- **Prompt**: Let me tell you an interesting story about cat Tom and mouse Jerry,
388
 
389
- **Generation**: Let me tell you an interesting story about cat Tom and mouse Jerry, which happened in my childhood. My father had a big house with two cats living inside it to kill mice. One day when I was playing at home alone, I found one of the tomcats lying on his back near our kitchen door, looking very much like he wanted something from us but couldn’t get up because there were too many people around him! He kept trying for several minutes before finally giving up...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
390
 
 
 
 
 
 
 
391
  </details>
392
 
393
- ### Finetuning
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
394
 
395
  ```bash
396
  bash finetune/scripts/run_sft_Yi_6b.sh
@@ -401,8 +695,123 @@ Once finished, you can compare the finetuned model and the base model with the f
401
  ```bash
402
  bash finetune/scripts/run_eval.sh
403
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
 
405
- For advanced usage (like fine-tuning based on your custom data), see [fine-tune code for Yi 6B and 34B](https://github.com/01-ai/Yi/tree/main/finetune).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
 
407
  ### Quantization
408
 
@@ -422,7 +831,41 @@ python quantization/gptq/eval_quantized_model.py \
422
  --trust_remote_code
423
  ```
424
 
425
- For a more detailed explanation, please read the [doc](https://github.com/01-ai/Yi/tree/main/quantization/gptq)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
 
427
  #### AWQ
428
  ```bash
@@ -439,10 +882,135 @@ python quantization/awq/eval_quantized_model.py \
439
  --model /quantized_model \
440
  --trust_remote_code
441
  ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
 
443
- For detailed explanations, see [AWQ quantization](https://github.com/01-ai/Yi/tree/main/quantization/awq).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
444
 
445
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
446
 
447
  # 🟢 Why Yi?
448
 
@@ -454,9 +1022,8 @@ For detailed explanations, see [AWQ quantization](https://github.com/01-ai/Yi/tr
454
  - [🛠️ Fine-tuning](#️-fine-tuning)
455
  - [API](#api)
456
  - [📌 Benchmarks](#-benchmarks)
457
- - [📊 Base model performance](#-base-model-performance)
458
  - [📊 Chat model performance](#-chat-model-performance)
459
- - [📊 Quantized chat model performance](#-quantized-chat-model-performance)
460
 
461
  ## 🌎 Ecosystem
462
 
@@ -471,9 +1038,9 @@ Yi has a comprehensive ecosystem, offering a range of tools, services, and model
471
 
472
  ### 💦 Upstream
473
 
474
- The Yi series models follow the same model architecture as LLaMA. By choosing Yi, you can leverage existing tools, libraries, and resources within the LLaMA ecosystem, eliminating the need to create new tools and enhancing development efficiency.
475
 
476
- For example, the Yi series models are saved in the format of the LLaMA model. You can directly use `LLaMAForCausalLM` and `LLaMATokenizer` to load the model. For more information, see [Use the chat model](#31-use-the-chat-model).
477
 
478
  ```python
479
  from transformers import AutoModelForCausalLM, AutoTokenizer
@@ -483,6 +1050,10 @@ tokenizer = AutoTokenizer.from_pretrained("01-ai/Yi-34b", use_fast=False)
483
  model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-34b", device_map="auto")
484
  ```
485
 
 
 
 
 
486
  ### 🌊 Downstream
487
 
488
  > 💡 Tip
@@ -535,80 +1106,77 @@ If you're seeking to explore the diverse capabilities within Yi's thriving famil
535
  - [amazing-openai-api](https://github.com/soulteary/amazing-openai-api): this tool converts Yi model APIs into the OpenAI API format out of the box.
536
  - [LlamaEdge](https://www.secondstate.io/articles/yi-34b/#create-an-openai-compatible-api-service-for-the-yi-34b-chat-model): this tool builds an OpenAI-compatible API server for Yi-34B-Chat using a portable Wasm (WebAssembly) file, powered by Rust.
537
 
538
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
539
 
540
  ## 📌 Benchmarks
541
 
542
- - [📊 Base model performance](#-base-model-performance)
543
  - [📊 Chat model performance](#-chat-model-performance)
544
- - [📊 Quantized chat model performance](#-quantized-chat-model-performance)
545
 
546
- ### 📊 Base model performance
547
 
548
- | Model | MMLU | CMMLU | C-Eval | GAOKAO | BBH | Common-sense Reasoning | Reading Comprehension | Math & Code |
549
- | :------------ | :------: | :------: | :------: | :------: | :------: | :--------------------: | :-------------------: | :---------: |
550
- | | 5-shot | 5-shot | 5-shot | 0-shot | 3-shot@1 | - | - | - |
551
- | LLaMA2-34B | 62.6 | - | - | - | 44.1 | 69.9 | 68.0 | 26.0 |
552
- | LLaMA2-70B | 68.9 | 53.3 | - | 49.8 | 51.2 | 71.9 | 69.4 | 36.8 |
553
- | Baichuan2-13B | 59.2 | 62.0 | 58.1 | 54.3 | 48.8 | 64.3 | 62.4 | 23.0 |
554
- | Qwen-14B | 66.3 | 71.0 | 72.1 | 62.5 | 53.4 | 73.3 | 72.5 | **39.8** |
555
- | Skywork-13B | 62.1 | 61.8 | 60.6 | 68.1 | 41.7 | 72.4 | 61.4 | 24.9 |
556
- | InternLM-20B | 62.1 | 59.0 | 58.8 | 45.5 | 52.5 | 78.3 | - | 30.4 |
557
- | Aquila-34B | 67.8 | 71.4 | 63.1 | - | - | - | - | - |
558
- | Falcon-180B | 70.4 | 58.0 | 57.8 | 59.0 | 54.0 | 77.3 | 68.8 | 34.0 |
559
- | Yi-6B | 63.2 | 75.5 | 72.0 | 72.2 | 42.8 | 72.3 | 68.7 | 19.8 |
560
- | Yi-6B-200K | 64.0 | 75.3 | 73.5 | 73.9 | 42.0 | 72.0 | 69.1 | 19.0 |
561
- | **Yi-34B** | **76.3** | **83.7** | 81.4 | 82.8 | **54.3** | **80.1** | 76.4 | 37.1 |
562
- | Yi-34B-200K | 76.1 | 83.6 | **81.9** | **83.4** | 52.7 | 79.7 | **76.6** | 36.3 |
563
-
564
- While benchmarking open-source models, we have observed a disparity between the
565
- results generated by our pipeline and those reported in public sources (e.g.
566
- OpenCompass). Upon conducting a more in-depth investigation of this difference,
567
- we have discovered that various models may employ different prompts,
568
- post-processing strategies, and sampling techniques, potentially resulting in
569
- significant variations in the outcomes. Our prompt and post-processing strategy
570
- remains consistent with the original benchmark, and greedy decoding is employed
571
- during evaluation without any post-processing for the generated content. For
572
- scores that were not reported by the original authors (including scores reported
573
- with different settings), we try to get results with our pipeline.
574
-
575
- To evaluate the model's capability extensively, we adopted the methodology
576
- outlined in Llama2. Specifically, we included PIQA, SIQA, HellaSwag, WinoGrande,
577
- ARC, OBQA, and CSQA to assess common sense reasoning. SquAD, QuAC, and BoolQ
578
- were incorporated to evaluate reading comprehension. CSQA was exclusively tested
579
- using a 7-shot setup, while all other tests were conducted with a 0-shot
580
- configuration. Additionally, we introduced GSM8K (8-shot@1), MATH (4-shot@1),
581
- HumanEval (0-shot@1), and MBPP (3-shot@1) under the category "Math & Code". Due
582
- to technical constraints, we did not test Falcon-180 on QuAC and OBQA; the score
583
- is derived by averaging the scores on the remaining tasks. Since the scores for
584
- these two tasks are generally lower than the average, we believe that
585
- Falcon-180B's performance was not underestimated.
586
 
587
- ### 📊 Chat model performance
 
 
 
588
 
589
- | Model | MMLU | MMLU | CMMLU | CMMLU | C-Eval(val)<sup>*</sup> | C-Eval(val)<sup>*</sup> | Truthful QA | BBH | BBH | GSM8k | GSM8k |
590
- | ----------------------- | --------- | --------- | --------- | --------- | ----------------------- | ----------------------- | ----------- | --------- | --------- | --------- | --------- |
591
- | | 0-shot | 5-shot | 0-shot | 5-shot | 0-shot | 5-shot | 0-shot | 0-shot | 3-shot | 0-shot | 4-shot |
592
- | LLaMA2-13B-Chat | 50.88 | 47.33 | 27.47 | 35.08 | 27.93 | 35.88 | 36.84 | 32.90 | 58.22 | 36.85 | 2.73 |
593
- | LLaMA2-70B-Chat | 59.42 | 59.86 | 36.10 | 40.99 | 34.99 | 41.31 | 53.95 | 42.36 | 58.53 | 47.08 | 58.68 |
594
- | Baichuan2-13B-Chat | 55.09 | 50.14 | 58.64 | 59.47 | 56.02 | 54.75 | 48.98 | 38.81 | 47.15 | 45.72 | 23.28 |
595
- | Qwen-14B-Chat | 63.99 | 64.98 | 67.73 | 70.57 | 66.12 | 70.06 | 52.49 | 49.65 | 54.98 | 59.51 | 61.18 |
596
- | InternLM-Chat-20B | 55.55 | 57.42 | 53.55 | 53.75 | 51.19 | 53.57 | 51.75 | 42.41 | 36.68 | 15.69 | 43.44 |
597
- | AquilaChat2-34B v1.2 | 65.15 | 66.70 | 67.51 | 70.02 | **82.99** | **89.38** | **64.33** | 20.12 | 34.28 | 11.52 | 48.45 |
598
- | Yi-6B-Chat | 58.24 | 60.99 | 69.44 | 74.71 | 68.80 | 74.22 | 50.58 | 39.70 | 47.15 | 38.44 | 44.88 |
599
- | Yi-6B-Chat-8bits(GPTQ) | 58.29 | 60.96 | 69.21 | 74.69 | 69.17 | 73.85 | 49.85 | 40.35 | 47.26 | 39.42 | 44.88 |
600
- | Yi-6B-Chat-4bits(AWQ) | 56.78 | 59.89 | 67.70 | 73.29 | 67.53 | 72.29 | 50.29 | 37.74 | 43.62 | 35.71 | 38.36 |
601
- | Yi-34B-Chat | **67.62** | 73.46 | **79.11** | **81.34** | 77.04 | 78.53 | 62.43 | 51.41 | **71.74** | **71.65** | **75.97** |
602
- | Yi-34B-Chat-8bits(GPTQ) | 66.24 | **73.69** | 79.05 | 81.23 | 76.82 | 78.97 | 61.84 | **52.08** | 70.97 | 70.74 | 75.74 |
603
- | Yi-34B-Chat-4bits(AWQ) | 65.77 | 72.42 | 78.21 | 80.50 | 75.71 | 77.27 | 61.84 | 48.30 | 69.39 | 70.51 | 74.00 |
604
-
605
- We evaluated various benchmarks using both zero-shot and few-shot methods, except for TruthfulQA. Generally, the zero-shot approach is more common in chat models. Our evaluation strategy involves generating responses while following instructions explicitly or implicitly (such as using few-shot examples). We then isolate relevant answers from the generated text. Some models are not well-suited to produce output in the specific format required by instructions in a few datasets, which leads to suboptimal results.
606
 
607
  <strong>*</strong>: C-Eval results are evaluated on the validation datasets
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
 
609
- ### 📊 Quantized chat model performance
610
 
611
- We also provide both 4-bit (AWQ) and 8-bit (GPTQ) quantized Yi chat models. Evaluation results on various benchmarks have shown that the quantized models have **negligible** losses. Additionally, they reduce the memory footprint size.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
612
 
613
  # 🟢 Who can use Yi?
614
 
@@ -618,7 +1186,9 @@ Everyone! 🙌 ✅
618
 
619
  - For free commercial use, you only need to [complete this form](https://www.lingyiwanwu.com/yi-license) to get a Yi Model Commercial License.
620
 
621
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
622
 
623
  # 🟢 Misc.
624
 
@@ -626,43 +1196,11 @@ Everyone! 🙌 ✅
626
 
627
  A heartfelt thank you to each of you who have made contributions to the Yi community! You have helped Yi not just a project, but a vibrant, growing home for innovation.
628
 
629
- <!---
630
- ref https://github.com/ngryman/contributor-faces
631
- npx contributor-faces --exclude "*bot*" --limit 70 --repo "https://github.com/01-ai/Yi"
632
-
633
- change the height and width for each of the contributors from 80 to 50 at ref index.js.
634
- --->
635
-
636
- [//]: contributor-faces
637
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/ZhaoFancy"><img style="margin:0" src="https://avatars.githubusercontent.com/u/139539780?v=4" title="ZhaoFancy" width="50" height="50"></a>
638
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/Anonymitaet"><img style="margin:0" src="https://avatars.githubusercontent.com/u/50226895?v=4" title="Anonymitaet" width="50" height="50"></a>
639
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/findmyway"><img style="margin:0" src="https://avatars.githubusercontent.com/u/5612003?v=4" title="findmyway" width="50" height="50"></a>
640
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/shiyue-loop"><img style="margin:0" src="https://avatars.githubusercontent.com/u/150643331?v=4" title="shiyue-loop" width="50" height="50"></a>
641
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/richardllin"><img style="margin:0" src="https://avatars.githubusercontent.com/u/1932744?v=4" title="richardllin" width="50" height="50"></a>
642
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/jiangchengSilent"><img style="margin:0" src="https://avatars.githubusercontent.com/u/143983063?v=4" title="jiangchengSilent" width="50" height="50"></a>
643
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/loofahcus"><img style="margin:0" src="https://avatars.githubusercontent.com/u/15729967?v=4" title="loofahcus" width="50" height="50"></a>
644
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/Yimi81"><img style="margin:0" src="https://avatars.githubusercontent.com/u/66633207?v=4" title="Yimi81" width="50" height="50"></a>
645
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/ly-nld"><img style="margin:0" src="https://avatars.githubusercontent.com/u/38471793?v=4" title="ly-nld" width="50" height="50"></a>
646
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/WayTooWill"><img style="margin:0" src="https://avatars.githubusercontent.com/u/119883899?v=4" title="WayTooWill" width="50" height="50"></a>
647
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/kai01ai"><img style="margin:0" src="https://avatars.githubusercontent.com/u/140378742?v=4" title="kai01ai" width="50" height="50"></a>
648
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/forpanyang"><img style="margin:0" src="https://avatars.githubusercontent.com/u/138085590?v=4" title="forpanyang" width="50" height="50"></a>
649
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/0x1111"><img style="margin:0" src="https://avatars.githubusercontent.com/u/750392?v=4" title="0x1111" width="50" height="50"></a>
650
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/angeligareta"><img style="margin:0" src="https://avatars.githubusercontent.com/u/32129522?v=4" title="angeligareta" width="50" height="50"></a>
651
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/xffxff"><img style="margin:0" src="https://avatars.githubusercontent.com/u/30254428?v=4" title="xffxff" width="50" height="50"></a>
652
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/tpoisonooo"><img style="margin:0" src="https://avatars.githubusercontent.com/u/7872421?v=4" title="tpoisonooo" width="50" height="50"></a>
653
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/tdolan21"><img style="margin:0" src="https://avatars.githubusercontent.com/u/40906019?v=4" title="tdolan21" width="50" height="50"></a>
654
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/statelesshz"><img style="margin:0" src="https://avatars.githubusercontent.com/u/28150734?v=4" title="statelesshz" width="50" height="50"></a>
655
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/renxiaoyi"><img style="margin:0" src="https://avatars.githubusercontent.com/u/10918916?v=4" title="renxiaoyi" width="50" height="50"></a>
656
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/markli404"><img style="margin:0" src="https://avatars.githubusercontent.com/u/116385770?v=4" title="markli404" width="50" height="50"></a>
657
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/fecet"><img style="margin:0" src="https://avatars.githubusercontent.com/u/41792945?v=4" title="fecet" width="50" height="50"></a>
658
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/cArlIcon"><img style="margin:0" src="https://avatars.githubusercontent.com/u/7384654?v=4" title="cArlIcon" width="50" height="50"></a>
659
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/alabulei1"><img style="margin:0" src="https://avatars.githubusercontent.com/u/45785633?v=4" title="alabulei1" width="50" height="50"></a>
660
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/eltociear"><img style="margin:0" src="https://avatars.githubusercontent.com/u/22633385?v=4" title="eltociear" width="50" height="50"></a>
661
- <a style="display:inline-block;width=50px;height=50px" href="https://github.com/Gmgge"><img style="margin:0" src="https://avatars.githubusercontent.com/u/48548141?v=4" title="Gmgge" width="50" height="50"></a>
662
-
663
- [//]: contributor-faces
664
-
665
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
666
 
667
  ### 📡 Disclaimer
668
 
@@ -675,14 +1213,16 @@ problematic outputs. We will not be responsible for any risks and issues
675
  resulting from misuse, misguidance, illegal usage, and related misinformation,
676
  as well as any associated data security concerns.
677
 
678
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
679
 
680
  ### 🪪 License
681
 
682
  The source code in this repo is licensed under the [Apache 2.0
683
- license](https://github.com/01-ai/Yi/blob/main/LICENSE). The Yi series models
684
- are fully open for academic research and free commercial usage with permission
685
- via applications. All usage must adhere to the [Yi Series Models Community License Agreement 2.1](https://github.com/01-ai/Yi/blob/main/MODEL_LICENSE_AGREEMENT.txt).
686
  For free commercial use, you only need to send an email to [get official commercial permission](https://www.lingyiwanwu.com/yi-license).
687
 
688
- <div align="right"> [ <a href="#building-the-next-generation-of-open-source-and-bilingual-llms">Back to top ⬆️ </a> ] </div>
 
 
 
71
  <details open>
72
  <summary></b>📕 Table of Contents</b></summary>
73
 
74
+ - [What is Yi?](#-what-is-yi)
75
+ - [Introduction](#-introduction)
76
+ - [Models](#-models)
77
  - [Chat models](#chat-models)
78
  - [Base models](#base-models)
79
  - [Other info](#other-info)
80
+ - [News](#-news)
81
+ - [How to use Yi?](#-how-to-use-yi)
82
  - [Quick start](#quick-start)
83
+ - [Choose your path](#choose-your-path)
84
+ - [pip](#quick-start---pip)
85
+ - [docker](#quick-start---docker)
86
+ - [llama.cpp](#quick-start---llamacpp)
87
+ - [conda-lock](#quick-start---conda-lock)
88
+ - [Web demo](#web-demo)
89
+ - [Fine-tuning](#fine-tuning)
90
  - [Quantization](#quantization)
91
+ - [Deployment](#deployment)
92
+ - [Learning hub](#learning-hub)
93
+ - [Why Yi?](#-why-yi)
94
+ - [Ecosystem](#-ecosystem)
95
+ - [Upstream](#-upstream)
96
+ - [Downstream](#-downstream)
97
+ - [Serving](#-serving)
98
+ - [Quantitation](#️-quantitation)
99
+ - [Fine-tuning](#️-fine-tuning)
100
  - [API](#api)
101
+ - [Benchmarks](#-benchmarks)
102
+ - [Base model performance](#-base-model-performance)
103
+ - [Chat model performance](#-chat-model-performance)
104
+ - [Who can use Yi?](#-who-can-use-yi)
105
+ - [Misc.](#-misc)
106
+ - [Acknowledgements](#acknowledgments)
107
+ - [Disclaimer](#-disclaimer)
108
+ - [License](#-license)
 
109
 
110
  </details>
111
 
 
118
  - 🤖 The Yi series models are the next generation of open-source large language models trained from scratch by [01.AI](https://01.ai/).
119
 
120
  - 🙌 Targeted as a bilingual language model and trained on 3T multilingual corpus, the Yi series models become one of the strongest LLM worldwide, showing promise in language understanding, commonsense reasoning, reading comprehension, and more. For example,
 
 
121
 
122
+ - Yi-34B-Chat model **landed in second place (following GPT-4 Turbo)**, outperforming other LLMs (such as GPT-4, Mixtral, Claude) on the AlpacaEval Leaderboard (based on data available up to January 2024).
123
+
124
+ - Yi-34B model **ranked first among all existing open-source models** (such as Falcon-180B, Llama-70B, Claude) in **both English and Chinese** on various benchmarks, including Hugging Face Open LLM Leaderboard (pre-trained) and C-Eval (based on data available up to November 2023).
125
+
126
+ - 🙏 (Credits to Llama) Thanks to the Transformer and Llama open-source communities, as they reduce the efforts required to build from scratch and enable the utilization of the same tools within the AI ecosystem.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
+ <details style="display: inline;"><summary> If you're interested in Yi's adoption of Llama architecture and license usage policy, see <span style="color: green;">Yi's relation with Llama.</span> ⬇️</summary> <ul> <br>
129
+
130
+ > 💡 TL;DR
131
+ >
132
+ > The Yi series models adopt the same model architecture as Llama but are **NOT** derivatives of Llama.
133
 
134
+ - Both Yi and Llama are all based on the Transformer structure, which has been the standard architecture for large language models since 2018.
135
 
136
+ - Grounded in the Transformer architecture, Llama has become a new cornerstone for the majority of state-of-the-art open-source models due to its excellent stability, reliable convergence, and robust compatibility. This positions Llama as the recognized foundational framework for models including Yi.
 
 
 
 
 
137
 
138
+ - Thanks to the Transformer and Llama architectures, other models can leverage their power, reducing the effort required to build from scratch and enabling the utilization of the same tools within their ecosystems.
139
 
140
+ - However, the Yi series models are NOT derivatives of Llama, as they do not use Llama's weights.
141
 
142
+ - As Llama's structure is employed by the majority of open-source models, the key factors of determining model performance are training datasets, training pipelines, and training infrastructure.
143
 
144
+ - Developing in a unique and proprietary way, Yi has independently created its own high-quality training datasets, efficient training pipelines, and robust training infrastructure entirely from the ground up. This effort has led to excellent performance with Yi series models ranking just behind GPT4 and surpassing Llama on the [Alpaca Leaderboard in Dec 2023](https://tatsu-lab.github.io/alpaca_eval/).
145
+ </ul>
146
+ </details>
147
 
148
+ <p align="right"> [
149
+ <a href="#top">Back to top ⬆️ </a> ]
150
+ </p>
151
 
152
+ ## 🎉 News
 
 
 
 
153
 
154
+ <details open>
155
+ <summary>🎯 <b>2024/03/06</b>: The Yi-9B is open-sourced and available to the public.</summary>
156
+ <br>
157
+ Yi-9B stands out as the top performer among a range of similar-sized open-source models (including Mistral-7B, SOLAR-10.7B, Gemma-7B, DeepSeek-Coder-7B-Base-v1.5 and more), particularly excelling in code, math, common-sense reasoning, and reading comprehension.
158
+ </details>
159
 
160
+ <details open>
161
+ <summary>🎯 <b>2024/01/23</b>: The Yi-VL models, <code><a href="https://huggingface.co/01-ai/Yi-VL-34B">Yi-VL-34B</a></code> and <code><a href="https://huggingface.co/01-ai/Yi-VL-6B">Yi-VL-6B</a></code>, are open-sourced and available to the public.</summary>
162
+ <br>
163
+ <code><a href="https://huggingface.co/01-ai/Yi-VL-34B">Yi-VL-34B</a></code> has ranked <strong>first</strong> among all existing open-source models in the latest benchmarks, including <a href="https://arxiv.org/abs/2311.16502">MMMU</a> and <a href="https://arxiv.org/abs/2401.11944">CMMMU</a> (based on data available up to January 2024).</li>
164
+ </details>
165
 
 
166
 
167
  <details>
168
+ <summary>🎯 <b>2023/11/23</b>: <a href="#chat-models">Chat models</a> are open-sourced and available to the public.</summary>
169
+ <br>This release contains two chat models based on previously released base models, two 8-bit models quantized by GPTQ, and two 4-bit models quantized by AWQ.
 
170
 
171
  - `Yi-34B-Chat`
172
  - `Yi-34B-Chat-4bits`
 
182
  </details>
183
 
184
  <details>
185
+ <summary>🔔 <b>2023/11/23</b>: The Yi Series Models Community License Agreement is updated to <a href="https://github.com/01-ai/Yi/blob/main/MODEL_LICENSE_AGREEMENT.txt">v2.1</a>.</summary>
186
  </details>
187
 
188
  <details>
189
  <summary>🔥 <b>2023/11/08</b>: Invited test of Yi-34B chat model.</summary>
190
+ <br>Application form:
 
191
 
192
  - [English](https://cn.mikecrm.com/l91ODJf)
193
  - [Chinese](https://cn.mikecrm.com/gnEZjiQ)
 
194
  </details>
195
 
196
  <details>
197
+ <summary>🎯 <b>2023/11/05</b>: <a href="#base-models">The base models, </a><code>Yi-6B-200K</code> and <code>Yi-34B-200K</code>, are open-sourced and available to the public.</summary>
198
+ <br>This release contains two base models with the same parameter sizes as the previous
 
199
  release, except that the context window is extended to 200K.
 
200
  </details>
201
 
202
  <details>
203
+ <summary>🎯 <b>2023/11/02</b>: <a href="#base-models">The base models, </a><code>Yi-6B</code> and <code>Yi-34B</code>, are open-sourced and available to the public.</summary>
204
+ <br>The first public release contains two bilingual (English/Chinese) base models
 
205
  with the parameter sizes of 6B and 34B. Both of them are trained with 4K
206
  sequence length and can be extended to 32K during inference time.
207
 
208
  </details>
209
 
210
+ <p align="right"> [
211
+ <a href="#top">Back to top ⬆️ </a> ]
212
+ </p>
213
+
214
+ ## 🎯 Models
215
+
216
+ Yi models come in multiple sizes and cater to different use cases. You can also fine-tune Yi models to meet your specific requirements.
217
+
218
+ If you want to deploy Yi models, make sure you meet the [software and hardware requirements](#deployment).
219
+
220
+ ### Chat models
221
+
222
+ | Model | Download
223
+ |---|---
224
+ Yi-34B-Chat | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat/summary)
225
+ Yi-34B-Chat-4bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat-4bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat-4bits/summary)
226
+ Yi-34B-Chat-8bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-Chat-8bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-Chat-8bits/summary)
227
+ Yi-6B-Chat| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat/summary)
228
+ Yi-6B-Chat-4bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat-4bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat-4bits/summary)
229
+ Yi-6B-Chat-8bits | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-Chat-8bits) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-Chat-8bits/summary)
230
+
231
+
232
+ <sub><sup> - 4-bit series models are quantized by AWQ. <br> - 8-bit series models are quantized by GPTQ <br> - All quantized models have a low barrier to use since they can be deployed on consumer-grade GPUs (e.g., 3090, 4090). </sup></sub>
233
+
234
+ ### Base models
235
+
236
+ | Model | Download |
237
+ |---|---|
238
+ Yi-34B| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B/summary)
239
+ Yi-34B-200K|• [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-34B-200K) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-34B-200K/summary)
240
+ Yi-9B|• [🤗 Hugging Face](TBD)
241
+ Yi-6B| • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B/summary)
242
+ Yi-6B-200K | • [🤗 Hugging Face](https://huggingface.co/01-ai/Yi-6B-200K) • [🤖 ModelScope](https://www.modelscope.cn/models/01ai/Yi-6B-200K/summary)
243
+
244
+ <sub><sup> - 200k is roughly equivalent to 400,000 Chinese characters. </sup></sub>
245
+
246
+ ### Model info
247
+
248
+ - For chat and base models
249
+
250
+ Model | Intro | Default context window | Pretrained tokens | Training Data Date
251
+ |---|---|---|---|---
252
+ 6B series models |They are suitable for personal and academic use. | 4K | 3T | Up to June 2023
253
+ 9B model| It is the best at coding and math in the Yi series models.|4K | Yi-9B is continuously trained based on Yi-6B, using 0.8T tokens. | Up to June 2023
254
+ 34B series models | They are suitable for personal, academic, and commercial (particularly for small and medium-sized enterprises) purposes. It's a cost-effective solution that's affordable and equipped with emergent ability.|4K | 3T | Up to June 2023
255
+
256
+ - For chat models
257
+
258
+ <details style="display: inline;"><summary>For chat model limitations, see the explanations below. ⬇️</summary>
259
+ <ul>
260
+ <br>The released chat model has undergone exclusive training using Supervised Fine-Tuning (SFT). Compared to other standard chat models, our model produces more diverse responses, making it suitable for various downstream tasks, such as creative scenarios. Furthermore, this diversity is expected to enhance the likelihood of generating higher quality responses, which will be advantageous for subsequent Reinforcement Learning (RL) training.
261
+
262
+ <br>However, this higher diversity might amplify certain existing issues, including:
263
+ <li>Hallucination: This refers to the model generating factually incorrect or nonsensical information. With the model's responses being more varied, there's a higher chance of hallucination that are not based on accurate data or logical reasoning.</li>
264
+ <li>Non-determinism in re-generation: When attempting to regenerate or sample responses, inconsistencies in the outcomes may occur. The increased diversity can lead to varying results even under similar input conditions.</li>
265
+ <li>Cumulative Error: This occurs when errors in the model's responses compound over time. As the model generates more diverse responses, the likelihood of small inaccuracies building up into larger errors increases, especially in complex tasks like extended reasoning, mathematical problem-solving, etc.</li>
266
+ <li>To achieve more coherent and consistent responses, it is advisable to adjust generation configuration parameters such as temperature, top_p, or top_k. These adjustments can help in the balance between creativity and coherence in the model's outputs.</li>
267
+ </ul>
268
+ </details>
269
+
270
+ <p align="right"> [
271
+ <a href="#top">Back to top ⬆️ </a> ]
272
+ </p>
273
+
274
 
275
  # 🟢 How to use Yi?
276
 
277
  - [Quick start](#quick-start)
278
+ - [Choose your path](#choose-your-path)
279
+ - [pip](#quick-start---pip)
280
+ - [docker](#quick-start---docker)
281
+ - [conda-lock](#quick-start---conda-lock)
282
+ - [llama.cpp](#quick-start---llamacpp)
283
+ - [Web demo](#web-demo)
284
+ - [Fine-tuning](#finetuning)
285
  - [Quantization](#quantization)
286
+ - [Deployment](#deployment)
287
+ - [Learning hub](#learning-hub)
288
 
289
  ## Quick start
290
 
 
294
 
295
  Select one of the following paths to begin your journey with Yi!
296
 
297
+ ![Quick start - Choose your path](https://github.com/01-ai/Yi/blob/main/assets/img/quick_start_path.png?raw=true)
298
 
299
  #### 🎯 Deploy Yi locally
300
 
301
  If you prefer to deploy Yi models locally,
302
 
303
  - 🙋‍♀️ and you have **sufficient** resources (for example, NVIDIA A800 80GB), you can choose one of the following methods:
304
+ - [pip](#pip)
305
+ - [Docker](#quick-start---docker)
306
+ - [conda-lock](#quick-start---conda-lock)
307
 
308
+ - 🙋‍♀️ and you have **limited** resources (for example, a MacBook Pro), you can use [llama.cpp](#quick-start---llamacpp).
309
 
310
  #### 🎯 Not to deploy Yi locally
311
 
 
339
  - [Yi-34B-Chat](https://platform.lingyiwanwu.com/) (Yi official beta)
340
  - Access is available through a whitelist. Welcome to apply (fill out a form in [English](https://cn.mikecrm.com/l91ODJf) or [Chinese](https://cn.mikecrm.com/gnEZjiQ)).
341
 
342
+ <p align="right"> [
343
+ <a href="#top">Back to top ⬆️ </a> ]
344
+ </p>
345
 
346
+ ### Quick start - pip
347
 
348
+ This tutorial guides you through every step of running **Yi-34B-Chat locally on an A800 (80G)** and then performing inference.
349
 
350
+ #### Step 0: Prerequisites
 
351
 
352
+ - Make sure Python 3.10 or a later version is installed.
353
+
354
+ - If you want to run other Yi models, see [software and hardware requirements](#deployment).
355
 
356
+ #### Step 1: Prepare your environment
357
 
358
  To set up the environment and install the required packages, execute the following command.
359
 
 
363
  pip install -r requirements.txt
364
  ```
365
 
366
+ #### Step 2: Download the Yi model
367
 
368
  You can download the weights and tokenizer of Yi models from the following sources:
369
 
 
371
  - [ModelScope](https://www.modelscope.cn/organization/01ai/)
372
  - [WiseModel](https://wisemodel.cn/organization/01.AI)
373
 
374
+ #### Step 3: Perform inference
375
 
376
  You can perform inference with Yi chat or base models as below.
377
 
378
+ ##### Perform inference with Yi chat model
379
 
380
  1. Create a file named `quick_start.py` and copy the following content to it.
381
 
 
418
  Hello! How can I assist you today?
419
  ```
420
 
421
+ ##### Perform inference with Yi base model
422
 
423
+ - Yi-34B
424
 
425
+ The steps are similar to [pip - Perform inference with Yi chat model](#perform-inference-with-yi-chat-model).
426
 
427
+ You can use the existing file [`text_generation.py`](https://github.com/01-ai/Yi/tree/main/demo).
428
+
429
+ ```bash
430
+ python demo/text_generation.py --model <your-model-path>
431
+ ```
432
+
433
+ Then you can see an output similar to the one below. 🥳
434
+
435
+ <details>
436
 
437
+ <summary>Output. ⬇️ </summary>
438
 
439
+ <br>
440
+
441
+ **Prompt**: Let me tell you an interesting story about cat Tom and mouse Jerry,
442
+
443
+ **Generation**: Let me tell you an interesting story about cat Tom and mouse Jerry, which happened in my childhood. My father had a big house with two cats living inside it to kill mice. One day when I was playing at home alone, I found one of the tomcats lying on his back near our kitchen door, looking very much like he wanted something from us but couldn’t get up because there were too many people around him! He kept trying for several minutes before finally giving up...
444
+
445
+ </details>
446
+
447
+ - Yi-9B
448
+
449
+ Input
450
+
451
+ ```bash
452
+ from transformers import AutoModelForCausalLM, AutoTokenizer
453
+
454
+ MODEL_DIR = "01-ai/Yi-9B"
455
+ model = AutoModelForCausalLM.from_pretrained(MODEL_DIR, torch_dtype="auto")
456
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_DIR, use_fast=False)
457
+
458
+ input_text = "# write the quick sort algorithm"
459
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
460
+ outputs = model.generate(**inputs, max_length=256)
461
+ print(tokenizer.decode(outputs[0], skip_special_tokens=True))
462
+ ```
463
+
464
+ Output
465
+
466
+ ```bash
467
+ # write the quick sort algorithm
468
+ def quick_sort(arr):
469
+ if len(arr) <= 1:
470
+ return arr
471
+ pivot = arr[len(arr) // 2]
472
+ left = [x for x in arr if x < pivot]
473
+ middle = [x for x in arr if x == pivot]
474
+ right = [x for x in arr if x > pivot]
475
+ return quick_sort(left) + middle + quick_sort(right)
476
+
477
+ # test the quick sort algorithm
478
+ print(quick_sort([3, 6, 8, 10, 1, 2, 1]))
479
+ ```
480
+
481
+ <p align="right"> [
482
+ <a href="#top">Back to top ⬆️ </a> ]
483
+ </p>
484
+
485
+ ### Quick start - Docker
486
  <details>
487
+ <summary> Run Yi-34B-chat locally with Docker: a step-by-step guide. ⬇️</summary>
488
+ <br>This tutorial guides you through every step of running <strong>Yi-34B-Chat on an A800 GPU</strong> or <strong>4*4090</strong> locally and then performing inference.
489
+ <h4>Step 0: Prerequisites</h4>
490
+ <p>Make sure you've installed <a href="https://docs.docker.com/engine/install/?open_in_browser=true">Docker</a> and <a href="https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html">nvidia-container-toolkit</a>.</p>
491
+
492
+ <h4> Step 1: Start Docker </h4>
493
+ <pre><code>docker run -it --gpus all \
494
+ -v &lt;your-model-path&gt;: /models
495
+ ghcr.io/01-ai/yi:latest
496
+ </code></pre>
497
+ <p>Alternatively, you can pull the Yi Docker image from <code>registry.lingyiwanwu.com/ci/01-ai/yi:latest</code>.</p>
498
+
499
+ <h4>Step 2: Perform inference</h4>
500
+ <p>You can perform inference with Yi chat or base models as below.</p>
501
+
502
+ <h5>Perform inference with Yi chat model</h5>
503
+ <p>The steps are similar to <a href="#perform-inference-with-yi-chat-model">pip - Perform inference with Yi chat model</a>.</p>
504
+ <p><strong>Note</strong> that the only difference is to set <code>model_path = '&lt;your-model-mount-path&gt;'</code> instead of <code>model_path = '&lt;your-model-path&gt;'</code>.</p>
505
+ <h5>Perform inference with Yi base model</h5>
506
+ <p>The steps are similar to <a href="#perform-inference-with-yi-base-model">pip - Perform inference with Yi base model</a>.</p>
507
+ <p><strong>Note</strong> that the only difference is to set <code>--model &lt;your-model-mount-path&gt;'</code> instead of <code>model &lt;your-model-path&gt;</code>.</p>
508
+ </details>
509
 
510
+ ### Quick start - conda-lock
511
 
512
+ <details>
513
+ <summary>You can use <code><a href="https://github.com/conda/conda-lock">conda-lock</a></code> to generate fully reproducible lock files for conda environments. ⬇️</summary>
514
  <br>
515
+ You can refer to <a href="https://github.com/01-ai/Yi/blob/ebba23451d780f35e74a780987ad377553134f68/conda-lock.yml">conda-lock.yml</a> for the exact versions of the dependencies. Additionally, you can utilize <code><a href="https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html">micromamba</a></code> for installing these dependencies.
516
+ <br>
517
+ To install the dependencies, follow these steps:
518
+
519
+ 1. Install micromamba by following the instructions available <a href="https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html">here</a>.
520
+
521
+ 2. Execute <code>micromamba install -y -n yi -f conda-lock.yml</code> to create a conda environment named <code>yi</code> and install the necessary dependencies.
522
+ </details>
523
+
524
+
525
+ ### Quick start - llama.cpp
526
+ <details>
527
+ <summary> Run Yi-chat-6B-2bits locally with llama.cpp: a step-by-step guide. ⬇️</summary>
528
+ <br>This tutorial guides you through every step of running a quantized model (<a href="https://huggingface.co/XeIaso/yi-chat-6B-GGUF/tree/main">Yi-chat-6B-2bits</a>) locally and then performing inference.</p>
529
+
530
+ - [Step 0: Prerequisites](#step-0-prerequisites)
531
+ - [Step 1: Download llama.cpp](#step-1-download-llamacpp)
532
+ - [Step 2: Download Yi model](#step-2-download-yi-model)
533
+ - [Step 3: Perform inference](#step-3-perform-inference)
534
+
535
+ #### Step 0: Prerequisites
536
+
537
+ - This tutorial assumes you use a MacBook Pro with 16GB of memory and an Apple M2 Pro chip.
538
+
539
+ - Make sure [`git-lfs`](https://git-lfs.com/) is installed on your machine.
540
+
541
+ #### Step 1: Download `llama.cpp`
542
+
543
+ To clone the [`llama.cpp`](https://github.com/ggerganov/llama.cpp) repository, run the following command.
544
+
545
+ ```bash
546
+ git clone [email protected]:ggerganov/llama.cpp.git
547
+ ```
548
+
549
+ #### Step 2: Download Yi model
550
+
551
+ 2.1 To clone [XeIaso/yi-chat-6B-GGUF](https://huggingface.co/XeIaso/yi-chat-6B-GGUF/tree/main) with just pointers, run the following command.
552
+
553
+ ```bash
554
+ GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/XeIaso/yi-chat-6B-GGUF
555
+ ```
556
+
557
+ 2.2 To download a quantized Yi model ([yi-chat-6b.Q2_K.gguf](https://huggingface.co/XeIaso/yi-chat-6B-GGUF/blob/main/yi-chat-6b.Q2_K.gguf)), run the following command.
558
+
559
+ ```bash
560
+ git-lfs pull --include yi-chat-6b.Q2_K.gguf
561
+ ```
562
+
563
+ #### Step 3: Perform inference
564
+
565
+ To perform inference with the Yi model, you can use one of the following methods.
566
+
567
+ - [Method 1: Perform inference in terminal](#method-1-perform-inference-in-terminal)
568
+
569
+ - [Method 2: Perform inference in web](#method-2-perform-inference-in-web)
570
+
571
+ ##### Method 1: Perform inference in terminal
572
+
573
+ To compile `llama.cpp` using 4 threads and then conduct inference, navigate to the `llama.cpp` directory, and run the following command.
574
+
575
+ > ##### Tips
576
+ >
577
+ > - Replace `/Users/yu/yi-chat-6B-GGUF/yi-chat-6b.Q2_K.gguf` with the actual path of your model.
578
+ >
579
+ > - By default, the model operates in completion mode.
580
+ >
581
+ > - For additional output customization options (for example, system prompt, temperature, repetition penalty, etc.), run `./main -h` to check detailed descriptions and usage.
582
+
583
+ ```bash
584
+ make -j4 && ./main -m /Users/yu/yi-chat-6B-GGUF/yi-chat-6b.Q2_K.gguf -p "How do you feed your pet fox? Please answer this question in 6 simple steps:\nStep 1:" -n 384 -e
585
+
586
+ ...
587
+
588
+ How do you feed your pet fox? Please answer this question in 6 simple steps:
589
+
590
+ Step 1: Select the appropriate food for your pet fox. You should choose high-quality, balanced prey items that are suitable for their unique dietary needs. These could include live or frozen mice, rats, pigeons, or other small mammals, as well as fresh fruits and vegetables.
591
+
592
+ Step 2: Feed your pet fox once or twice a day, depending on the species and its individual preferences. Always ensure that they have access to fresh water throughout the day.
593
+
594
+ Step 3: Provide an appropriate environment for your pet fox. Ensure it has a comfortable place to rest, plenty of space to move around, and opportunities to play and exercise.
595
+
596
+ Step 4: Socialize your pet with other animals if possible. Interactions with other creatures can help them develop social skills and prevent boredom or stress.
597
+
598
+ Step 5: Regularly check for signs of illness or discomfort in your fox. Be prepared to provide veterinary care as needed, especially for common issues such as parasites, dental health problems, or infections.
599
+
600
+ Step 6: Educate yourself about the needs of your pet fox and be aware of any potential risks or concerns that could affect their well-being. Regularly consult with a veterinarian to ensure you are providing the best care.
601
+
602
+ ...
603
+
604
+ ```
605
+
606
+ Now you have successfully asked a question to the Yi model and got an answer! 🥳
607
+
608
+ ##### Method 2: Perform inference in web
609
+
610
+ 1. To initialize a lightweight and swift chatbot, run the following command.
611
+
612
+ ```bash
613
+ cd llama.cpp
614
+ ./server --ctx-size 2048 --host 0.0.0.0 --n-gpu-layers 64 --model /Users/yu/yi-chat-6B-GGUF/yi-chat-6b.Q2_K.gguf
615
+ ```
616
+
617
+ Then you can get an output like this:
618
 
 
619
 
620
+ ```bash
621
+ ...
622
+
623
+ llama_new_context_with_model: n_ctx = 2048
624
+ llama_new_context_with_model: freq_base = 5000000.0
625
+ llama_new_context_with_model: freq_scale = 1
626
+ ggml_metal_init: allocating
627
+ ggml_metal_init: found device: Apple M2 Pro
628
+ ggml_metal_init: picking default device: Apple M2 Pro
629
+ ggml_metal_init: ggml.metallib not found, loading from source
630
+ ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
631
+ ggml_metal_init: loading '/Users/yu/llama.cpp/ggml-metal.metal'
632
+ ggml_metal_init: GPU name: Apple M2 Pro
633
+ ggml_metal_init: GPU family: MTLGPUFamilyApple8 (1008)
634
+ ggml_metal_init: hasUnifiedMemory = true
635
+ ggml_metal_init: recommendedMaxWorkingSetSize = 11453.25 MB
636
+ ggml_metal_init: maxTransferRate = built-in GPU
637
+ ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size = 128.00 MiB, ( 2629.44 / 10922.67)
638
+ llama_new_context_with_model: KV self size = 128.00 MiB, K (f16): 64.00 MiB, V (f16): 64.00 MiB
639
+ ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size = 0.02 MiB, ( 2629.45 / 10922.67)
640
+ llama_build_graph: non-view tensors processed: 676/676
641
+ llama_new_context_with_model: compute buffer total size = 159.19 MiB
642
+ ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size = 156.02 MiB, ( 2785.45 / 10922.67)
643
+ Available slots:
644
+ -> Slot 0 - max context: 2048
645
+
646
+ llama server listening at http://0.0.0.0:8080
647
+ ```
648
+
649
+ 2. To access the chatbot interface, open your web browser and enter `http://0.0.0.0:8080` into the address bar.
650
+
651
+ ![Yi model chatbot interface - llama.cpp](https://github.com/01-ai/Yi/blob/main/assets/img/yi_llama_cpp1.png?raw=true)
652
 
653
+
654
+ 3. Enter a question, such as "How do you feed your pet fox? Please answer this question in 6 simple steps" into the prompt window, and you will receive a corresponding answer.
655
+
656
+ ![Ask a question to Yi model - llama.cpp](https://github.com/01-ai/Yi/blob/main/assets/img/yi_llama_cpp2.png?raw=true)
657
+
658
+ </ul>
659
  </details>
660
 
661
+ <p align="right"> [
662
+ <a href="#top">Back to top ⬆️ </a> ]
663
+ </p>
664
+
665
+ ### Web demo
666
+
667
+ You can build a web UI demo for Yi **chat** models (note that Yi base models are not supported in this senario).
668
+
669
+ [Step 1: Prepare your environment](#step-1-prepare-your-environment).
670
+
671
+ [Step 2: Download the Yi model](#step-2-download-the-yi-model).
672
+
673
+ Step 3. To start a web service locally, run the following command.
674
+
675
+ ```bash
676
+ python demo/web_demo.py -c <your-model-path>
677
+ ```
678
+
679
+ You can access the web UI by entering the address provided in the console into your browser.
680
+
681
+ ![Quick start - web demo](https://github.com/01-ai/Yi/blob/main/assets/img/yi_34b_chat_web_demo.gif?raw=true)
682
+
683
+ <p align="right"> [
684
+ <a href="#top">Back to top ⬆️ </a> ]
685
+ </p>
686
+
687
+ ### Fine-tuning
688
 
689
  ```bash
690
  bash finetune/scripts/run_sft_Yi_6b.sh
 
695
  ```bash
696
  bash finetune/scripts/run_eval.sh
697
  ```
698
+ <details style="display: inline;"><summary>For advanced usage (like fine-tuning based on your custom data), see the explanations below. ⬇️ </summary> <ul>
699
+
700
+ ### Finetune code for Yi 6B and 34B
701
+
702
+ #### Preparation
703
+
704
+ ##### From Image
705
+
706
+ By default, we use a small dataset from [BAAI/COIG](https://huggingface.co/datasets/BAAI/COIG) to finetune the base model.
707
+ You can also prepare your customized dataset in the following `jsonl` format:
708
+
709
+ ```json
710
+ { "prompt": "Human: Who are you? Assistant:", "chosen": "I'm Yi." }
711
+ ```
712
+
713
+ And then mount them in the container to replace the default ones:
714
+
715
+ ```bash
716
+ docker run -it \
717
+ -v /path/to/save/finetuned/model/:/finetuned-model \
718
+ -v /path/to/train.jsonl:/yi/finetune/data/train.json \
719
+ -v /path/to/eval.jsonl:/yi/finetune/data/eval.json \
720
+ ghcr.io/01-ai/yi:latest \
721
+ bash finetune/scripts/run_sft_Yi_6b.sh
722
+ ```
723
+
724
+ ##### From Local Server
725
+
726
+ Make sure you have conda. If not, use
727
+
728
+ ```bash
729
+ mkdir -p ~/miniconda3
730
+ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
731
+ bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
732
+ rm -rf ~/miniconda3/miniconda.sh
733
+ ~/miniconda3/bin/conda init bash
734
+ source ~/.bashrc
735
+ ```
736
+
737
+ Then, create a conda env:
738
+
739
+ ```bash
740
+ conda create -n dev_env python=3.10 -y
741
+ conda activate dev_env
742
+ pip install torch==2.0.1 deepspeed==0.10 tensorboard transformers datasets sentencepiece accelerate ray==2.7
743
+ ```
744
+
745
+ #### Hardware Setup
746
 
747
+ For the Yi-6B model, a node with 4 GPUs, each has GPU mem larger than 60GB is recommended.
748
+
749
+ For the Yi-34B model, because the usage of zero-offload technique takes a lot CPU memory, please be careful to limit the GPU numbers in 34B finetune training. Please use CUDA_VISIBLE_DEVICES to limit the GPU number (as shown in scripts/run_sft_Yi_34b.sh).
750
+
751
+ A typical hardware setup for finetuning 34B model is a node with 8GPUS (limit to 4 in running by CUDA_VISIBLE_DEVICES=0,1,2,3), each has GPU mem larger than 80GB, with total CPU mem larger than 900GB.
752
+
753
+ #### Quick Start
754
+
755
+ Download a LLM-base model to MODEL_PATH (6B and 34B). A typical folder of models is like:
756
+
757
+ ```bash
758
+ |-- $MODEL_PATH
759
+ | |-- config.json
760
+ | |-- pytorch_model-00001-of-00002.bin
761
+ | |-- pytorch_model-00002-of-00002.bin
762
+ | |-- pytorch_model.bin.index.json
763
+ | |-- tokenizer_config.json
764
+ | |-- tokenizer.model
765
+ | |-- ...
766
+ ```
767
+
768
+ Download a dataset from huggingface to local storage DATA_PATH, e.g. Dahoas/rm-static.
769
+
770
+ ```bash
771
+ |-- $DATA_PATH
772
+ | |-- data
773
+ | | |-- train-00000-of-00001-2a1df75c6bce91ab.parquet
774
+ | | |-- test-00000-of-00001-8c7c51afc6d45980.parquet
775
+ | |-- dataset_infos.json
776
+ | |-- README.md
777
+ ```
778
+
779
+ `finetune/yi_example_dataset` has example datasets, which are modified from [BAAI/COIG](https://huggingface.co/datasets/BAAI/COIG)
780
+
781
+ ```bash
782
+ |-- $DATA_PATH
783
+ |--data
784
+ |-- train.jsonl
785
+ |-- eval.jsonl
786
+ ```
787
+
788
+ `cd` into the scripts folder, copy and paste the script, and run. For example:
789
+
790
+ ```bash
791
+ cd finetune/scripts
792
+
793
+ bash run_sft_Yi_6b.sh
794
+ ```
795
+
796
+ For the Yi-6B base model, setting training_debug_steps=20 and num_train_epochs=4 can output a chat model, which takes about 20 minutes.
797
+
798
+ For the Yi-34B base model, it takes a relatively long time for initialization. Please be patient.
799
+
800
+ #### Evaluation
801
+
802
+ ```bash
803
+ cd finetune/scripts
804
+
805
+ bash run_eval.sh
806
+ ```
807
+
808
+ Then you'll see the answer from both the base model and the finetuned model.
809
+ </ul>
810
+ </details>
811
+
812
+ <p align="right"> [
813
+ <a href="#top">Back to top ⬆️ </a> ]
814
+ </p>
815
 
816
  ### Quantization
817
 
 
831
  --trust_remote_code
832
  ```
833
 
834
+ <details style="display: inline;"><summary>For a more detailed explanation, see the explanations below. ⬇️</summary> <ul>
835
+
836
+ #### GPT-Q quantization
837
+
838
+ [GPT-Q](https://github.com/IST-DASLab/gptq) is a PTQ(Post-Training Quantization)
839
+ method. It's memory saving and provides potential speedups while retaining the accuracy
840
+ of the model.
841
+
842
+ Yi models can be GPT-Q quantized without a lot of efforts.
843
+ We provide a step-by-step tutorial below.
844
+
845
+ To run GPT-Q, we will use [AutoGPTQ](https://github.com/PanQiWei/AutoGPTQ) and
846
+ [exllama](https://github.com/turboderp/exllama).
847
+ And the huggingface transformers has integrated optimum and auto-gptq to perform
848
+ GPTQ quantization on language models.
849
+
850
+ ##### Do Quantization
851
+
852
+ The `quant_autogptq.py` script is provided for you to perform GPT-Q quantization:
853
+
854
+ ```bash
855
+ python quant_autogptq.py --model /base_model \
856
+ --output_dir /quantized_model --bits 4 --group_size 128 --trust_remote_code
857
+ ```
858
+
859
+
860
+ ##### Run Quantized Model
861
+
862
+ You can run a quantized model using the `eval_quantized_model.py`:
863
+
864
+ ```bash
865
+ python eval_quantized_model.py --model /quantized_model --trust_remote_code
866
+ ```
867
+ </ul>
868
+ </details>
869
 
870
  #### AWQ
871
  ```bash
 
882
  --model /quantized_model \
883
  --trust_remote_code
884
  ```
885
+ <details style="display: inline;"><summary>For detailed explanations, see the explanations below. ⬇️</summary> <ul>
886
+
887
+ #### AWQ quantization
888
+
889
+ [AWQ](https://github.com/mit-han-lab/llm-awq) is a PTQ(Post-Training Quantization)
890
+ method. It's an efficient and accurate low-bit weight quantization (INT3/4) for LLMs.
891
+
892
+ Yi models can be AWQ quantized without a lot of efforts.
893
+ We provide a step-by-step tutorial below.
894
+
895
+ To run AWQ, we will use [AutoAWQ](https://github.com/casper-hansen/AutoAWQ).
896
+
897
+ ##### Do Quantization
898
+
899
+ The `quant_autoawq.py` script is provided for you to perform AWQ quantization:
900
+
901
+ ```bash
902
+ python quant_autoawq.py --model /base_model \
903
+ --output_dir /quantized_model --bits 4 --group_size 128 --trust_remote_code
904
+ ```
905
+
906
+ ##### Run Quantized Model
907
+
908
+ You can run a quantized model using the `eval_quantized_model.py`:
909
+
910
+ ```bash
911
+ python eval_quantized_model.py --model /quantized_model --trust_remote_code
912
+ ```
913
+
914
+
915
+ </ul>
916
+ </details>
917
+ <p align="right"> [
918
+ <a href="#top">Back to top ⬆️ </a> ]
919
+ </p>
920
+
921
+ ### Deployment
922
+
923
+ If you want to deploy Yi models, make sure you meet the software and hardware requirements.
924
+
925
+ #### Software requirements
926
+
927
+ Before using Yi quantized models, make sure you've installed the correct software listed below.
928
+
929
+ | Model | Software
930
+ |---|---
931
+ Yi 4-bit quantized models | [AWQ and CUDA](https://github.com/casper-hansen/AutoAWQ?tab=readme-ov-file#install-from-pypi)
932
+ Yi 8-bit quantized models | [GPTQ and CUDA](https://github.com/PanQiWei/AutoGPTQ?tab=readme-ov-file#quick-installation)
933
+
934
+ #### Hardware requirements
935
+
936
+ Before deploying Yi in your environment, make sure your hardware meets the following requirements.
937
+
938
+ ##### Chat models
939
+
940
+ | Model | Minimum VRAM | Recommended GPU Example |
941
+ |----------------------|--------------|:-------------------------------------:|
942
+ | Yi-6B-Chat | 15 GB | RTX 3090 <br> RTX 4090 <br> A10 <br> A30 |
943
+ | Yi-6B-Chat-4bits | 4 GB | RTX 3060 <br> RTX 4060 |
944
+ | Yi-6B-Chat-8bits | 8 GB | RTX 3070 <br> RTX 4060 |
945
+ | Yi-34B-Chat | 72 GB | 4 x RTX 4090 <br> A800 (80GB) |
946
+ | Yi-34B-Chat-4bits | 20 GB | RTX 3090 <br> RTX 4090 <br> A10 <br> A30 <br> A100 (40GB) |
947
+ | Yi-34B-Chat-8bits | 38 GB | 2 x RTX 3090 <br> 2 x RTX 4090 <br> A800 (40GB) |
948
+
949
+ Below are detailed minimum VRAM requirements under different batch use cases.
950
+
951
+ | Model | batch=1 | batch=4 | batch=16 | batch=32 |
952
+ | ----------------------- | ------- | ------- | -------- | -------- |
953
+ | Yi-6B-Chat | 12 GB | 13 GB | 15 GB | 18 GB |
954
+ | Yi-6B-Chat-4bits | 4 GB | 5 GB | 7 GB | 10 GB |
955
+ | Yi-6B-Chat-8bits | 7 GB | 8 GB | 10 GB | 14 GB |
956
+ | Yi-34B-Chat | 65 GB | 68 GB | 76 GB | > 80 GB |
957
+ | Yi-34B-Chat-4bits | 19 GB | 20 GB | 30 GB | 40 GB |
958
+ | Yi-34B-Chat-8bits | 35 GB | 37 GB | 46 GB | 58 GB |
959
+
960
+ ##### Base models
961
+
962
+ | Model | Minimum VRAM | Recommended GPU Example |
963
+ |----------------------|--------------|:-------------------------------------:|
964
+ | Yi-6B | 15 GB | RTX3090 <br> RTX4090 <br> A10 <br> A30 |
965
+ | Yi-6B-200K | 50 GB | A800 (80 GB) |
966
+ | Yi-9B | 20 GB | 1 x RTX 4090 (24 GB) |
967
+ | Yi-34B | 72 GB | 4 x RTX 4090 <br> A800 (80 GB) |
968
+ | Yi-34B-200K | 200 GB | 4 x A800 (80 GB) |
969
+
970
+ <p align="right"> [
971
+ <a href="#top">Back to top ⬆️ </a> ]
972
+ </p>
973
+
974
+ ### Learning hub
975
+
976
+ <details>
977
+ <summary> If you want to learn Yi, you can find a wealth of helpful educational resources here. ⬇️</summary>
978
+ <br>
979
+
980
+ Welcome to the Yi learning hub!
981
+
982
+ Whether you're a seasoned developer or a newcomer, you can find a wealth of helpful educational resources to enhance your understanding and skills with Yi models, including insightful blog posts, comprehensive video tutorials, hands-on guides, and more.
983
+
984
+ The content you find here has been generously contributed by knowledgeable Yi experts and passionate enthusiasts. We extend our heartfelt gratitude for your invaluable contributions!
985
+
986
+ At the same time, we also warmly invite you to join our collaborative effort by contributing to Yi. If you have already made contributions to Yi, please don't hesitate to showcase your remarkable work in the table below.
987
 
988
+ With all these resources at your fingertips, you're ready to start your exciting journey with Yi. Happy learning! 🥳
989
+
990
+ #### Tutorials
991
+ ##### English tutorials
992
+ | Type | Deliverable | Date | Author |
993
+ |-------------|--------------------------------------------------------|----------------|----------------|
994
+ | Video | [Run dolphin-2.2-yi-34b on IoT Devices](https://www.youtube.com/watch?v=NJ89T5mO25Y) | 2023-11-30 | [Second State](https://github.com/second-state) |
995
+ | Blog | [Running Yi-34B-Chat locally using LlamaEdge](https://www.secondstate.io/articles/yi-34b/) | 2023-11-30 | [Second State](https://github.com/second-state) |
996
+ | Video | [Install Yi 34B Locally - Chinese English Bilingual LLM](https://www.youtube.com/watch?v=CVQvj4Wrh4w&t=476s) | 2023-11-05 | [Fahd Mirza](https://www.youtube.com/@fahdmirza) |
997
+ | Video | [Dolphin Yi 34b - Brand New Foundational Model TESTED](https://www.youtube.com/watch?v=On3Zuv27V3k&t=85s) | 2023-11-27 | [Matthew Berman](https://www.youtube.com/@matthew_berman) |
998
+
999
+
1000
+ ##### Chinese tutorials
1001
+ | Type | Deliverable | Date | Author |
1002
+ |-------------|--------------------------------------------------------|----------------|----------------|
1003
+ | Blog | [实测零一万物Yi-VL多模态语言模型:能准确“识图吃瓜”](https://mp.weixin.qq.com/s/fu4O9XvJ03JhimsEyI-SsQ) | 2024-02-02 | [苏洋](https://github.com/soulteary) |
1004
+ | Blog | [本地运行零一万物 34B 大模型,使用 Llama.cpp & 21G 显存](https://zhuanlan.zhihu.com/p/668921042) | 2023-11-26 | [苏洋](https://github.com/soulteary) |
1005
+ | Blog | [零一万物模型折腾笔记:官方 Yi-34B 模型基础使用](https://zhuanlan.zhihu.com/p/671387298) | 2023-12-10 | [苏洋](https://github.com/soulteary) |
1006
+ | Blog | [CPU 混合推理,非常见大模型量化方案:“二三五六” 位量化方案](https://zhuanlan.zhihu.com/p/671698216) | 2023-12-12 | [苏洋](https://github.com/soulteary) |
1007
+ | Blog | [单卡 3 小时训练 Yi-6B 大模型 Agent:基于 Llama Factory 实战](https://zhuanlan.zhihu.com/p/678989191) | 2024-01-22 | [郑耀威](https://github.com/hiyouga) |
1008
+ | Blog | [零一万物开源Yi-VL多模态大模型,魔搭社区推理&微调最佳实践来啦!](https://zhuanlan.zhihu.com/p/680098411) | 2024-01-26 | [ModelScope](https://github.com/modelscope) |
1009
+ | Video | [只需 24G 显存,用 vllm 跑起来 Yi-34B 中英双语大模型](https://www.bilibili.com/video/BV17t4y1f7Ee/) | 2023-12-28 | [漆妮妮](https://space.bilibili.com/1262370256) |
1010
+ | Video | [Yi-VL-34B 多模态大模型 - 用两张 A40 显卡跑起来](https://www.bilibili.com/video/BV1Q5411y7AG/) | 2023-01-28 | [漆妮妮](https://space.bilibili.com/1262370256) |
1011
+
1012
+ </details>
1013
 
 
1014
 
1015
  # 🟢 Why Yi?
1016
 
 
1022
  - [🛠️ Fine-tuning](#️-fine-tuning)
1023
  - [API](#api)
1024
  - [📌 Benchmarks](#-benchmarks)
 
1025
  - [📊 Chat model performance](#-chat-model-performance)
1026
+ - [📊 Base model performance](#-base-model-performance)
1027
 
1028
  ## 🌎 Ecosystem
1029
 
 
1038
 
1039
  ### 💦 Upstream
1040
 
1041
+ The Yi series models follow the same model architecture as Llama. By choosing Yi, you can leverage existing tools, libraries, and resources within the Llama ecosystem, eliminating the need to create new tools and enhancing development efficiency.
1042
 
1043
+ For example, the Yi series models are saved in the format of the Llama model. You can directly use `LlamaForCausalLM` and `LlamaTokenizer` to load the model. For more information, see [Use the chat model](#31-use-the-chat-model).
1044
 
1045
  ```python
1046
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
1050
  model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-34b", device_map="auto")
1051
  ```
1052
 
1053
+ <p align="right"> [
1054
+ <a href="#top">Back to top ⬆️ </a> ]
1055
+ </p>
1056
+
1057
  ### 🌊 Downstream
1058
 
1059
  > 💡 Tip
 
1106
  - [amazing-openai-api](https://github.com/soulteary/amazing-openai-api): this tool converts Yi model APIs into the OpenAI API format out of the box.
1107
  - [LlamaEdge](https://www.secondstate.io/articles/yi-34b/#create-an-openai-compatible-api-service-for-the-yi-34b-chat-model): this tool builds an OpenAI-compatible API server for Yi-34B-Chat using a portable Wasm (WebAssembly) file, powered by Rust.
1108
 
1109
+ <p align="right"> [
1110
+ <a href="#top">Back to top ⬆️ </a> ]
1111
+ </p>
1112
 
1113
  ## 📌 Benchmarks
1114
 
 
1115
  - [📊 Chat model performance](#-chat-model-performance)
1116
+ - [📊 Base model performance](#-base-model-performance)
1117
 
1118
+ ### 📊 Chat model performance
1119
 
1120
+ Yi-34B-Chat model demonstrates exceptional performance, ranking first among all existing open-source models in the benchmarks including MMLU, CMMLU, BBH, GSM8k, and more.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1121
 
1122
+ ![Chat model performance](https://github.com/01-ai/Yi/blob/main/assets/img/benchmark_chat.png?raw=true)
1123
+
1124
+ <details>
1125
+ <summary> Evaluation methods and challenges. ⬇️ </summary>
1126
 
1127
+ - **Evaluation methods**: we evaluated various benchmarks using both zero-shot and few-shot methods, except for TruthfulQA.
1128
+ - **Zero-shot vs. few-shot**: in chat models, the zero-shot approach is more commonly employed.
1129
+ - **Evaluation strategy**: our evaluation strategy involves generating responses while following instructions explicitly or implicitly (such as using few-shot examples). We then isolate relevant answers from the generated text.
1130
+ - **Challenges faced**: some models are not well-suited to produce output in the specific format required by instructions in few datasets, which leads to suboptimal results.
 
 
 
 
 
 
 
 
 
 
 
 
 
1131
 
1132
  <strong>*</strong>: C-Eval results are evaluated on the validation datasets
1133
+ </details>
1134
+
1135
+ ### 📊 Base model performance
1136
+
1137
+ #### Yi-34B and Yi-34B-200K
1138
+
1139
+ The Yi-34B and Yi-34B-200K models stand out as the top performers among open-source models, especially excelling in MMLU, CMMLU, common-sense reasoning, reading comprehension, and more.
1140
+
1141
+ ![Base model performance](https://github.com/01-ai/Yi/blob/main/assets/img/benchmark_base.png?raw=true)
1142
+
1143
+ <details>
1144
+ <summary> Evaluation methods. ⬇️</summary>
1145
+
1146
+ - **Disparity in results**: while benchmarking open-source models, a disparity has been noted between results from our pipeline and those reported by public sources like OpenCompass.
1147
+ - **Investigation findings**: a deeper investigation reveals that variations in prompts, post-processing strategies, and sampling techniques across models may lead to significant outcome differences.
1148
+ - **Uniform benchmarking process**: our methodology aligns with the original benchmarks—consistent prompts and post-processing strategies are used, and greedy decoding is applied during evaluations without any post-processing for the generated content.
1149
+ - **Efforts to retrieve unreported scores**: for scores that were not reported by the original authors (including scores reported with different settings), we try to get results with our pipeline.
1150
+ - **Extensive model evaluation**: to evaluate the model’s capability extensively, we adopted the methodology outlined in Llama2. Specifically, we included PIQA, SIQA, HellaSwag, WinoGrande, ARC, OBQA, and CSQA to assess common sense reasoning. SquAD, QuAC, and BoolQ were incorporated to evaluate reading comprehension.
1151
+ - **Special configurations**: CSQA was exclusively tested using a 7-shot setup, while all other tests were conducted with a 0-shot configuration. Additionally, we introduced GSM8K (8-shot@1), MATH (4-shot@1), HumanEval (0-shot@1), and MBPP (3-shot@1) under the category "Math & Code".
1152
+ - **Falcon-180B caveat**: Falcon-180B was not tested on QuAC and OBQA due to technical constraints. Its performance score is an average from other tasks, and considering the generally lower scores of these two tasks, Falcon-180B's capabilities are likely not underestimated.
1153
+ </details>
1154
+
1155
+ #### Yi-9B
1156
 
1157
+ Yi-9B is almost the best among a range of similar-sized open-source models (including Mistral-7B, SOLAR-10.7B, Gemma-7B, DeepSeek-Coder-7B-Base-v1.5 and more), particularly excelling in code, math, common-sense reasoning, and reading comprehension.
1158
 
1159
+ ![Yi-9B benchmark - details](TBD)
1160
+
1161
+ - In terms of **overall** ability (`Mean-All), Yi-9B performs the best among similarly sized open-source models, surpassing DeepSeek-Coder, DeepSeek-Math, Mistral-7B, SOLAR-10.7B, and Gemma-7B.
1162
+
1163
+ ![Yi-9B benchmark - overall](TBD)
1164
+
1165
+ - In terms of **coding** ability (Mean-Code), Yi-9B's performance is second only to DeepSeek-Coder-7B, surpassing Yi-34B, SOLAR-10.7B, Mistral-7B, and Gemma-7B.
1166
+
1167
+ ![Yi-9B benchmark - code](TBD)
1168
+
1169
+ - In terms of **math** ability (Mean-Math), Yi-9B's performance is second only to DeepSeek-Math-7B, surpassing SOLAR-10.7B, Mistral-7B, and Gemma-7B.
1170
+
1171
+ ![Yi-9B benchmark - math](TBD)
1172
+
1173
+ - In terms of **common sense and reasoning** ability (Mean-Text), Yi-9B's performance is on par with Mistral-7B, SOLAR-10.7B, and Gemma-7B.
1174
+
1175
+ ![Yi-9B benchmark - text](TBD)
1176
+
1177
+ <p align="right"> [
1178
+ <a href="#top">Back to top ⬆️ </a> ]
1179
+ </p>
1180
 
1181
  # 🟢 Who can use Yi?
1182
 
 
1186
 
1187
  - For free commercial use, you only need to [complete this form](https://www.lingyiwanwu.com/yi-license) to get a Yi Model Commercial License.
1188
 
1189
+ <p align="right"> [
1190
+ <a href="#top">Back to top ⬆️ </a> ]
1191
+ </p>
1192
 
1193
  # 🟢 Misc.
1194
 
 
1196
 
1197
  A heartfelt thank you to each of you who have made contributions to the Yi community! You have helped Yi not just a project, but a vibrant, growing home for innovation.
1198
 
1199
+ [![yi contributors](https://contrib.rocks/image?repo=01-ai/yi&max=2000&columns=15)](https://github.com/01-ai/yi/graphs/contributors)
1200
+
1201
+ <p align="right"> [
1202
+ <a href="#top">Back to top ⬆️ </a> ]
1203
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1204
 
1205
  ### 📡 Disclaimer
1206
 
 
1213
  resulting from misuse, misguidance, illegal usage, and related misinformation,
1214
  as well as any associated data security concerns.
1215
 
1216
+ <p align="right"> [
1217
+ <a href="#top">Back to top ⬆️ </a> ]
1218
+ </p>
1219
 
1220
  ### 🪪 License
1221
 
1222
  The source code in this repo is licensed under the [Apache 2.0
1223
+ license](https://github.com/01-ai/Yi/blob/main/LICENSE). The Yi series models are fully open for academic research and free for commercial use, with automatic permission granted upon application. All usage must adhere to the [Yi Series Models Community License Agreement 2.1](https://github.com/01-ai/Yi/blob/main/MODEL_LICENSE_AGREEMENT.txt).
 
 
1224
  For free commercial use, you only need to send an email to [get official commercial permission](https://www.lingyiwanwu.com/yi-license).
1225
 
1226
+ <p align="right"> [
1227
+ <a href="#top">Back to top ⬆️ </a> ]
1228
+ </p>