InternLM

开箱即用的中文大模型,从预训练到部署全流程搞定

InternLM 是由上海人工智能实验室开源的大型语言模型系列,涵盖 InternLM、InternLM2、InternLM2.5 和 InternLM3 等多个版本。该项目旨在提供高性能、可商用的大模型基座,解决中文场景下的自然语言理解与生成问题。核心能力包括模型预训练、微调、RLHF 对齐、长上下文支持(如 1M token)以及高效的 FlashAttention 加速。项目提供了完整的模型权重、训练代码和推理工具,支持从学术研究到工业落地的全流程。其模型在中文理解、数学推理和代码生成等任务上表现优异,且针对国产硬件和部署场景做了优化。通过开源,项目降低了大模型的使用门槛,开发者可以基于其进行二次开发或直接部署。

开源 free 对话助手
访问官网 ↗ GitHub ↗ 文档 ↗
GitHub 星标 ★ 7279
维护状态 低维护
是否开源 是
定价模式 free

项目数据

分类对话助手
开发团队InternLM
所属国家
官网地址
定价模式free
价格说明开源模型,Apache-2.0许可,可免费下载使用,无在线服务。
访问状态
是否开源是
开源协议Apache-2.0
主要语言Python
技术栈/模型chatbot,chinese,fine-tuning-llm,flash-attention,gpt,large-language-model,llm,long-context,pretrained-models,rlhf
GitHub 星标★ 7279
30天Star增速
HF 下载量
上线时间2023-07-06 00:00:00
最近更新2026-09-22 00:00:00
维护状态低维护
中文支持
访问方式
移动端支持
综合评分
收录时间2026-08-09
浏览次数3

使用教程

难度:进阶 约 30 分钟 部署方式:本地安装 6 步

环境要求

  • Python 环境(用于运行 LMDeploy / Ollama 的 Python 调用代码)
  • 已安装 pip,可执行 pip install
  • 能够访问 HuggingFace 下载 internlm/internlm3-8b-instruct 模型权重
  • 若使用 Ollama 方案,需先安装 Ollama 运行时

安装与启动步骤

  1. 1安装 LMDeploy

    LMDeploy 是官方推荐的压缩、部署与服务化工具包,用一条 pip 命令安装即可,建议在独立虚拟环境中执行。

    pip install lmdeploy
  2. 2本地批量推理

    用 LMDeploy 的 pipeline 直接加载模型并提问,脚本会自动从 HuggingFace 拉取权重,首次运行需等待下载完成。

    import lmdeploy
    model_dir = "internlm/internlm3-8b-instruct"
    pipe = lmdeploy.pipeline(model_dir)
    response = pipe("Please tell me five scenic spots in Shanghai")
    print(response)
  3. 3启动兼容 API 服务

    启动 OpenAI 兼容的推理服务,--model-name 用于指定请求时使用的模型名,--server-port 指定监听端口。

    lmdeploy serve api_server internlm/internlm3-8b-instruct --model-name internlm3-8b-instruct --server-port 23333
  4. 4发起对话请求

    服务启动后,用 curl 向本地 23333 端口发送 chat/completions 请求,注意 model 字段要与启动时的 --model-name 保持一致。

    curl http://localhost:23333/v1/chat/completions 
        -H "Content-Type: application/json" 
        -d '{
        "model": "internlm3-8b-instruct",
        "messages": [
        {"role": "user", "content": "Please tell me five scenic spots in Shanghai"}
        ]
        }'
  5. 5安装 Ollama 方案

    另一种更轻量的本地运行方式:先用官方脚本安装 Ollama,再安装 ollama 的 Python 客户端库。

    curl -fsSL https://ollama.com/install.sh | sh
    pip install ollama
  6. 6Ollama 流式推理

    通过 ollama.chat 指定 model 为 internlm/internlm3-8b-instruct,开启 stream 逐块打印模型回复内容。

    import ollama
    
    system_prompt = """You are an AI assistant whose name is InternLM (书生·浦语).
    - InternLM (书生·浦语) is a conversational language model that is developed by Shanghai AI Laboratory (上海人工智能实验室). It is designed to be helpful, honest, and harmless.
    - InternLM (书生·浦语) can understand and communicate fluently in the language chosen by the user such as English and 中文."""
    
    messages = [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": "Please tell me five scenic spots in Shanghai"}
    ]
    
    stream = ollama.chat(
        model='internlm/internlm3-8b-instruct',
        messages=messages,
        stream=True,
    )
    
    for chunk in stream:
      print(chunk['message']['content'], end='', flush=True)

