Home

Awesome

<p align="left"> &nbspEnglish&nbsp | &nbsp; <a href="README_CN.md">中文</a> </p> <br><br> <div align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/01-ai/Yi/main/assets/img/Yi_logo_icon_dark.svg" width="200px"> <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/01-ai/Yi/main/assets/img/Yi_logo_icon_light.svg" width="200px"> <img alt="specify theme context for images" src="https://raw.githubusercontent.com/01-ai/Yi/main/assets/img/Yi_logo_icon_light.svg" width="200px"> </picture> </br> </br> <a href="https://github.com/01-ai/Yi/actions/workflows/build_docker_image.yml"> <img src="https://github.com/01-ai/Yi/actions/workflows/build_docker_image.yml/badge.svg"> </a> <a href="mailto:oss@01.ai"> <img src="https://img.shields.io/badge/✉️-yi@01.ai-FFE01B"> </a> </div> <div id="top"></div> <div align="center"> <h3 align="center">Building the Next Generation of Open-Source and Bilingual LLMs</h3> </div> <p align="center"> 🤗 <a href="https://huggingface.co/01-ai" target="_blank">Hugging Face</a> • 🤖 <a href="https://www.modelscope.cn/organization/01ai/" target="_blank">ModelScope</a> • 🟣 <a href="https://wisemodel.cn/organization/01.AI" target="_blank">wisemodel</a> </p> <p align="center"> 👩‍🚀 Ask questions or discuss ideas on <a href="https://github.com/01-ai/Yi/discussions" target="_blank"> GitHub </a> </p> <p align="center"> 👋 Join us on <a href="https://discord.gg/hYUwWddeAu" target="_blank"> 👾 Discord </a> or <a href="https://github.com/01-ai/Yi-1.5/issues/2" target="_blank"> 💬 WeChat </a> </p> <p align="center"> 📝 Check out <a href="https://arxiv.org/abs/2403.04652"> Yi Tech Report </a> </p> <p align="center"> 📚 Grow at <a href="#learning-hub"> Yi Learning Hub </a> </p> <p align="center"> 💪 Learn at <a href="https://01-ai.github.io/"> Yi Tech Blog </a> </p> <!-- DO NOT REMOVE ME --> <hr> <details open> <summary></b>📕 Table of Contents</b></summary> </details> <hr>

What is Yi?

Introduction

💡 TL;DR

The Yi series models adopt the same model architecture as Llama but are NOT derivatives of Llama.

</ul> </details> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

News

<details> <summary>🔥 <b>2024-07-29</b>: The <a href="https://github.com/Haijian06/Yi/tree/main/Cookbook">Yi Cookbook 1.0 </a> is released, featuring tutorials and examples in both Chinese and English.</summary> </details> <details> <summary>🎯 <b>2024-05-13</b>: The <a href="https://github.com/01-ai/Yi-1.5">Yi-1.5 series models </a> are open-sourced, further improving coding, math, reasoning, and instruction-following abilities.</summary> </details> <details> <summary>🎯 <b>2024-03-16</b>: The <code>Yi-9B-200K</code> is open-sourced and available to the public.</summary> </details> <details> <summary>🎯 <b>2024-03-08</b>: <a href="https://arxiv.org/abs/2403.04652">Yi Tech Report</a> is published! </summary> </details> <details open> <summary>🔔 <b>2024-03-07</b>: The long text capability of the Yi-34B-200K has been enhanced. </summary> <br> In the "Needle-in-a-Haystack" test, the Yi-34B-200K's performance is improved by 10.5%, rising from 89.3% to an impressive 99.8%. We continue to pre-train the model on 5B tokens long-context data mixture and demonstrate a near-all-green performance. </details> <details open> <summary>🎯 <b>2024-03-06</b>: The <code>Yi-9B</code> is open-sourced and available to the public.</summary> <br> <code>Yi-9B</code> 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. </details> <details open> <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> <br> <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> </details> <details> <summary>🎯 <b>2023-11-23</b>: <a href="#chat-models">Chat models</a> are open-sourced and available to the public.</summary> <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.

You can try some of them interactively at:

</details> <details> <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> </details> <details> <summary>🔥 <b>2023-11-08</b>: Invited test of Yi-34B chat model.</summary> <br>Application form: </details> <details> <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> <br>This release contains two base models with the same parameter sizes as the previous release, except that the context window is extended to 200K. </details> <details> <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> <br>The first public release contains two bilingual (English/Chinese) base models with the parameter sizes of 6B and 34B. Both of them are trained with 4K sequence length and can be extended to 32K during inference time. </details> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Models

