InternLM2(书生·浦语2) 2
InternLM系列 · 上海人工智能实验室 · 2024-01发布
模型介绍
上海 AI 实验室开源的 InternLM2,多语言与工具能力平衡,多尺寸含轻量版,配套书生 Community 生态。
模型基础信息
免费额度与收费政策
免费规则详情
Apache-2.0 可商用。
收费标准简介
本地零成本。
模型能力介绍
✅ 核心优势
- 中文强
- 多模态
- 工具调用
- pache 商用
⚠️ 短板与局限
- 生态较新
- 尺寸有限
- 英文一般
🎯 适用场景
- 中文 Agent
- 多模态应用
- 本地部署
- 教育
模型使用教程
本章节整理 InternLM2(书生·浦语2) 的在线体验、API调用、本地部署全套入门教程,快速上手使用该模型。
- 本地体验:
ollama run internlm2或 Transformers / vLLM 加载。 - 云端:HF 托管模型可在线体验。
ollama run internlm2 "用中文介绍一下InternLM2(书生·浦语2)"
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download 上海人工智能实验室/InternLM2 --local-dir ./internlm2
或 ModelScope 国内直连下载。
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained('上海人工智能实验室/InternLM2')
tok = AutoTokenizer.from_pretrained('上海人工智能实验室/InternLM2')
code = tok.apply_chat_template([{'role':'user','content':'你好'}], tokenize=False)
print(model.generate(**tok(code, return_tensors='pt')))
InternLM2 是上海 AI 实验室开源的中文大模型(1.8B~20B),与 LMDeploy 深度适配,本地中文友好。
- LMDeploy 部署(推荐):
pip install lmdeploy && lmdeploy serve internlm/internlm2_5-7b-chat
- vLLM:
vllm serve internlm/internlm2_5-7b-chat --trust-remote-code --port 8000
- transformers 加载:
python -c "from transformers import AutoModelForCausalLM, AutoTokenizer; m=AutoModelForCausalLM.from_pretrained('internlm/internlm2_5-7b-chat', trust_remote_code=True, torch_dtype='float16').cuda(); t=AutoTokenizer.from_pretrained('internlm/internlm2_5-7b-chat', trust_remote_code=True); print(t.decode(m.generate(t('介绍一下自己', return_tensors='pt').to('cuda'), max_new_tokens=64)[0], skip_special_tokens=True))"
Tips:20B 需要 40GB 显存;1.8B 量化后端侧/低配也能跑。
💡 使用小技巧
书生生态文档丰富。
❓ 常见问题 FAQ
Q1:InternLM2 特点?\nA1:中文与工具能力平衡。
访问备注与注意事项
- ModelScope 可下
Aitishiku.com