初始化项目,由ModelHub XC社区提供模型

Model: RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-07-20 04:18:09 +08:00
commit 4b0f009157
24 changed files with 507 additions and 0 deletions

57
.gitattributes vendored Normal file
View File

@@ -0,0 +1,57 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q2_K.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.IQ3_XS.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.IQ3_S.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q3_K_S.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.IQ3_M.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q3_K.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q3_K_L.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.IQ4_XS.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q4_0.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.IQ4_NL.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q4_K.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q4_1.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q5_0.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q5_K.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q5_1.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
internlm2-chat-1_8b-sft.Q8_0.gguf filter=lfs diff=lfs merge=lfs -text

384
README.md Normal file
View File

@@ -0,0 +1,384 @@
Quantization made by Richard Erkhov.
[Github](https://github.com/RichardErkhov)
[Discord](https://discord.gg/pvy7H8DZMG)
[Request more models](https://github.com/RichardErkhov/quant_request)
internlm2-chat-1_8b-sft - GGUF
- Model creator: https://huggingface.co/internlm/
- Original model: https://huggingface.co/internlm/internlm2-chat-1_8b-sft/
| Name | Quant method | Size |
| ---- | ---- | ---- |
| [internlm2-chat-1_8b-sft.Q2_K.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q2_K.gguf) | Q2_K | 0.72GB |
| [internlm2-chat-1_8b-sft.IQ3_XS.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.IQ3_XS.gguf) | IQ3_XS | 0.79GB |
| [internlm2-chat-1_8b-sft.IQ3_S.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.IQ3_S.gguf) | IQ3_S | 0.83GB |
| [internlm2-chat-1_8b-sft.Q3_K_S.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q3_K_S.gguf) | Q3_K_S | 0.83GB |
| [internlm2-chat-1_8b-sft.IQ3_M.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.IQ3_M.gguf) | IQ3_M | 0.85GB |
| [internlm2-chat-1_8b-sft.Q3_K.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q3_K.gguf) | Q3_K | 0.9GB |
| [internlm2-chat-1_8b-sft.Q3_K_M.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q3_K_M.gguf) | Q3_K_M | 0.9GB |
| [internlm2-chat-1_8b-sft.Q3_K_L.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q3_K_L.gguf) | Q3_K_L | 0.96GB |
| [internlm2-chat-1_8b-sft.IQ4_XS.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.IQ4_XS.gguf) | IQ4_XS | 1.0GB |
| [internlm2-chat-1_8b-sft.Q4_0.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q4_0.gguf) | Q4_0 | 1.04GB |
| [internlm2-chat-1_8b-sft.IQ4_NL.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.IQ4_NL.gguf) | IQ4_NL | 1.04GB |
| [internlm2-chat-1_8b-sft.Q4_K_S.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q4_K_S.gguf) | Q4_K_S | 1.04GB |
| [internlm2-chat-1_8b-sft.Q4_K.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q4_K.gguf) | Q4_K | 1.09GB |
| [internlm2-chat-1_8b-sft.Q4_K_M.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q4_K_M.gguf) | Q4_K_M | 1.09GB |
| [internlm2-chat-1_8b-sft.Q4_1.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q4_1.gguf) | Q4_1 | 1.14GB |
| [internlm2-chat-1_8b-sft.Q5_0.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q5_0.gguf) | Q5_0 | 1.24GB |
| [internlm2-chat-1_8b-sft.Q5_K_S.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q5_K_S.gguf) | Q5_K_S | 1.24GB |
| [internlm2-chat-1_8b-sft.Q5_K.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q5_K.gguf) | Q5_K | 1.26GB |
| [internlm2-chat-1_8b-sft.Q5_K_M.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q5_K_M.gguf) | Q5_K_M | 1.26GB |
| [internlm2-chat-1_8b-sft.Q5_1.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q5_1.gguf) | Q5_1 | 1.33GB |
| [internlm2-chat-1_8b-sft.Q6_K.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q6_K.gguf) | Q6_K | 1.45GB |
| [internlm2-chat-1_8b-sft.Q8_0.gguf](https://huggingface.co/RichardErkhov/internlm_-_internlm2-chat-1_8b-sft-gguf/blob/main/internlm2-chat-1_8b-sft.Q8_0.gguf) | Q8_0 | 1.87GB |
Original model description:
---
pipeline_tag: text-generation
license: other
---
# InternLM
<div align="center">
<img src="https://github.com/InternLM/InternLM/assets/22529082/b9788105-8892-4398-8b47-b513a292378e" width="200"/>
<div>&nbsp;</div>
<div align="center">
<b><font size="5">InternLM</font></b>
<sup>
<a href="https://internlm.intern-ai.org.cn/">
<i><font size="4">HOT</font></i>
</a>
</sup>
<div>&nbsp;</div>
</div>
[![evaluation](https://github.com/InternLM/InternLM/assets/22529082/f80a2a58-5ddf-471a-8da4-32ab65c8fd3b)](https://github.com/internLM/OpenCompass/)
[💻Github Repo](https://github.com/InternLM/InternLM) • [🤔Reporting Issues](https://github.com/InternLM/InternLM/issues/new) • [📜Technical Report](https://arxiv.org/abs/2403.17297)
</div>
## Introduction
InternLM2-1.8B is the 1.8 billion parameter version of the second generation InternLM series. In order to facilitate user use and research, InternLM2-1.8B has three versions of open-source models. They are:
- InternLM2-1.8B: Foundation models with high quality and high adaptation flexibility, which serve as a good starting point for downstream deep adaptations.
- InternLM2-Chat-1.8B-SFT: Chat model after supervised fine-tuning (SFT) on InternLM2-1.8B.
- InternLM2-Chat-1.8B: Further aligned on top of InternLM2-Chat-1.8B-SFT through online RLHF. InternLM2-Chat-1.8B exhibits better instruction following, chat experience, and function calling, which is recommended for downstream applications.
The InternLM2 has the following technical features:
- Effective support for ultra-long contexts of up to 200,000 characters: The model nearly perfectly achieves "finding a needle in a haystack" in long inputs of 200,000 characters. It also leads among open-source models in performance on long-text tasks such as LongBench and L-Eval.
- Comprehensive performance enhancement: Compared to the previous generation model, it shows significant improvements in various capabilities, including reasoning, mathematics, and coding.
## InternLM2-1.8B
### Performance Evaluation
We have evaluated InternLM2 on several important benchmarks using the open-source evaluation tool [OpenCompass](https://github.com/open-compass/opencompass). Some of the evaluation results are shown in the table below. You are welcome to visit the [OpenCompass Leaderboard](https://opencompass.org.cn/rank) for more evaluation results.
| Dataset\Models | InternLM2-1.8B | InternLM2-Chat-1.8B-SFT | InternLM2-7B | InternLM2-Chat-7B |
| :---: | :---: | :---: | :---: | :---: |
| MMLU | 46.9 | 47.1 | 65.8 | 63.7 |
| AGIEval | 33.4 | 38.8 | 49.9 | 47.2 |
| BBH | 37.5 | 35.2 | 65.0 | 61.2 |
| GSM8K | 31.2 | 39.7 | 70.8 | 70.7 |
| MATH | 5.6 | 11.8 | 20.2 | 23.0 |
| HumanEval | 25.0 | 32.9 | 43.3 | 59.8 |
| MBPP(Sanitized) | 22.2 | 23.2 | 51.8 | 51.4 |
- The evaluation results were obtained from [OpenCompass](https://github.com/open-compass/opencompass) , and evaluation configuration can be found in the configuration files provided by [OpenCompass](https://github.com/open-compass/opencompass).
- The evaluation data may have numerical differences due to the version iteration of [OpenCompass](https://github.com/open-compass/opencompass), so please refer to the latest evaluation results of [OpenCompass](https://github.com/open-compass/opencompass).
**Limitations:** Although we have made efforts to ensure the safety of the model during the training process and to encourage the model to generate text that complies with ethical and legal requirements, the model may still produce unexpected outputs due to its size and probabilistic generation paradigm. For example, the generated responses may contain biases, discrimination, or other harmful content. Please do not propagate such content. We are not responsible for any consequences resulting from the dissemination of harmful information.
### Import from Transformers
To load the InternLM2 1.8B Chat SFT model using Transformers, use the following code:
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-chat-1_8b-sft", trust_remote_code=True)
# Set `torch_dtype=torch.float16` to load model in float16, otherwise it will be loaded as float32 and cause OOM Error.
model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-chat-1_8b-sft", torch_dtype=torch.float16, trust_remote_code=True).cuda()
model = model.eval()
response, history = model.chat(tokenizer, "hello", history=[])
print(response)
# Hello! How can I help you today?
response, history = model.chat(tokenizer, "please provide three suggestions about time management", history=history)
print(response)
```
The responses can be streamed using `stream_chat`:
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "internlm/internlm2-chat-1_8b-sft"
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=torch.float16, trust_remote_code=True).cuda()
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = model.eval()
length = 0
for response, history in model.stream_chat(tokenizer, "Hello", history=[]):
print(response[length:], flush=True, end="")
length = len(response)
```
## Deployment
### LMDeploy
LMDeploy is a toolkit for compressing, deploying, and serving LLM, developed by the MMRazor and MMDeploy teams.
```bash
pip install lmdeploy
```
You can run batch inference locally with the following python code:
```python
import lmdeploy
pipe = lmdeploy.pipeline("internlm/internlm2-chat-1_8b-sft")
response = pipe(["Hi, pls intro yourself", "Shanghai is"])
print(response)
```
Or you can launch an OpenAI compatible server with the following command:
```bash
lmdeploy serve api_server internlm/internlm2-chat-1_8b-sft --model-name internlm2-chat-1_8b-sft --server-port 23333
```
Then you can send a chat request to the server:
```bash
curl http://localhost:23333/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "internlm2-chat-1_8b-sft",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Introduce deep learning to me."}
]
}'
```
Find more details in the [LMDeploy documentation](https://lmdeploy.readthedocs.io/en/latest/)
### vLLM
Launch OpenAI compatible server with `vLLM>=0.3.2`:
```bash
pip install vllm
```
```bash
python -m vllm.entrypoints.openai.api_server --model internlm/internlm2-chat-1_8b-sft --served-model-name internlm2-chat-1_8b-sft --trust-remote-code
```
Then you can send a chat request to the server:
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "internlm2-chat-1_8b-sft",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Introduce deep learning to me."}
]
}'
```
Find more details in the [vLLM documentation](https://docs.vllm.ai/en/latest/index.html)
## Open Source License
The code is licensed under Apache-2.0, while model weights are fully open for academic research and also allow **free** commercial usage. To apply for a commercial license, please fill in the [application form (English)](https://wj.qq.com/s2/12727483/5dba/)/[申请表(中文)](https://wj.qq.com/s2/12725412/f7c1/). For other questions or collaborations, please contact <internlm@pjlab.org.cn>.
## Citation
```
@misc{cai2024internlm2,
title={InternLM2 Technical Report},
author={Zheng Cai and Maosong Cao and Haojiong Chen and Kai Chen and Keyu Chen and Xin Chen and Xun Chen and Zehui Chen and Zhi Chen and Pei Chu and Xiaoyi Dong and Haodong Duan and Qi Fan and Zhaoye Fei and Yang Gao and Jiaye Ge and Chenya Gu and Yuzhe Gu and Tao Gui and Aijia Guo and Qipeng Guo and Conghui He and Yingfan Hu and Ting Huang and Tao Jiang and Penglong Jiao and Zhenjiang Jin and Zhikai Lei and Jiaxing Li and Jingwen Li and Linyang Li and Shuaibin Li and Wei Li and Yining Li and Hongwei Liu and Jiangning Liu and Jiawei Hong and Kaiwen Liu and Kuikun Liu and Xiaoran Liu and Chengqi Lv and Haijun Lv and Kai Lv and Li Ma and Runyuan Ma and Zerun Ma and Wenchang Ning and Linke Ouyang and Jiantao Qiu and Yuan Qu and Fukai Shang and Yunfan Shao and Demin Song and Zifan Song and Zhihao Sui and Peng Sun and Yu Sun and Huanze Tang and Bin Wang and Guoteng Wang and Jiaqi Wang and Jiayu Wang and Rui Wang and Yudong Wang and Ziyi Wang and Xingjian Wei and Qizhen Weng and Fan Wu and Yingtong Xiong and Chao Xu and Ruiliang Xu and Hang Yan and Yirong Yan and Xiaogui Yang and Haochen Ye and Huaiyuan Ying and Jia Yu and Jing Yu and Yuhang Zang and Chuyu Zhang and Li Zhang and Pan Zhang and Peng Zhang and Ruijie Zhang and Shuo Zhang and Songyang Zhang and Wenjian Zhang and Wenwei Zhang and Xingcheng Zhang and Xinyue Zhang and Hui Zhao and Qian Zhao and Xiaomeng Zhao and Fengzhe Zhou and Zaida Zhou and Jingming Zhuo and Yicheng Zou and Xipeng Qiu and Yu Qiao and Dahua Lin},
year={2024},
eprint={2403.17297},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```
## 简介
书生·浦语-1.8B (InternLM2-1.8B) 是第二代浦语模型系列的18亿参数版本。为了方便用户使用和研究书生·浦语-1.8B (InternLM2-1.8B) 共有三个版本的开源模型,他们分别是:
- InternLM2-1.8B: 具有高质量和高适应灵活性的基础模型,为下游深度适应提供了良好的起点。
- InternLM2-Chat-1.8B-SFT在 InternLM2-1.8B 上进行监督微调 (SFT) 后得到的对话模型。
- InternLM2-chat-1.8B:通过在线 RLHF 在 InternLM2-Chat-1.8B-SFT 之上进一步对齐。 InternLM2-Chat-1.8B 表现出更好的指令跟随、聊天体验和函数调用,推荐下游应用程序使用。
InternLM2 模型具备以下的技术特点
- 有效支持20万字超长上下文模型在20万字长输入中几乎完美地实现长文“大海捞针”而且在 LongBench 和 L-Eval 等长文任务中的表现也达到开源模型中的领先水平。
- 综合性能全面提升:各能力维度相比上一代模型全面进步,在推理、数学、代码等方面的能力提升显著。
## InternLM2-1.8B
### 性能评测
我们使用开源评测工具 [OpenCompass](https://github.com/internLM/OpenCompass/) 对 InternLM2 在几个重要的评测集进行了评测 ,部分评测结果如下表所示,欢迎访问[ OpenCompass 榜单 ](https://opencompass.org.cn/rank)获取更多的评测结果。
| 评测集 | InternLM2-1.8B | InternLM2-Chat-1.8B-SFT | InternLM2-7B | InternLM2-Chat-7B |
| :---: | :---: | :---: | :---: | :---: |
| MMLU | 46.9 | 47.1 | 65.8 | 63.7 |
| AGIEval | 33.4 | 38.8 | 49.9 | 47.2 |
| BBH | 37.5 | 35.2 | 65.0 | 61.2 |
| GSM8K | 31.2 | 39.7 | 70.8 | 70.7 |
| MATH | 5.6 | 11.8 | 20.2 | 23.0 |
| HumanEval | 25.0 | 32.9 | 43.3 | 59.8 |
| MBPP(Sanitized) | 22.2 | 23.2 | 51.8 | 51.4 |
- 以上评测结果基于 [OpenCompass](https://github.com/open-compass/opencompass) 获得(部分数据标注`*`代表数据来自原始论文),具体测试细节可参见 [OpenCompass](https://github.com/open-compass/opencompass) 中提供的配置文件。
- 评测数据会因 [OpenCompass](https://github.com/open-compass/opencompass) 的版本迭代而存在数值差异,请以 [OpenCompass](https://github.com/open-compass/opencompass) 最新版的评测结果为主。
**局限性:** 尽管在训练过程中我们非常注重模型的安全性,尽力促使模型输出符合伦理和法律要求的文本,但受限于模型大小以及概率生成范式,模型可能会产生各种不符合预期的输出,例如回复内容包含偏见、歧视等有害内容,请勿传播这些内容。由于传播不良信息导致的任何后果,本项目不承担责任。
### 通过 Transformers 加载
通过以下的代码加载 InternLM2 1.8B Chat SFT 模型
```python
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm2-chat-1_8b-sft", trust_remote_code=True)
# `torch_dtype=torch.float16` 可以令模型以 float16 精度加载,否则 transformers 会将模型加载为 float32导致显存不足
model = AutoModelForCausalLM.from_pretrained("internlm/internlm2-chat-1_8b-sft", torch_dtype=torch.float16, trust_remote_code=True).cuda()
model = model.eval()
response, history = model.chat(tokenizer, "你好", history=[])
print(response)
# 你好!有什么我可以帮助你的吗?
response, history = model.chat(tokenizer, "请提供三个管理时间的建议。", history=history)
print(response)
```
如果想进行流式生成,则可以使用 `stream_chat` 接口:
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "internlm/internlm2-chat-1_8b-sft"
model = AutoModelForCausalLM.from_pretrained(model_path, torch_dype=torch.float16, trust_remote_code=True).cuda()
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
model = model.eval()
length = 0
for response, history in model.stream_chat(tokenizer, "你好", history=[]):
print(response[length:], flush=True, end="")
length = len(response)
```
## 部署
### LMDeploy
LMDeploy 由 MMDeploy 和 MMRazor 团队联合开发,是涵盖了 LLM 任务的全套轻量化、部署和服务解决方案。
```bash
pip install lmdeploy
```
你可以使用以下 python 代码进行本地批量推理:
```python
import lmdeploy
pipe = lmdeploy.pipeline("internlm/internlm2-chat-1_8b-sft")
response = pipe(["Hi, pls intro yourself", "Shanghai is"])
print(response)
```
或者你可以使用以下命令启动兼容 OpenAI API 的服务:
```bash
lmdeploy serve api_server internlm/internlm2-chat-1_8b-sft --server-port 23333
```
然后你可以向服务端发起一个聊天请求:
```bash
curl http://localhost:23333/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "internlm2-chat-1_8b-sft",
"messages": [
{"role": "system", "content": "你是个友善的AI助手。"},
{"role": "user", "content": "介绍一下深度学习。"}
]
}'
```
更多信息请查看 [LMDeploy 文档](https://lmdeploy.readthedocs.io/en/latest/)
### vLLM
使用`vLLM>=0.3.2`启动兼容 OpenAI API 的服务:
```bash
pip install vllm
```
```bash
python -m vllm.entrypoints.openai.api_server --model internlm/internlm2-chat-1_8b-sft --trust-remote-code
```
然后你可以向服务端发起一个聊天请求:
```bash
curl http://localhost:8000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "internlm2-chat-1_8b-sft",
"messages": [
{"role": "system", "content": "你是个友善的AI助手。"},
{"role": "user", "content": "介绍一下深度学习。"}
]
}'
```
更多信息请查看 [vLLM 文档](https://docs.vllm.ai/en/latest/index.html)
## 开源许可证
本仓库的代码依照 Apache-2.0 协议开源。模型权重对学术研究完全开放,也可申请免费的商业使用授权([申请表](https://wj.qq.com/s2/12725412/f7c1/))。其他问题与合作请联系 <internlm@pjlab.org.cn>
## 引用
```
@misc{cai2024internlm2,
title={InternLM2 Technical Report},
author={Zheng Cai and Maosong Cao and Haojiong Chen and Kai Chen and Keyu Chen and Xin Chen and Xun Chen and Zehui Chen and Zhi Chen and Pei Chu and Xiaoyi Dong and Haodong Duan and Qi Fan and Zhaoye Fei and Yang Gao and Jiaye Ge and Chenya Gu and Yuzhe Gu and Tao Gui and Aijia Guo and Qipeng Guo and Conghui He and Yingfan Hu and Ting Huang and Tao Jiang and Penglong Jiao and Zhenjiang Jin and Zhikai Lei and Jiaxing Li and Jingwen Li and Linyang Li and Shuaibin Li and Wei Li and Yining Li and Hongwei Liu and Jiangning Liu and Jiawei Hong and Kaiwen Liu and Kuikun Liu and Xiaoran Liu and Chengqi Lv and Haijun Lv and Kai Lv and Li Ma and Runyuan Ma and Zerun Ma and Wenchang Ning and Linke Ouyang and Jiantao Qiu and Yuan Qu and Fukai Shang and Yunfan Shao and Demin Song and Zifan Song and Zhihao Sui and Peng Sun and Yu Sun and Huanze Tang and Bin Wang and Guoteng Wang and Jiaqi Wang and Jiayu Wang and Rui Wang and Yudong Wang and Ziyi Wang and Xingjian Wei and Qizhen Weng and Fan Wu and Yingtong Xiong and Chao Xu and Ruiliang Xu and Hang Yan and Yirong Yan and Xiaogui Yang and Haochen Ye and Huaiyuan Ying and Jia Yu and Jing Yu and Yuhang Zang and Chuyu Zhang and Li Zhang and Pan Zhang and Peng Zhang and Ruijie Zhang and Shuo Zhang and Songyang Zhang and Wenjian Zhang and Wenwei Zhang and Xingcheng Zhang and Xinyue Zhang and Hui Zhao and Qian Zhao and Xiaomeng Zhao and Fengzhe Zhou and Zaida Zhou and Jingming Zhuo and Yicheng Zou and Xipeng Qiu and Yu Qiao and Dahua Lin},
year={2024},
eprint={2403.17297},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
```

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:8ef8e9445dc387a9a7beaf895aabcf75867257ffbddb305551223621692cdb7c
size 914997920

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fe0bc1e678abcd8ac8d581eb8064071655814eb0295d61ecea2573d290eb5bf1
size 888259232

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:259604cf4ab7da2e514f75f0c535611f8ec2c8a2a7e203094bde2318a53c0de2
size 852869792

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:63b48acf49ba06d076681040d485c688d39aadcd026389d8646e24f41df24579
size 1120262816

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2c14bc7aff71d89bd234a7c0d8babace6a0a541f04e152c18b984a681164ec40
size 1068726944

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b0bbcf0f5a198dee8bd22785ad860d03ad9a74c5305d063a7360b214e4ce7e4d
size 771885728

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:63a067d0f5479cc05215929e705a5c93274656bf84ff85c944aa703fecf25ce8
size 964412064

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:f2645ffc6ab4c1fedc5e3fdf751204aa1b6265e2bcdd64ac170e3e08d514c016
size 1030996640

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:63a067d0f5479cc05215929e705a5c93274656bf84ff85c944aa703fecf25ce8
size 964412064

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b1ac67a3a3dc969d84d51eebfaab9c1f1d91df2de638b2f4a29272cda2d23642
size 888259232

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:19239e6a04f7080d57c0f371cc020977b3527ac29c0d36bf221b9cde924aa96c
size 1113971360

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:066dedfb5f5d70c1cc512a7256a4f0a5bca20ecfd22f43ad3af503d6ba8984a7
size 1220188832

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:700064da49e99f88d9b84e5fd18e841609f6a30335d487acca5cbe182bb86af7
size 1172363936

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:700064da49e99f88d9b84e5fd18e841609f6a30335d487acca5cbe182bb86af7
size 1172363936

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ad332ca181bdb08f7b2b5360422b107a90197c931739650c0162173ae149c03e
size 1121311392

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b91dae2ff50fe91e33d18850dfd7292f812a86634b52cf4e9ad05042f32b83bf
size 1326406304

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:2fce97653f06c9d5702525e351321aadc5f559e9d23453bf2369415850c49c12
size 1432623776

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:94e6e2c084177609726d8563b5b0114e8c2a9b9427d757fb10807c6a0ea0925b
size 1356487328

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:94e6e2c084177609726d8563b5b0114e8c2a9b9427d757fb10807c6a0ea0925b
size 1356487328

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:127ff4754c557cdcc09e0ff3228706f4724dc3636a9c67111e5acb0ffded119e
size 1326406304

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a0a572753a553c61fb21ff5d171ca7bc1edf1b4385f0b4e76b5456d34c6cd06e
size 1552118432

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:84b6f4733ec0fb84a407deab24d045f3c8cff37d2adcbd0faa125ac5e21d267d
size 2009612960