Yi models come in multiple sizes and cater to different use cases. You can also fine-tune Yi models to meet your specific requirements.

If you want to deploy Yi models, make sure you meet the software and hardware requirements.

Chat models

ModelDownload
Yi-34B-Chat🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-34B-Chat-4bits🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-34B-Chat-8bits🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-6B-Chat🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-6B-Chat-4bits🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-6B-Chat-8bits🤗 Hugging Face🤖 ModelScope🟣 wisemodel

<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>

Base models

ModelDownload
Yi-34B🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-34B-200K🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-9B🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-9B-200K🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-6B🤗 Hugging Face🤖 ModelScope🟣 wisemodel
Yi-6B-200K🤗 Hugging Face🤖 ModelScope🟣 wisemodel

<sub><sup> - 200k is roughly equivalent to 400,000 Chinese characters. <br> - If you want to use the previous version of the Yi-34B-200K (released on Nov 5, 2023), run git checkout 069cd341d60f4ce4b07ec394e82b79e94f656cf to download the weight. </sup></sub>

Model info

<table> <thead> <tr> <th>Model</th> <th>Intro</th> <th>Default context window</th> <th>Pretrained tokens</th> <th>Training Data Date</th> </tr> </thead> <tbody><tr> <td>6B series models</td> <td>They are suitable for personal and academic use.</td> <td rowspan="3">4K</td> <td>3T</td> <td rowspan="3">Up to June 2023</td> </tr> <tr> <td>9B series models</td> <td>It is the best at coding and math in the Yi series models.</td> <td>Yi-9B is continuously trained based on Yi-6B, using 0.8T tokens.</td> </tr> <tr> <td>34B series models</td> <td>They are suitable for personal, academic, and commercial (particularly for small and medium-sized enterprises) purposes. It&#39;s a cost-effective solution that&#39;s affordable and equipped with emergent ability.</td> <td>3T</td> </tr> </tbody></table> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

How to use Yi?

Quick start

💡 Tip: If you want to get started with the Yi model and explore different methods for inference, check out the Yi Cookbook.

Choose your path

Select one of the following paths to begin your journey with Yi!

Quick start - Choose your path

🎯 Deploy Yi locally

If you prefer to deploy Yi models locally,

🎯 Not to deploy Yi locally

If you prefer not to deploy Yi models locally, you can explore Yi's capabilities using any of the following options.

🙋‍♀️ Run Yi with APIs

If you want to explore more features of Yi, you can adopt one of these methods:

🙋‍♀️ Run Yi in playground

If you want to chat with Yi with more customizable options (e.g., system prompt, temperature, repetition penalty, etc.), you can try one of the following options:

🙋‍♀️ Chat with Yi

If you want to chat with Yi, you can use one of these online services, which offer a similar user experience:

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Quick start - pip

This tutorial guides you through every step of running Yi-34B-Chat locally on an A800 (80G) and then performing inference.

Step 0: Prerequisites

Step 1: Prepare your environment

To set up the environment and install the required packages, execute the following command.

git clone https://github.com/01-ai/Yi.git
cd yi
pip install -r requirements.txt

Step 2: Download the Yi model

You can download the weights and tokenizer of Yi models from the following sources:

Step 3: Perform inference

You can perform inference with Yi chat or base models as below.

Perform inference with Yi chat model
  1. Create a file named quick_start.py and copy the following content to it.

    from transformers import AutoModelForCausalLM, AutoTokenizer
    
    model_path = '<your-model-path>'
    
    tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
    
    # Since transformers 4.35.0, the GPT-Q/AWQ model can be loaded using AutoModelForCausalLM.
    model = AutoModelForCausalLM.from_pretrained(
        model_path,
        device_map="auto",
        torch_dtype='auto'
    ).eval()
    
    # Prompt content: "hi"
    messages = [
        {"role": "user", "content": "hi"}
    ]
    
    input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
    output_ids = model.generate(input_ids.to('cuda'))
    response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
    
    # Model response: "Hello! How can I assist you today?"
    print(response)
    
  2. Run quick_start.py.

    python quick_start.py
    

    Then you can see an output similar to the one below. 🥳

    Hello! How can I assist you today?
    
Perform inference with Yi base model
<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Quick start - Docker

