---
title: internlm2-chat-20b-4bits
canonical_url: "https://www.modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-chat-20b-4bits"
md_url: "https://www.modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-chat-20b-4bits.md"
repository: Shanghai_AI_Laboratory/internlm2-chat-20b-4bits
last_updated: 2025-02-26
license: apache-2.0
pipeline_tag: text-generation
tasks:
  - text-generation
model_type:
  - internlm
architectures:
  - InternLM2ForCausalLM
library_name:
  - pytorch
frameworks:
  - Pytorch
inference_backends:
  - "deploy_task text/emb"
  - "lmdeploy 0.9.1"
  - "lmdeploy_turbomind 0.9.1"
  - "sglang 0.5.2"
  - "vllm 0.9.2"
downloads: 1301
stars: 0
---

# internlm2-chat-20b-4bits

> internlm2-chat-20b-4bits - Shanghai_AI_Laboratory 在 ModelScope 开源的模型。INT4 Weight-only Quantization and Deployment (W4A16)

Shanghai_AI_Laboratory/internlm2-chat-20b-4bits 是 ModelScope 魔搭社区上的text-generation模型，采用 apache-2.0 许可，可用 deploy_task text/emb、lmdeploy 0.9.1、lmdeploy_turbomind 0.9.1 部署。

- **Repository**: Shanghai_AI_Laboratory/internlm2-chat-20b-4bits
- **License**: apache-2.0
- **Tasks**: text-generation
- **Inference backends**: deploy_task text/emb, lmdeploy 0.9.1, lmdeploy_turbomind 0.9.1, sglang 0.5.2, vllm 0.9.2
- **Downloads**: 1301
- **Stars**: 0
- **Last updated**: 2025-02-26

Source: https://www.modelscope.cn/models/Shanghai_AI_Laboratory/internlm2-chat-20b-4bits

---

<div align="center">
  <img src="https://raw.githubusercontent.com/InternLM/lmdeploy/0be9e7ab6fe9a066cfb0a09d0e0c8d2e28435e58/resources/lmdeploy-logo.svg" width="450"/>
</div>

# INT4 Weight-only Quantization and Deployment (W4A16)

LMDeploy adopts [AWQ](https://arxiv.org/abs/2306.00978) algorithm for 4bit weight-only quantization. By developed the high-performance cuda kernel, the 4bit quantized model inference achieves up to 2.4x faster than FP16.

LMDeploy supports the following NVIDIA GPU for W4A16 inference:

- Turing(sm75): 20 series, T4

- Ampere(sm80,sm86): 30 series, A10, A16, A30, A100

- Ada Lovelace(sm90): 40 series

Before proceeding with the quantization and inference, please ensure that lmdeploy is installed.

```shell
pip install lmdeploy[all]
```

This article comprises the following sections:

<!-- toc -->

- [Inference](#inference)
- [Evaluation](#evaluation)
- [Service](#service)

<!-- tocstop -->
## Inference

Trying the following codes, you can perform the batched offline inference with the quantized model:

```python
from lmdeploy import pipeline, TurbomindEngineConfig
engine_config = TurbomindEngineConfig(model_format='awq')
pipe = pipeline("internlm/internlm2-chat-20b-4bits", backend_config=engine_config)
response = pipe(["Hi, pls intro yourself", "Shanghai is"])
print(response)
```

For more information about the pipeline parameters, please refer to [here](https://github.com/InternLM/lmdeploy/blob/main/docs/en/inference/pipeline.md).

## Evaluation

Please overview [this guide](https://opencompass.readthedocs.io/en/latest/advanced_guides/evaluation_turbomind.html) about model evaluation with LMDeploy.

## Service

LMDeploy's `api_server` enables models to be easily packed into services with a single command. The provided RESTful APIs are compatible with OpenAI's interfaces. Below are an example of service startup:

```shell
lmdeploy serve api_server internlm/internlm2-chat-20b-4bits --backend turbomind --model-format awq
```

The default port of `api_server` is `23333`. After the server is launched, you can communicate with server on terminal through `api_client`:

```shell
lmdeploy serve api_client http://0.0.0.0:23333
```

You can overview and try out `api_server` APIs online by swagger UI at `http://0.0.0.0:23333`, or you can also read the API specification from [here](https://github.com/InternLM/lmdeploy/blob/main/docs/en/serving/restful_api.md).
