From 6fc31bb4cf557b897ae9ab79375beef29419dd0f Mon Sep 17 00:00:00 2001 From: binbin Deng <108676127+plusbang@users.noreply.github.com> Date: Wed, 2 Aug 2023 11:00:56 +0800 Subject: [PATCH] LLM: first update descriptions for ChatGLM transformers int4 example (#8646) --- .../transformers_int4/chatglm/README.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/llm/example/transformers/transformers_int4/chatglm/README.md b/python/llm/example/transformers/transformers_int4/chatglm/README.md index a5b7a1d4..e15f24b0 100644 --- a/python/llm/example/transformers/transformers_int4/chatglm/README.md +++ b/python/llm/example/transformers/transformers_int4/chatglm/README.md @@ -2,15 +2,21 @@ In this directory, you will find examples on how you could apply BigDL-LLM INT4 optimizations on ChatGLM models. For illustration purposes, we utilize the [THUDM/chatglm-6b](https://huggingface.co/THUDM/chatglm-6b) as a reference ChatGLM model. -## 0. Requirements +> **Note**: If you want to download the Hugging Face *Transformers* model, please refer to [here](https://huggingface.co/docs/hub/models-downloading#using-git). +> +> BigDL-LLM optimizes the *Transformers* model in INT4 precision at runtime, so that no explicit conversion is needed. + +## Requirements To run these examples with BigDL-LLM, we have some recommended requirements for your machine, please refer to [here](../README.md#recommended-requirements) for more information. ## Example: Predict Tokens using `generate()` API In the example [generate.py](./generate.py), we show a basic use case for a ChatGLM model to predict the next N tokens using `generate()` API, with BigDL-LLM INT4 optimizations. ### 1. Install -We suggest using conda to manage environment: +We suggest using conda to manage the Python environment. For more information about conda installation, please refer to [here](https://docs.conda.io/en/latest/miniconda.html#). + +After installing conda, create a Python environment for BigDL-LLM: ```bash -conda create -n llm python=3.9 +conda create -n llm python=3.9 # recommend to use Python 3.9 conda activate llm pip install bigdl-llm[all] # install bigdl-llm with 'all' option @@ -26,6 +32,8 @@ Arguments info: - `--prompt PROMPT`: argument defining the prompt to be infered (with integrated prompt format for chat). It is default to be `'AI是什么?'`. - `--n-predict N_PREDICT`: argument defining the max number of tokens to predict. It is default to be `32`. +The expected output can be found in [Sample Output](#23-sample-output) section. + > **Note**: When loading the model in 4-bit, BigDL-LLM converts linear layers in the model into INT4 format. In theory, a *X*B model saved in 16-bit will requires approximately 2*X* GB of memory for loading, and ~0.5*X* GB memory for further inference. > > Please select the appropriate size of the ChatGLM model based on the capabilities of your machine.