<details> <summary> Run Yi-34B-chat locally with Docker: a step-by-step guide. ⬇️</summary> <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. <h4>Step 0: Prerequisites</h4> <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> <h4> Step 1: Start Docker </h4> <pre><code>docker run -it --gpus all \ -v &lt;your-model-path&gt;: /models ghcr.io/01-ai/yi:latest </code></pre> <p>Alternatively, you can pull the Yi Docker image from <code>registry.lingyiwanwu.com/ci/01-ai/yi:latest</code>.</p> <h4>Step 2: Perform inference</h4> <p>You can perform inference with Yi chat or base models as below.</p> <h5>Perform inference with Yi chat model</h5> <p>The steps are similar to <a href="#perform-inference-with-yi-chat-model">pip - Perform inference with Yi chat model</a>.</p> <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> <h5>Perform inference with Yi base model</h5> <p>The steps are similar to <a href="#perform-inference-with-yi-base-model">pip - Perform inference with Yi base model</a>.</p> <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> </details>

Quick start - conda-lock

<details> <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> <br> 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. <br> To install the dependencies, follow these steps:
  1. Install micromamba by following the instructions available <a href="https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html">here</a>.

  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.

</details>

Quick start - llama.cpp

<a href="https://github.com/01-ai/Yi/blob/main/docs/README_llama.cpp.md">The following tutorial </a> will guide 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.

<details> <summary> Run Yi-chat-6B-2bits locally with llama.cpp: a step-by-step guide. ⬇️</summary> <br><a href="https://github.com/01-ai/Yi/blob/main/docs/README_llama.cpp.md">This tutorial</a> 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>

Step 0: Prerequisites

Step 1: Download llama.cpp

To clone the llama.cpp repository, run the following command.

git clone git@github.com:ggerganov/llama.cpp.git

Step 2: Download Yi model

2.1 To clone XeIaso/yi-chat-6B-GGUF with just pointers, run the following command.

GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/XeIaso/yi-chat-6B-GGUF

2.2 To download a quantized Yi model (yi-chat-6b.Q2_K.gguf), run the following command.

git-lfs pull --include yi-chat-6b.Q2_K.gguf

Step 3: Perform inference

To perform inference with the Yi model, you can use one of the following methods.

Method 1: Perform inference in terminal

To compile llama.cpp using 4 threads and then conduct inference, navigate to the llama.cpp directory, and run the following command.

Tips
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

...

How do you feed your pet fox? Please answer this question in 6 simple steps:

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.

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.

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.

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.

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.

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.

...

Now you have successfully asked a question to the Yi model and got an answer! 🥳

Method 2: Perform inference in web
  1. To initialize a lightweight and swift chatbot, run the following command.

    cd llama.cpp
    ./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
    

    Then you can get an output like this:

    ...
    
    llama_new_context_with_model: n_ctx      = 2048
    llama_new_context_with_model: freq_base  = 5000000.0
    llama_new_context_with_model: freq_scale = 1
    ggml_metal_init: allocating
    ggml_metal_init: found device: Apple M2 Pro
    ggml_metal_init: picking default device: Apple M2 Pro
    ggml_metal_init: ggml.metallib not found, loading from source
    ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
    ggml_metal_init: loading '/Users/yu/llama.cpp/ggml-metal.metal'
    ggml_metal_init: GPU name:   Apple M2 Pro
    ggml_metal_init: GPU family: MTLGPUFamilyApple8 (1008)
    ggml_metal_init: hasUnifiedMemory              = true
    ggml_metal_init: recommendedMaxWorkingSetSize  = 11453.25 MB
    ggml_metal_init: maxTransferRate               = built-in GPU
    ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =   128.00 MiB, ( 2629.44 / 10922.67)
    llama_new_context_with_model: KV self size  =  128.00 MiB, K (f16):   64.00 MiB, V (f16):   64.00 MiB
    ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =     0.02 MiB, ( 2629.45 / 10922.67)
    llama_build_graph: non-view tensors processed: 676/676
    llama_new_context_with_model: compute buffer total size = 159.19 MiB
    ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =   156.02 MiB, ( 2785.45 / 10922.67)
    Available slots:
    -> Slot 0 - max context: 2048
    
    llama server listening at http://0.0.0.0:8080
    
  2. To access the chatbot interface, open your web browser and enter http://0.0.0.0:8080 into the address bar.

    Yi model chatbot interface - llama.cpp

  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.

    Ask a question to Yi model - llama.cpp

</ul> </details> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Web demo

You can build a web UI demo for Yi chat models (note that Yi base models are not supported in this senario).

Step 1: Prepare your environment.

Step 2: Download the Yi model.

Step 3. To start a web service locally, run the following command.

python demo/web_demo.py -c <your-model-path>

You can access the web UI by entering the address provided in the console into your browser.

Quick start - web demo

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Fine-tuning

bash finetune/scripts/run_sft_Yi_6b.sh

Once finished, you can compare the finetuned model and the base model with the following command:

