InternLM

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

开源 🏷️完全免费 🔧 仅开源项目,无在线服务,需自行部署 对话助手 🍴 复刻 509 🐛 待处理 9 👀 关注 57
GitHub ↗
GitHub 星标 ★ 7277
维护状态 低维护
是否开源 开源
定价模式 🏷️完全免费 开源模型,Apache-2.0许可,可免费下载使用,无在线服务。

项目预览

InternLM 项目界面预览图
图片来源:GitHub 官方仓库名片

项目数据

分类对话助手
开发团队InternLM
定价模式🏷️完全免费
价格说明开源模型,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 星标★ 7277
上线时间2023-07-06 00:00:00
代码更新2025-10-30
仓库体积7.3 MB
本站数据更新2026-11-09
维护状态低维护
收录时间2026-08-09
浏览次数4

项目介绍

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

Star 增长趋势

本站每日记录该项目 GitHub 星标变化,观测越久曲线越完整

数据来源:GitHub API 逐日快照 · 收录于 2026-08-09 · 当前星标 ★ 7277

使用教程

难度:进阶 约 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

上一篇:dolly

下一篇:Linly

同类项目推荐

Awesome_Multimodel_LLM 开源

一站式收藏多模态大模型资源,快速跟上最新进展

Awesome_Multimodel is a curated GitHub repository that provides a comprehensive coll···

★ 379 2026-08-09
Mobile-O 开源

让手机原生跑通多模态AI,离线也能理解与生成图像。

[CVPR'26 Demo] Mobile-O: Unified Multimodal Understanding and Generation on Mobile D···

★ 161 2026-08-09
laya 开源

一次前向传播,把任意文本变成选择、评分和是/否判断

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decision···

★ 35257 2026-10-14
awesome-ltx2 开源

找齐 LTX-2 模型、工作流和 LoRA,一键上手视频生成。

All available LTX-2 models, encoders, workflows, LoRAs for ComfyUI

★ 604 2026-08-10
awesome-AI-toolkit 开源

一站式找齐AI工具、框架、数据集和论文

A curated, comprehensive collection of open-source AI tools, frameworks, datasets, c···

★ 209 2026-08-09
awesome-controlnet 开源

一站式收集 ControlNet 资源,快速上手精准可控的图像生成

Awesome repo for ControlNet

★ 97 2026-08-09
sealion 开源

让大模型真正听懂东南亚多国语言

South-East Asia Large Language Models

★ 425 2026-09-25
Bootstrap3D 开源

用合成数据训练多视图扩散模型,让 3D 生成更稳更准

[ICCV-2025] Official implementation of Bootstrap3D: Improving Multi-view Diffusion M···

★ 94 2026-08-09
Yi 开源

中文大模型新选择,从零训练性能强,拿来即用可微调

A series of large language models trained from scratch by developers @01-ai

★ 7834 2026-08-09