example_title: "Yi-34B-Chat"
text: "hi"
output:
text: " Hello! How can I assist you today?"
example_title: "Yi-34B"
text: "There's a place where time stands still. A place of breath taking wonder, but also"
output:
text: " an eerie sense that something is just not right…\nBetween the two worlds lies The Forgotten Kingdom - home to creatures long since thought extinct and ancient magic so strong it defies belief! Only here can you find what has been lost for centuries: An Elixir Of Life which will restore youth and vitality if only those who seek its power are brave enough to face up against all manner of dangers lurking in this mysterious land! But beware; some say there may even exist powerful entities beyond our comprehension whose intentions towards humanity remain unclear at best ---- they might want nothing more than destruction itself rather then anything else from their quest after immortality (and maybe someone should tell them about modern medicine)? In any event though – one thing remains true regardless : whether or not success comes easy depends entirely upon how much effort we put into conquering whatever challenges lie ahead along with having faith deep down inside ourselves too ;) So let’s get started now shall We?"
pipeline_tag: text-generation
new_version: 01-ai/Yi-1.5-6B
specify theme context for images
Building the Next Generation of Open-Source and Bilingual LLMs
🤖 The Yi series models are the next generation of open-source large language models trained from scratch by 01.AI.
🙌 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,
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).
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).
🙏 (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.
If you're interested in Yi's adoption of Llama architecture and license usage policy, see Yi's relation with Llama. ⬇️
💡 TL;DR
The Yi series models adopt the same model architecture as Llama but are NOT derivatives of Llama.
Both Yi and Llama are based on the Transformer structure, which has been the standard architecture for large language models since 2018.
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.
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.
However, the Yi series models are NOT derivatives of Llama, as they do not use Llama's weights.
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.
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.
🔥 2024-07-29: The Yi Cookbook 1.0 is released, featuring tutorials and examples in both Chinese and English.🎯 2024-05-13: The Yi-1.5 series models are open-sourced, further improving coding, math, reasoning, and instruction-following abilities.🎯 2024-03-16: The Yi-9B-200K is open-sourced and available to the public.🎯 2024-03-08: Yi Tech Report is published! 🔔 2024-03-07: The long text capability of the Yi-34B-200K has been enhanced.
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.
🎯 2024-03-06: The Yi-9B is open-sourced and available to the public. 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.
🎯 2024-01-23: The Yi-VL models, [object Object] and [object Object], are open-sourced and available to the public. [object Object] has ranked first among all existing open-source models in the latest benchmarks, including MMMU and CMMMU (based on data available up to January 2024).
🎯 2023-11-23: Chat models are open-sourced and available to the public. 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.
🎯 2023-11-05: The base models, Yi-6B-200K and Yi-34B-200K, are open-sourced and available to the public. This release contains two base models with the same parameter sizes as the previous
release, except that the context window is extended to 200K.
🎯 2023-11-02: The base models, Yi-6B and Yi-34B, are open-sourced and available to the public. 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.
- 4-bit series models are quantized by AWQ. - 8-bit series models are quantized by GPTQ - All quantized models have a low barrier to use since they can be deployed on consumer-grade GPUs (e.g., 3090, 4090).
- 200k is roughly equivalent to 400,000 Chinese characters. - 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.
Model info
For chat and base models
Model
Intro
Default context window
Pretrained tokens
Training Data Date
6B series models
They are suitable for personal and academic use.
4K
3T
Up to June 2023
9B series models
It is the best at coding and math in the Yi series models.
Yi-9B is continuously trained based on Yi-6B, using 0.8T tokens.
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.
3T
For chat models
For chat model limitations, see the explanations below. ⬇️
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.
However, this higher diversity might amplify certain existing issues, including:
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.
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.
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.
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.
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:
You can perform inference with Yi chat or base models as below.
Perform inference with Yi chat model
Create a file named quick_start.py and copy the following content to it.
python
1from transformers import AutoModelForCausalLM, AutoTokenizer
23model_path ='<your-model-path>'45tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)67# Since transformers 4.35.0, the GPT-Q/AWQ model can be loaded using AutoModelForCausalLM.8model = AutoModelForCausalLM.from_pretrained(9 model_path,10 device_map="auto",11 torch_dtype='auto'12).eval()1314# Prompt content: "hi"15messages =[16{"role":"user","content":"hi"}17]1819input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')20output_ids = model.generate(input_ids.to('cuda'))21response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)2223# Model response: "Hello! How can I assist you today?"24print(response)
Run quick_start.py.
python quick_start.py
Then you can see an output similar to the one below. 🥳
Then you can see an output similar to the one below. 🥳
Output. ⬇️
Prompt: Let me tell you an interesting story about cat Tom and mouse Jerry,
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...
Run Yi-34B-chat locally with Docker: a step-by-step guide. ⬇️ This tutorial guides you through every step of running Yi-34B-Chat on an A800 GPU or 4*4090 locally and then performing inference.
Note that the only difference is to set --model <your-model-mount-path>' instead of model <your-model-path>.
Quick start - conda-lock
You can use [object Object] to generate fully reproducible lock files for conda environments. ⬇️
You can refer to conda-lock.yml for the exact versions of the dependencies. Additionally, you can utilize [object Object] for installing these dependencies.
To install the dependencies, follow these steps:
Install micromamba by following the instructions available here.
Execute micromamba install -y -n yi -f conda-lock.yml to create a conda environment named yi and install the necessary dependencies.
Run Yi-chat-6B-2bits locally with llama.cpp: a step-by-step guide. ⬇️ This tutorial guides you through every step of running a quantized model (Yi-chat-6B-2bits) locally and then performing inference.
To compile llama.cpp using 4 threads and then conduct inference, navigate to the llama.cpp directory, and run the following command.
Tips
Replace /Users/yu/yi-chat-6B-GGUF/yi-chat-6b.Q2_K.gguf with the actual path of your model.
By default, the model operates in completion mode.
For additional output customization options (for example, system prompt, temperature, repetition penalty, etc.), run ./main -h to check detailed descriptions and usage.
bash
1make -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
23...
45How do you feed your pet fox? Please answer this question in6 simple steps:
67Step 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.
89Step 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.
1011Step 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.
1213Step 4: Socialize your pet with other animals if possible. Interactions with other creatures can help them develop social skills and prevent boredom or stress.
1415Step 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.
1617Step 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.
1819...
20
Now you have successfully asked a question to the Yi model and got an answer! 🥳
Method 2: Perform inference in web
To initialize a lightweight and swift chatbot, run the following command.
1...
23llama_new_context_with_model: n_ctx =20484llama_new_context_with_model: freq_base =5000000.05llama_new_context_with_model: freq_scale =16ggml_metal_init: allocating
7ggml_metal_init: found device: Apple M2 Pro
8ggml_metal_init: picking default device: Apple M2 Pro
9ggml_metal_init: ggml.metallib not found, loading from source10ggml_metal_init: GGML_METAL_PATH_RESOURCES = nil
11ggml_metal_init: loading '/Users/yu/llama.cpp/ggml-metal.metal'12ggml_metal_init: GPU name: Apple M2 Pro
13ggml_metal_init: GPU family: MTLGPUFamilyApple8 (1008)14ggml_metal_init: hasUnifiedMemory =true15ggml_metal_init: recommendedMaxWorkingSetSize =11453.25 MB
16ggml_metal_init: maxTransferRate = built-in GPU
17ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =128.00 MiB, (2629.44 / 10922.67)18llama_new_context_with_model: KV self size =128.00 MiB, K (f16): 64.00 MiB, V (f16): 64.00 MiB
19ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =0.02 MiB, (2629.45 / 10922.67)20llama_build_graph: non-view tensors processed: 676/676
21llama_new_context_with_model: compute buffer total size =159.19 MiB
22ggml_backend_metal_buffer_type_alloc_buffer: allocated buffer, size =156.02 MiB, (2785.45 / 10922.67)23Available slots:
24-> Slot 0 - max context: 20482526llama server listening at http://0.0.0.0:8080
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
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.
Once finished, you can compare the finetuned model and the base model with the following command:
bash finetune/scripts/run_eval.sh
For advanced usage (like fine-tuning based on your custom data), see the explanations below. ⬇️
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:
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:
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:
If you have any questions while using the Yi series models, the answers provided below could serve as a helpful reference for you. ⬇️
💡Fine-tuning
Base model or Chat model - which to fine-tune? The choice of pre-trained language model for fine-tuning hinges on the computational resources you have at your disposal and the particular demands of your task.
If you are working with a substantial volume of fine-tuning data (say, over 10,000 samples), the Base model could be your go-to choice.
On the other hand, if your fine-tuning data is not quite as extensive, opting for the Chat model might be a more fitting choice.
It is generally advisable to fine-tune both the Base and Chat models, compare their performance, and then pick the model that best aligns with your specific requirements.
Yi-34B versus Yi-34B-Chat for full-scale fine-tuning - what is the difference?
The key distinction between full-scale fine-tuning on Yi-34Band Yi-34B-Chat comes down to the fine-tuning approach and outcomes.
Yi-34B-Chat employs a Special Fine-Tuning (SFT) method, resulting in responses that mirror human conversation style more closely.
The Base model's fine-tuning is more versatile, with a relatively high performance potential.
If you are confident in the quality of your data, fine-tuning with Yi-34B could be your go-to.
If you are aiming for model-generated responses that better mimic human conversational style, or if you have doubts about your data quality, Yi-34B-Chat might be your best bet.
💡Quantization
Quantized model versus original model - what is the performance gap?
The performance variance is largely contingent on the quantization method employed and the specific use cases of these models. For instance, when it comes to models provided by the AWQ official, from a Benchmark standpoint, quantization might result in a minor performance drop of a few percentage points.
Subjectively speaking, in situations like logical reasoning, even a 1% performance shift could impact the accuracy of the output results.
💡General
Where can I source fine-tuning question answering datasets?
You can find fine-tuning question answering datasets on platforms like Hugging Face, with datasets like m-a-p/COIG-CQIA readily available.
Additionally, Github offers fine-tuning frameworks, such as hiyouga/LLaMA-Factory, which integrates pre-made datasets.
What is the GPU memory requirement for fine-tuning Yi-34B FP16?
The GPU memory needed for fine-tuning 34B FP16 hinges on the specific fine-tuning method employed. For full parameter fine-tuning, you'll need 8 GPUs each with 80 GB; however, more economical solutions like Lora require less. For more details, check out hiyouga/LLaMA-Factory. Also, consider using BF16 instead of FP16 for fine-tuning to optimize performance.
Are there any third-party platforms that support chat functionality for the Yi-34b-200k model?
If you're looking for third-party Chats, options include fireworks.ai.
Learning hub
If you want to learn Yi, you can find a wealth of helpful educational resources here. ⬇️
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! 🥳
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.
Yi-34B-Chat | Yi Platform: Note that currently it's available through a whitelist. Welcome to apply (fill out a form in English or Chinese) and experience it firsthand!
Yi-6B-Chat (Replicate): you can use this model with more options by setting additional parameters and calling APIs.
ScaleLLM: you can use this service to run Yi models locally with added flexibility and customization.
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.
SUSTech/SUS-Chat-34B: this model ranked first among all models below 70B and outperformed the twice larger deepseek-llm-67b-chat. You can check the result on the Open LLM Leaderboard.
@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}
}
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
Evaluation methods and challenges. ⬇️
Evaluation methods: we evaluated various benchmarks using both zero-shot and few-shot methods, except for TruthfulQA.
Zero-shot vs. few-shot: in chat models, the zero-shot approach is more commonly employed.
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.
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.
*: C-Eval results are evaluated on the validation datasets
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
Evaluation methods. ⬇️
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.
Investigation findings: a deeper investigation reveals that variations in prompts, post-processing strategies, and sampling techniques across models may lead to significant outcome differences.
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.
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.
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.
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".
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.
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
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.
Yi-9B benchmark - overall
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.
Yi-9B benchmark - code
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.
Yi-9B benchmark - math
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.
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.
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.
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.