bash finetune/scripts/run_eval.sh
<details style="display: inline;"><summary>For advanced usage (like fine-tuning based on your custom data), see the explanations below. ⬇️ </summary> <ul>

Finetune code for Yi 6B and 34B

Preparation

From Image

By default, we use a small dataset from BAAI/COIG to finetune the base model. You can also prepare your customized dataset in the following jsonl format:

{ "prompt": "Human: Who are you? Assistant:", "chosen": "I'm Yi." }

And then mount them in the container to replace the default ones:

docker run -it \
    -v /path/to/save/finetuned/model/:/finetuned-model \
    -v /path/to/train.jsonl:/yi/finetune/data/train.json \
    -v /path/to/eval.jsonl:/yi/finetune/data/eval.json \
    ghcr.io/01-ai/yi:latest \
    bash finetune/scripts/run_sft_Yi_6b.sh
From Local Server

Make sure you have conda. If not, use

mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm -rf ~/miniconda3/miniconda.sh
~/miniconda3/bin/conda init bash
source ~/.bashrc

Then, create a conda env:

conda create -n dev_env python=3.10 -y
conda activate dev_env
pip install torch==2.0.1 deepspeed==0.10 tensorboard transformers datasets sentencepiece accelerate ray==2.7

Hardware Setup

For the Yi-6B model, a node with 4 GPUs, each with GPU memory larger than 60GB, is recommended.

For the Yi-34B model, because the usage of the zero-offload technique consumes a lot of CPU memory, please be careful to limit the number of GPUs in the 34B finetune training. Please use CUDA_VISIBLE_DEVICES to limit the number of GPUs (as shown in scripts/run_sft_Yi_34b.sh).

A typical hardware setup for finetuning the 34B model is a node with 8 GPUs (limited to 4 in running by CUDA_VISIBLE_DEVICES=0,1,2,3), each with GPU memory larger than 80GB, and total CPU memory larger than 900GB.

Quick Start

Download a LLM-base model to MODEL_PATH (6B and 34B). A typical folder of models is like:

|-- $MODEL_PATH
|   |-- config.json
|   |-- pytorch_model-00001-of-00002.bin
|   |-- pytorch_model-00002-of-00002.bin
|   |-- pytorch_model.bin.index.json
|   |-- tokenizer_config.json
|   |-- tokenizer.model
|   |-- ...

Download a dataset from huggingface to local storage DATA_PATH, e.g. Dahoas/rm-static.

|-- $DATA_PATH
|   |-- data
|   |   |-- train-00000-of-00001-2a1df75c6bce91ab.parquet
|   |   |-- test-00000-of-00001-8c7c51afc6d45980.parquet
|   |-- dataset_infos.json
|   |-- README.md

finetune/yi_example_dataset has example datasets, which are modified from BAAI/COIG

|-- $DATA_PATH
    |--data
        |-- train.jsonl
        |-- eval.jsonl

cd into the scripts folder, copy and paste the script, and run. For example:

cd finetune/scripts

bash run_sft_Yi_6b.sh

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.

For the Yi-34B base model, it takes a relatively long time for initialization. Please be patient.

Evaluation

cd finetune/scripts

bash run_eval.sh

Then you'll see the answer from both the base model and the finetuned model.

</ul> </details> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Quantization

GPT-Q

python quantization/gptq/quant_autogptq.py \
  --model /base_model                      \
  --output_dir /quantized_model            \
  --trust_remote_code

Once finished, you can then evaluate the resulting model as follows:

python quantization/gptq/eval_quantized_model.py \
  --model /quantized_model                       \
  --trust_remote_code
<details style="display: inline;"><summary>For details, see the explanations below. ⬇️</summary> <ul>

GPT-Q quantization

GPT-Q is a PTQ (Post-Training Quantization) method. It saves memory and provides potential speedups while retaining the accuracy of the model.

Yi models can be GPT-Q quantized without a lot of efforts. We provide a step-by-step tutorial below.

To run GPT-Q, we will use AutoGPTQ and exllama. And the huggingface transformers has integrated optimum and auto-gptq to perform GPTQ quantization on language models.

Do Quantization

The quant_autogptq.py script is provided for you to perform GPT-Q quantization:

python quant_autogptq.py --model /base_model \
    --output_dir /quantized_model --bits 4 --group_size 128 --trust_remote_code
Run Quantized Model

You can run a quantized model using the eval_quantized_model.py:

python eval_quantized_model.py --model /quantized_model --trust_remote_code
</ul> </details>

AWQ

python quantization/awq/quant_autoawq.py \
  --model /base_model                      \
  --output_dir /quantized_model            \
  --trust_remote_code

