第二节课作业:轻松玩转书生·浦语大模型趣味 Demo
GitHub地址:
https://github.com/InternLM/tutorial/blob/main/helloworld/hello_world.md
1.使用 InternLM2-Chat-7B 模型生成 300 字的小故事

2.熟悉 hugging face 下载功能,使用 huggingface_hub python 包,下载 InternLM2-20B 的 config.json 文件到本地
import os
os.environ['HF_ENDPOINT']='https://hf-mirror.com'
from huggingface_hub import hf_hub_download # Load model directly
hf_hub_download(repo_id="internlm/internlm2-20b", filename="config.json",local_dir ='/root/code/')

进阶:
1.完成 Lagent 工具调用 Demo 创作部署
使用了pythonInterpreter工具

2.完成浦语·灵笔的图文理解及创作部署

第三节课作业:基于 InternLM 和 LangChain 搭建你的知识库
GitHub地址:https://github.com/InternLM/tutorial/tree/main/langchain
选择一个垂直领域,收集该领域的专业资料构建专业知识库,并搭建专业问答助手,并在 OpenXLab 上成功部署
本次选用的数据为:中文医患问答对话数据,选用其中2022年的部分数据

测试效果并不是很好,可能是数据太少的缘故;
github地址:https://github.com/Yang-Changhui/medi_langchain_internlm/tree/main
openxlab应用地址:https://openxlab.org.cn/apps/detail/Yang-Changhui/medi_langchain_internlm
第四节课作业:XTuner低成本微调
GitHub地址:
https://github.com/InternLM/tutorial/tree/main/xtuner
构建数据集,使用 XTuner 微调 InternLM-Chat-7B 模型, 让模型学习到它是你的智能小助手,效果如下图所示
微调前:

微调后:

进阶作业:
将训练好的Adapter模型权重上传到 OpenXLab、Hugging Face 或者 MoelScope 任一一平台。
from modelscope.hub.api import HubApi
YOUR_ACCESS_TOKEN = '你的modelscope的key'
api = HubApi()
api.login(YOUR_ACCESS_TOKEN)
api.push_model(
model_id="yangchanghui/personal_assistant",
model_dir="/root/personal_assistant/work_dirs/hf" # 本地模型目录,要求目录中必须包含configuration.json
)

第五节课作业: LMDeploy 的量化和部署
GitHub地址:https://github.com/InternLM/tutorial/blob/main/lmdeploy/lmdeploy.md
基础作业:
使用 LMDeploy 以本地对话、网页Gradio、API服务中的一种方式部署 InternLM-Chat-7B 模型,生成 300 字的小故事

进阶作业:
KV Cache量化前:

KV Cache量化后:

显存大概减少32G
模型量化前:

模型量化后:

显存大概下降一半
第六节课作业:opencompass模型评测
GitHub实验:https://github.com/InternLM/tutorial/blob/main/opencompass/opencompass_tutorial.md
使用 OpenCompass 评测 InternLM2-Chat-7B 模型在 C-Eval 数据集上的性能:

使用 OpenCompass 评测 InternLM2-Chat-7B 模型使用 LMDeploy 0.2.0 部署后在 C-Eval 数据集上的性能

部署量化后效果变差,很可能是模型量化出错,目前还在排查
本文介绍了如何使用InternLM进行模型操作,包括下载配置文件、调用工具如Lagent和LangChain搭建知识库、微调模型、量化部署以及模型性能评估。教程涵盖了从基础任务到进阶作业的实践过程。
2159

被折叠的 条评论
为什么被折叠?