关键配置

配置项必填说明示例
model_dir是模型权重目录或 HuggingFace 仓库名,LMDeploy 据此加载模型internlm/internlm3-8b-instruct
--model-name否API 服务对外暴露的模型名称,需与请求体 model 字段一致internlm3-8b-instruct
--server-port否OpenAI 兼容服务的监听端口23333
num_ctx否Ollama 调用的上下文窗口长度8192
num_predict否Ollama 调用的最大生成 token 数2048

如何确认成功

API 服务启动后,curl 请求返回包含模型回复的 JSON;或在 Python 中运行 pipeline,终端打印出上海五个景点即成功。

常见问题

Q:curl 请求报模型名不存在怎么办?

A:检查请求体中的 model 字段是否与启动服务时 --model-name 的值完全一致,示例中为 internlm3-8b-instruct。

Q:如何让模型支持更长上下文?

A:使用 Ollama 调用时可通过 options 传入 num_ctx 参数,README 示例中设置为 8192。

Q:LMDeploy 和 Ollama 两种方式该选哪个?

A:LMDeploy 适合批量推理和自建 OpenAI 兼容服务;Ollama 安装更轻量,适合本地快速对话体验。可任选其一。

Q:首次运行很慢是正常的吗?

A:正常。首次运行会自动下载模型权重,体积较大,需要等待下载完成后再进行推理。

注意事项

  • README 中所有示例模型均为 internlm/internlm3-8b-instruct,替换模型时需同步修改服务名与请求体。
  • Ollama 方案需先执行安装脚本安装 Ollama 运行时,再安装 Python 客户端 ollama。
  • Python 示例中的 thinking_system_prompt 变量 README 未给出定义,实际使用时需自行补充系统提示词。
  • 官方还提供在线 Chat Web 与 API 文档链接,可先体验再决定是否本地部署。

核心亮点

  • 多版本迭代成熟,从基础版到长上下文版覆盖不同需求
  • 中文能力突出,在中文理解和生成任务上表现优于同量级模型
  • 提供完整的训练和推理工具链,支持微调和 RLHF,便于定制

不足之处

  • 文档和社区生态相对国际主流项目(如 LLaMA)仍有差距
  • 部分高级功能依赖特定硬件或库,部署门槛略高

适用场景

  • 中文对话助手和客服系统开发
  • 企业私有化大模型部署与微调
  • 学术研究中的模型对比和实验

替代项目

LLaMA、ChatGLM、Qwen

项目介绍

InternLM 是开源模型领域的开源项目,由 InternLM 开发,2023 年首次发布。

在全站 13,090 个收录项目中,它的 GitHub 星标数(7,279)位列前 7%,在开源模型分类的 424 个项目里位列前 9%。

项目已超过三个月没有代码更新,维护节奏明显放缓,最近一次代码更新于 2026-09-22。Apache-2.0许可,可免费下载使用,无在线服务。

它主要面向的使用场景是:中文对话助手和客服系统开发。同类可对比的替代方案包括 LLaMA、ChatGLM、Qwen。

上一篇:dolly

下一篇:Linly

同类项目推荐

Machine-Learning 开源

跟着博客笔记,边看边跑机器学习代码

All content related to machine learning from my blog

★ 115 2026-08-09
CoreML-Models 开源

下载即用的苹果端 AI 模型库,免去转换烦恼

Core ML model zoo for iOS/macOS — PyTorch models converted to ready-to-use .mlpacka···

★ 1873 2026-08-10