Once finished, you can then evaluate the resulting model as follows:

python quantization/awq/eval_quantized_model.py \
  --model /quantized_model                       \
  --trust_remote_code
<details style="display: inline;"><summary>For details, see the explanations below. ⬇️</summary> <ul>

AWQ quantization

AWQ is a PTQ (Post-Training Quantization) method. It's an efficient and accurate low-bit weight quantization (INT3/4) for LLMs.

Yi models can be AWQ quantized without a lot of efforts. We provide a step-by-step tutorial below.

To run AWQ, we will use AutoAWQ.

Do Quantization

The quant_autoawq.py script is provided for you to perform AWQ quantization:

python quant_autoawq.py --model /base_model \
    --output_dir /quantized_model --bits 4 --group_size 128 --trust_remote_code
Run Quantized Model

You can run a quantized model using the eval_quantized_model.py:

python eval_quantized_model.py --model /quantized_model --trust_remote_code
</ul> </details> <p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Deployment

If you want to deploy Yi models, make sure you meet the software and hardware requirements.

Software requirements

Before using Yi quantized models, make sure you've installed the correct software listed below.

ModelSoftware
Yi 4-bit quantized modelsAWQ and CUDA
Yi 8-bit quantized modelsGPTQ and CUDA

Hardware requirements

Before deploying Yi in your environment, make sure your hardware meets the following requirements.

Chat models
ModelMinimum VRAMRecommended GPU Example
Yi-6B-Chat15 GB1 x RTX 3090 (24 GB) <br> 1 x RTX 4090 (24 GB) <br> 1 x A10 (24 GB) <br> 1 x A30 (24 GB)
Yi-6B-Chat-4bits4 GB1 x RTX 3060 (12 GB)<br> 1 x RTX 4060 (8 GB)
Yi-6B-Chat-8bits8 GB1 x RTX 3070 (8 GB) <br> 1 x RTX 4060 (8 GB)
Yi-34B-Chat72 GB4 x RTX 4090 (24 GB)<br> 1 x A800 (80GB)
Yi-34B-Chat-4bits20 GB1 x RTX 3090 (24 GB) <br> 1 x RTX 4090 (24 GB) <br> 1 x A10 (24 GB) <br> 1 x A30 (24 GB) <br> 1 x A100 (40 GB)
Yi-34B-Chat-8bits38 GB2 x RTX 3090 (24 GB) <br> 2 x RTX 4090 (24 GB)<br> 1 x A800 (40 GB)

Below are detailed minimum VRAM requirements under different batch use cases.

Modelbatch=1batch=4batch=16batch=32
Yi-6B-Chat12 GB13 GB15 GB18 GB
Yi-6B-Chat-4bits4 GB5 GB7 GB10 GB
Yi-6B-Chat-8bits7 GB8 GB10 GB14 GB
Yi-34B-Chat65 GB68 GB76 GB> 80 GB
Yi-34B-Chat-4bits19 GB20 GB30 GB40 GB
Yi-34B-Chat-8bits35 GB37 GB46 GB58 GB
Base models
ModelMinimum VRAMRecommended GPU Example
Yi-6B15 GB1 x RTX 3090 (24 GB) <br> 1 x RTX 4090 (24 GB) <br> 1 x A10 (24 GB) <br> 1 x A30 (24 GB)
Yi-6B-200K50 GB1 x A800 (80 GB)
Yi-9B20 GB1 x RTX 4090 (24 GB)
Yi-34B72 GB4 x RTX 4090 (24 GB) <br> 1 x A800 (80 GB)
Yi-34B-200K200 GB4 x A800 (80 GB)
<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

FAQ

<details> <summary> If you have any questions while using the Yi series models, the answers provided below could serve as a helpful reference for you. ⬇️</summary> <br>

💡Fine-tuning

💡Quantization

💡General

Learning hub

<details> <summary> If you want to learn Yi, you can find a wealth of helpful educational resources here. ⬇️</summary> <br>

Welcome to the Yi learning hub!

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.

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!

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.

With all these resources at your fingertips, you're ready to start your exciting journey with Yi. Happy learning! 🥳

Tutorials

Blog tutorials
DeliverableDateAuthor
使用 Dify、Meilisearch、零一万物模型实现最简单的 RAG 应用(三):AI 电影推荐2024-05-20苏洋
使用autodl服务器,在A40显卡上运行, Yi-34B-Chat-int4模型,并使用vllm优化加速,显存占用42G,速度18 words-s2024-05-20fly-iot
Yi-VL 最佳实践2024-05-20ModelScope
一键运行零一万物新鲜出炉Yi-1.5-9B-Chat大模型2024-05-13Second State
零一万物开源Yi-1.5系列大模型2024-05-13刘聪
零一万物Yi-1.5系列模型发布并开源! 34B-9B-6B 多尺寸,魔搭社区推理微调最佳实践教程来啦!2024-05-13ModelScope
Yi-34B 本地部署简单测试2024-05-13漆妮妮
驾辰龙跨Llama持Wasm,玩转Yi模型迎新春过大年(上)2024-05-13Words worth
驾辰龙跨Llama持Wasm,玩转Yi模型迎新春过大年(下篇)2024-05-13Words worth
Ollama新增两个命令,开始支持零一万物Yi-1.5系列模型2024-05-13AI工程师笔记
使用零一万物 200K 模型和 Dify 快速搭建模型应用2024-05-13苏洋
(持更) 零一万物模型折腾笔记:社区 Yi-34B 微调模型使用2024-05-13苏洋
Python+ERNIE-4.0-8K-Yi-34B-Chat大模型初探2024-05-11江湖评谈
技术布道 Vue及Python调用零一万物模型和Prompt模板(通过百度千帆大模型平台)2024-05-11MumuLab
多模态大模型Yi-VL-plus体验 效果很棒2024-04-27大家好我是爱因
使用autodl服务器,两个3090显卡上运行, Yi-34B-Chat-int4模型,并使用vllm优化加速,显存占用42G,速度23 words-s2024-04-27fly-iot
Getting Started with Yi-1.5-9B-Chat2024-04-27Second State
基于零一万物yi-vl-plus大模型简单几步就能批量生成Anki图片笔记2024-04-24正经人王同学
【AI开发:语言】一、Yi-34B超大模型本地部署CPU和GPU版2024-04-21My的梦想已实现
【Yi-34B-Chat-Int4】使用4个2080Ti显卡11G版本,运行Yi-34B模型,5年前老显卡是支持的,可以正常运行,速度 21 words-s,vllm要求算力在7以上的显卡就可以2024-03-22fly-iot
零一万物大模型部署+微调总结2024-03-22v_wus
零一万物Yi大模型vllm推理时Yi-34B或Yi-6bchat重复输出的解决方案2024-03-02郝铠锋
Yi-34B微调训练2024-03-02lsjlnd
实测零一万物Yi-VL多模态语言模型:能准确“识图吃瓜”2024-02-02苏洋
零一万物开源Yi-VL多模态大模型,魔搭社区推理&微调最佳实践来啦!2024-01-26ModelScope
单卡 3 小时训练 Yi-6B 大模型 Agent:基于 Llama Factory 实战2024-01-22郑耀威
零一科技Yi-34B Chat大模型环境搭建&推理2024-01-15要养家的程序员
基于LLaMA Factory,单卡3小时训练专属大模型 Agent2024-01-15机器学习社区
双卡 3080ti 部署 Yi-34B 大模型 - Gradio + vLLM 踩坑全记录2024-01-02漆妮妮
【大模型部署实践-3】3个能在3090上跑起来的4bits量化Chat模型(baichuan2-13b、InternLM-20b、Yi-34b)2024-01-02aq_Seabiscuit
只需 24G 显存,用 vllm 跑起来 Yi-34B 中英双语大模型2023-12-28漆妮妮
零一万物模型官方 Yi-34B 模型本地离线运行部署使用笔记(物理机和docker两种部署方式),200K 超长文本内容,34B 干翻一众 70B 模型,打榜分数那么高,这模型到底行不行?2023-12-28代码讲故事
LLM - 大模型速递之 Yi-34B 入门与 LoRA 微调2023-12-18BIT_666
通过vllm框架进行大模型推理2023-12-18土山炮
CPU 混合推理,非常见大模型量化方案:“二三五六” 位量化方案2023-12-12苏洋
零一万物模型折腾笔记:官方 Yi-34B 模型基础使用2023-12-10苏洋
Running Yi-34B-Chat locally using LlamaEdge2023-11-30Second State
本地运行零一万物 34B 大模型,使用 Llama.cpp & 21G 显存2023-11-26苏洋
GitHub Project
DeliverableDateAuthor
yi-openai-proxy2024-05-11苏洋
基于零一万物 Yi 模型和 B 站构建大语言模型高质量训练数据集2024-04-29正经人王同学
基于视频网站和零一万物大模型构建大语言模型高质量训练数据集2024-04-25正经人王同学
基于零一万物yi-34b-chat-200k输入任意文章地址,点击按钮即可生成无广告或推广内容的简要笔记,并生成分享图给好友2024-04-24正经人王同学
Food-GPT-Yi-model2024-04-21Hubert S
Video tutorials
DeliverableDateAuthor
Run dolphin-2.2-yi-34b on IoT Devices2023-11-30Second State
只需 24G 显存,用 vllm 跑起来 Yi-34B 中英双语大模型2023-12-28漆妮妮
Install Yi 34B Locally - Chinese English Bilingual LLM2023-11-05Fahd Mirza
Dolphin Yi 34b - Brand New Foundational Model TESTED2023-11-27Matthew Berman
Yi-VL-34B 多模态大模型 - 用两张 A40 显卡跑起来2024-01-28漆妮妮
4060Ti 16G显卡安装零一万物最新开源的Yi-1.5版大语言模型2024-05-14titan909
Yi-1.5: True Apache 2.0 Competitor to LLAMA-32024-05-13Prompt Engineering
Install Yi-1.5 Model Locally - Beats Llama 3 in Various Benchmarks2024-05-13Fahd Mirza
how to install Ollama and run Yi 6B2024-05-13Ridaa Davids
地表最强混合智能AI助手:llama3_70B+Yi_34B+Qwen1.5_110B2024-05-04朱扎特
ChatDoc学术论文辅助--基于Yi-34B和langchain进行PDF知识库问答2024-05-03朱扎特
基于Yi-34B的领域知识问答项目演示2024-05-02朱扎特
使用RTX4090+GaLore算法 全参微调Yi-6B大模型2024-03-24小工蚂创始人
无内容审查NSFW大语言模型Yi-34B-Chat蒸馏版测试,RolePlay,《天龙八部》马夫人康敏,本地GPU,CPU运行2024-03-20刘悦的技术博客
无内容审查NSFW大语言模型整合包,Yi-34B-Chat,本地CPU运行,角色扮演潘金莲2024-03-16刘悦的技术博客
量化 Yi-34B-Chat 并在单卡 RTX 4090 使用 vLLM 部署2024-03-05白鸽巢
Yi-VL-34B(5):使用3个3090显卡24G版本,运行Yi-VL-34B模型,支持命令行和web界面方式,理解图片的内容转换成文字2024-02-27fly-iot
Win环境KoboldCpp本地部署大语言模型进行各种角色扮演游戏2024-02-25魚蟲蟲
无需显卡本地部署Yi-34B-Chat进行角色扮演游戏 P22024-02-23魚蟲蟲
【wails】(2):使用go-llama.cpp 运行 yi-01-6b大模型,使用本地CPU运行,速度还可以,等待下一版本更新2024-02-20fly-iot
【xinference】(6):在autodl上,使用xinference部署yi-vl-chat和qwen-vl-chat模型,可以使用openai调用成功2024-02-06fly-iot
无需显卡本地部署Yi-34B-Chat进行角色扮演游戏 P12024-02-05魚蟲蟲
2080Ti部署YI-34B大模型 xinference-oneapi-fastGPT本地知识库使用指南2024-01-30小饭护法要转码
Best Story Writing AI Model - Install Yi 6B 200K Locally on Windows2024-01-22Fahd Mirza
Mac 本地运行大语言模型方法与常见问题指南(Yi 34B 模型+32 GB 内存测试)2024-01-21小吴苹果机器人
【Dify知识库】(11):Dify0.4.9改造支持MySQL,成功接入yi-6b 做对话,本地使用fastchat启动,占8G显存,完成知识库配置2024-01-21fly-iot
这位LLM先生有点暴躁,用的是YI-6B的某个量化版,#LLM #大语言模型 #暴躁老哥2024-01-20晓漫吧
大模型推理 NvLink 桥接器有用吗|双卡 A6000 测试一下2024-01-17漆妮妮
大模型推理 A40 vs A6000 谁更强 - 对比 Yi-34B 的单、双卡推理性能2024-01-15漆妮妮
C-Eval 大语言模型评测基准- 用 LM Evaluation Harness + vLLM 跑起来2024-01-11漆妮妮
双显卡部署 Yi-34B 大模型 - vLLM + Gradio 踩坑记录2024-01-01漆妮妮
手把手教学!使用 vLLM 快速部署 Yi-34B-Chat2023-12-26白鸽巢
如何训练企业自己的大语言模型?Yi-6B LORA微调演示 #小工蚁2023-12-21小工蚂创始人
Yi-34B(4):使用4个2080Ti显卡11G版本,运行Yi-34B模型,5年前老显卡是支持的,可以正常运行,速度 21 words/s2023-12-02fly-iot
使用autodl服务器,RTX 3090 * 3 显卡上运行, Yi-34B-Chat模型,显存占用60G2023-12-01fly-iot
使用autodl服务器,两个3090显卡上运行, Yi-34B-Chat-int4模型,用vllm优化,增加 --num-gpu 2,速度23 words/s2023-12-01fly-iot
Yi大模型一键本地部署 技术小白玩转AI2023-12-01技术小白玩转AI
01.AI's Yi-6B: Overview and Fine-Tuning2023-11-28AI Makerspace
Yi 34B Chat LLM outperforms Llama 70B2023-11-27DLExplorer
How to run open source models on mac Yi 34b on m3 Max2023-11-26TECHNO PREMIUM
Yi-34B - 200K - The BEST & NEW CONTEXT WINDOW KING 2023-11-24Prompt Engineering
Yi 34B : The Rise of Powerful Mid-Sized Models - Base,200k & Chat2023-11-24Sam Witteveen
在IoT设备运行破解版李开复大模型dolphin-2.2-yi-34b(还可作为私有OpenAI API服务器)2023-11-15Second State
Run dolphin-2.2-yi-34b on IoT Devices (Also works as a Private OpenAI API Server)2023-11-14Second State
How to Install Yi 34B 200K Llamafied on Windows Laptop2023-11-11Fahd Mirza
</details>

Why Yi?

Ecosystem

Yi has a comprehensive ecosystem, offering a range of tools, services, and models to enrich your experiences and maximize productivity.

Upstream

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.

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.

from transformers import AutoModelForCausalLM, AutoTokenizer

tokenizer = AutoTokenizer.from_pretrained("01-ai/Yi-34b", use_fast=False)

model = AutoModelForCausalLM.from_pretrained("01-ai/Yi-34b", device_map="auto")
<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Downstream

💡 Tip

Serving

If you want to get up with Yi in a few minutes, you can use the following services built upon Yi.

Quantization

If you have limited computational capabilities, you can use Yi's quantized models as follows.

These quantized models have reduced precision but offer increased efficiency, such as faster inference speed and smaller RAM usage.

Fine-tuning

If you're seeking to explore the diverse capabilities within Yi's thriving family, you can delve into Yi's fine-tuned models as below.

API

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Tech report

For detailed capabilities of the Yi series model, see Yi: Open Foundation Models by 01.AI.

Citation

@misc{ai2024yi,
    title={Yi: Open Foundation Models by 01.AI},
    author={01. AI and : and Alex Young and Bei Chen and Chao Li and Chengen Huang and Ge Zhang and Guanwei Zhang and Heng Li and Jiangcheng Zhu and Jianqun Chen and Jing Chang and Kaidong Yu and Peng Liu and Qiang Liu and Shawn Yue and Senbin Yang and Shiming Yang and Tao Yu and Wen Xie and Wenhao Huang and Xiaohui Hu and Xiaoyi Ren and Xinyao Niu and Pengcheng Nie and Yuchi Xu and Yudong Liu and Yue Wang and Yuxuan Cai and Zhenyu Gu and Zhiyuan Liu and Zonghong Dai},
    year={2024},
    eprint={2403.04652},
    archivePrefix={arXiv},
    primaryClass={cs.CL}
}

Benchmarks

Chat model performance

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.

Chat model performance

<details> <summary> Evaluation methods and challenges. ⬇️ </summary>

<strong>*</strong>: C-Eval results are evaluated on the validation datasets

</details>

Base model performance

Yi-34B and Yi-34B-200K

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.

Base model performance

<details> <summary> Evaluation methods. ⬇️</summary> </details>

Yi-9B

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.

Yi-9B benchmark - details

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Who can use Yi?

Everyone! 🙌 ✅

The code and weights of the Yi series models are distributed under the Apache 2.0 license, which means the Yi series models are free for personal usage, academic purposes, and commercial use.

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Misc.

Acknowledgments

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.

yi contributors

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

Disclaimer

We use data compliance checking algorithms during the training process, to ensure the compliance of the trained model to the best of our ability. Due to complex data and the diversity of language model usage scenarios, we cannot guarantee that the model will generate correct, and reasonable output in all scenarios. Please be aware that there is still a risk of the model producing problematic outputs. We will not be responsible for any risks and issues resulting from misuse, misguidance, illegal usage, and related misinformation, as well as any associated data security concerns.

<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>

License

The code and weights of the Yi-1.5 series models are distributed under the Apache 2.0 license.

If you create derivative works based on this model, please include the following attribution in your derivative works:

This work is a derivative of [The Yi Series Model You Base On] by 01.AI, used under the Apache 2.0 License.
<p align="right"> [ <a href="#top">Back to top ⬆️ </a> ] </p>