书生大模型实战营第四期-入门岛-4. maas课程任务
书生大模型实战营第四期-入门岛-4. maas课程任务
任务一、模型下载
任务内容
使用Hugging Face平台、魔搭社区平台(可选)和魔乐社区平台(可选)下载文档中提到的模型(至少需要下载config.json文件、model.safetensors.index.json文件),请在必要的步骤以及结果当中截图。
作业过程
下载internlm2_5-7b-chat的配置文件
新建一个hf_download_josn.py 文件,内容如下:
import os
from huggingface_hub import hf_hub_download# 指定模型标识符
repo_id = "internlm/internlm2_5-7b"# 指定要下载的文件列表
files_to_download = [{"filename": "config.json"},{"filename": "model.safetensors.index.json"}
]# 创建一个目录来存放下载的文件
local_dir = f"{repo_id.split('/')[1]}"
os.makedirs(local_dir, exist_ok=True)# 遍历文件列表并下载每个文件
for file_info in files_to_download:file_path = hf_hub_download(repo_id=repo_id,filename=file_info["filename"],local_dir=local_dir)print(f"{file_info['filename']} file downloaded to: {file_path}")

下载internlm2_5-chat-1_8b并打印示例输出
创建hf_download_1_8_demo.py文件,内容如下:
import torch
from transformers import AutoTokenizer, AutoModelForCausalLMtokenizer = AutoTokenizer.from_pretrained("internlm/internlm2_5-1_8b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("internlm/internlm2_5-1_8b", torch_dtype=torch.float16, trust_remote_code=True)
model = model.eval()inputs = tokenizer(["A beautiful flower"], return_tensors="pt")
gen_kwargs = {"max_length": 128,"top_p": 0.8,"temperature": 0.8,"do_sample": True,"repetition_penalty": 1.0
}# 以下内容可选,如果解除注释等待一段时间后可以看到模型输出
output = model.generate(**inputs, **gen_kwargs)
output = tokenizer.decode(output[0].tolist(), skip_special_tokens=True)
print(output)

任务二、模型上传(可选)
作业内容
将我们下载好的config.json文件(也自行添加其他模型相关文件)上传到对应HF平台和魔搭社区平台,并截图。
作业过程
上传模型文件到HF平台
通过CLI上传 Hugging Face同样是跟Git相关联,通常大模型的模型文件都比较大,因此我们需要安装git lfs,对大文件系统支持。
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
# sudo apt-get install git-lfs # CodeSpace里面可能会有aptkey冲突且没有足够权限
git lfs install # 直接在git环境下配置git LFS
pip install huggingface_hub
在github的CodeSpace里面:
git config --global credential.helper store
huggingface-cli login
命令行登录hf,输入token(在hg创建并获取):
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ git config --global credential.helper store
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ huggingface-cli login_| _| _| _| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _|_|_|_| _|_| _|_|_| _|_|_|_|_| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|_|_|_|_| _| _| _| _|_| _| _|_| _| _| _| _| _| _|_| _|_|_| _|_|_|_| _| _|_|_|_| _| _| _| _| _| _| _| _| _| _|_| _| _| _| _| _| _| _|_| _| _|_| _|_|_| _|_|_| _|_|_| _| _| _|_|_| _| _| _| _|_|_| _|_|_|_|To log in, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .
Enter your token (input will not be visible):
Add token as git credential? (Y/n) Y
Token is valid (permission: write).
The token `hf_internlm_test` has been saved to /home/codespace/.cache/huggingface/stored_tokens
Your token has been saved in your configured git credential helpers (store).
Your token has been saved to /home/codespace/.cache/huggingface/token
Login successful.
The current active token is: `hf_internlm_test`
创建hg项目:
# intern_study_L0_4就是model_name
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ huggingface-cli repo create intern_study_L0_4
git version 2.47.0
git-lfs/3.5.1 (GitHub; linux amd64; go 1.21.8)You are about to create lldhsds/intern_study_L0_4
Proceed? [Y/n] YYour repo now lives at:https://huggingface.co/lldhsds/intern_study_L0_4You can clone it locally with the command below, and commit/push as usual.git clone https://huggingface.co/lldhsds/intern_study_L0_4# 将上面创建的项目克隆到本地
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ git clone https://huggingface.co/lldhsds/intern_study_L0_4
Cloning into 'intern_study_L0_4'...
remote: Enumerating objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 3 (from 1)
Unpacking objects: 100% (3/3), 1.05 KiB | 1.05 MiB/s, done.
更新项目并推送到远程仓库:
# 添加README.md文件
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ vim README.md@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ git add .
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ git commit -m "add:intern_study_L0_4"
[main 380529d] add:intern_study_L0_41 file changed, 3 insertions(+)create mode 100644 README.md
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ git push
remote: Password authentication in git is no longer supported. You must use a user access token or an SSH key instead. See https://huggingface.co/blog/password-git-deprecation
fatal: Authentication failed for 'https://huggingface.co/lldhsds/intern_study_L0_4/'
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ export hf_token="xxx" # 此处设置hf access key@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ git remote set-url origin https://lldhsds:$hf_token@huggingface.co/lldhsds/intern_study_L0_4
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_study_L0_4 (main) $ git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 449 bytes | 449.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
remote: -------------------------------------------------------------------------
remote: Your push was accepted, but with warnings:
remote: - Warning: empty or missing yaml metadata in repo card
remote: help: https://huggingface.co/docs/hub/model-cards#model-card-metadata
remote: -------------------------------------------------------------------------
remote: -------------------------------------------------------------------------
remote: Please find the documentation at:
remote: https://huggingface.co/docs/hub/model-cards#model-card-metadata
remote:
remote: -------------------------------------------------------------------------
To https://huggingface.co/lldhsds/intern_study_L0_4510dcc0..380529d main -> main
仓库信息:

上传模型文件到魔搭社区平台
- 魔搭社区注册登录,并创建model

- 下载模型并修改
git clone https://www.modelscope.cn/lldhsds/intern_study_L0_4.git
- 上传模型文件
(/root/share/pre_envs/pytorch2.1.2cu12.1) root@intern-studio-50014188:~/intern_study_L0_4# ls
README.md configuration.json# 创建config.json
(/root/share/pre_envs/pytorch2.1.2cu12.1) root@intern-studio-50014188:~/intern_study_L0_4# vim config.json# git提交三部曲
(/root/share/pre_envs/pytorch2.1.2cu12.1) root@intern-studio-50014188:~/intern_study_L0_4# git add .
(/root/share/pre_envs/pytorch2.1.2cu12.1) root@intern-studio-50014188:~/intern_study_L0_4# git commit -m "add:intern_study_L0_4"
[master ac42332] add:intern_study_L0_41 file changed, 35 insertions(+)create mode 100644 config.json# 这一步需要进行验证,moodelscope用户名+ moodelscope git token
(/root/share/pre_envs/pytorch2.1.2cu12.1) root@intern-studio-50014188:~/intern_study_L0_4# git push
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 128 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 692 bytes | 57.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
To https://www.modelscope.cn/lldhsds/intern_study_L0_4.git5acaa46..ac42332 master -> master
- 查看仓库
上传的文件,modelspace需要审核。

任务三、Space上传(可选)
作业内容
在HF平台上使用Spaces并把intern_cobuild部署成功,关键步骤截图。
作业过程
访问下面链接https://huggingface.co/spaces,点击右上角的Create new Space创建项目,输入项目名为intern_cobuild,并选择Static应用进行创建,创建成功后会自动跳转到一个默认的HTML页面。
创建好项目后,回到githuab的CodeSpace,接着clone并修改项目:
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ git clone https://huggingface.co/spaces/lldhsds/intern_cobuild
Cloning into 'intern_cobuild'...
remote: Enumerating objects: 6, done.
remote: Total 6 (delta 0), reused 0 (delta 0), pack-reused 6 (from 1)
Unpacking objects: 100% (6/6), 1.88 KiB | 1.88 MiB/s, done.
@lldhsds ➜ /workspaces/codespaces-jupyter (main) $ cd intern_cobuild/
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ ls
README.md index.html style.css
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ mv index.html index.html.bak
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ vim index.html
index.html文件内容修改如下:
<!doctype html>
<html>
<head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><style>html, body {margin: 0;padding: 0;height: 100%;}body {display: flex;justify-content: center;align-items: center;}iframe {width: 430px;height: 932px;border: none;}</style>
</head>
<body><iframe src="https://colearn.intern-ai.org.cn/cobuild" title="description"></iframe>
</body>
</html>
推送修改:
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ export hf_token="xxx" # 这里操作时改为
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ git remote set-url origin https://lldhsds:$hf_token@huggingface.co/spaces/lldhsds/intern_cobuild/
@lldhsds ➜ /workspaces/codespaces-jupyter/intern_cobuild (main) $ git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 596 bytes | 596.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0 (from 0)
To https://huggingface.co/spaces/lldhsds/intern_cobuild/fb177af..3b8fef2 main -> main
推送成功后查看Space界面,界面已更新:

相关文章:
书生大模型实战营第四期-入门岛-4. maas课程任务
书生大模型实战营第四期-入门岛-4. maas课程任务 任务一、模型下载 任务内容 使用Hugging Face平台、魔搭社区平台(可选)和魔乐社区平台(可选)下载文档中提到的模型(至少需要下载config.json文件、model.safetensor…...
Spring ApplicationListener监听
【JavaWeb】Spring ApplicationListener-CSDN博客 ApplicationEvent以及Listener是Spring为我们提供的一个事件监听、订阅的实现,内部实现原理是观察者设计模式,设计初衷也是为了系统业务逻辑之间的解耦,提高可扩展性以及可维护性。事件发布…...
K8s调度器扩展(scheduler)
1.K8S调度器 筛选插件扩展 为了熟悉 K8S调度器扩展步骤,目前只修改 筛选 插件 准备环境(到GitHub直接下载压缩包,然后解压,解压要在Linux系统下完成) 2. 编写调度器插件代码 在 Kubernetes 源代码目录下编写调度插件…...
IntelliJ IDEA 中,自动导包功能
在 IntelliJ IDEA 中,自动导包功能可以极大地提高开发效率,减少手动导入包所带来的繁琐和错误。以下是如何在 IntelliJ IDEA 中设置和使用自动导包功能的详细步骤: 一、设置自动导包 打开 IntelliJ IDEA: 启动 IntelliJ IDEA 并打…...
Spring事务笔记
目录 1.Spring 编程式事务 2.Transactional 3.事务隔离级别 4.Spring 事务传播机制 什么是事务? 事务是⼀组操作的集合, 是⼀个不可分割的操作. 事务会把所有的操作作为⼀个整体, ⼀起向数据库提交或者是撤销操作请求. 所以这组操作要么同时成 功, 要么同时失败 1.Spri…...
SQLite 管理工具 SQLiteStudio 3.4.5 发布
SQLiteStudio 3.4.5 版本现已发布,它带来了大量的 bug 修复,并增加了一些小功能。SQLiteStudio 是一个跨平台的 SQLite 数据库的管理工具。 具体更新内容包括: 现在可以使用 Collations Editor 窗口在数据库中注册 Extension-based collatio…...
QT 实现组织树状图
1.实现效果 在Qt中使用QGraphicsItem和QGraphicsScene实现树状图,你需要创建自定义的QGraphicsItem类来表示树的节点,并管理它们的位置和连接,以下是实现效果图。 2.实现思路 可以看见,上图所示,我们需要自定义连线类和节点类。 每个节点类Node,需要绘制矩形框体文字…...
go-学习
文章目录 简介标识符字符串的拼接,关键字数据类型声明变量常量算术运算符关系运算符逻辑运算符位运算赋值运算符其他运算符 简介 Go 语言的基础组成有以下几个部分: 1.包声明 2.引入包 3.函数 4.变量 5.语句 & 表达式 6.注释 package main import &q…...
【面试分享】主流编程语言的内存回收机制及其优缺点
以下是几种主流编程语言的内存回收机制及其优缺点: 一、Java 内存回收机制: Java 使用自动内存管理,主要通过垃圾回收器(Garbage Collector,GC)来回收不再被使用的对象所占用的内存。Java 的垃圾回收器会定…...
STM32-- 串口发送数据
while(USART_GetFlagStatus(USART2,USART_FLAG_TXE)RESET);?? 答: 这行代码: while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) RESET);的作用是等待串口 USART2 的发送数据寄存器(TXE,Transmit Dat…...
数据结构 (13)串的应用举例
前言 数据结构中的串(String),也称为字符串,是一种常见且重要的数据结构,在计算机科学中被广泛应用于各种场景。 一、文本处理 文本编辑器:在文本编辑器中,字符串被用来表示和存储用户输入的文本…...
qt-- - 版本和下载介绍
qt版本很多,每个大版本都有几个版本是长期支持的(LTS),最好使用长期支持的。 例如qt5.15 qt6.2 qt6.8 都是LTS版本的。 qt在线安装需要提供账号,之前安装qt6.8因为账号问题试了很长时间,密码错了。 …...
解锁 Vue 项目中 TSX 配置与应用简单攻略
在 Vue 项目中配置 TSX 写法 在 Vue 项目中使用 TSX 可以为我们带来更灵活、高效的开发体验,特别是在处理复杂组件逻辑和动态渲染时。以下是详细的配置步骤: 一、安装相关依赖 首先,我们需要在命令行中输入以下命令来安装 vitejs/plugin-v…...
ShuffleNet:一种为移动设备设计的极致高效的卷积神经网络
摘要 https://arxiv.org/pdf/1707.01083 我们介绍了一种名为ShuffleNet的计算效率极高的卷积神经网络(CNN)架构,该架构专为计算能力非常有限的移动设备(例如10-150 MFLOPs)而设计。新架构利用两种新操作:逐…...
yum源问题的解决方案
linux课堂作业 问题描述 yum 直接安装tree的问题截图 这个错误表明你的系统没有正确注册到 Red Hat Subscription Management(这个问题不用管),也没有配置有效的 YUM 软件仓库,因此无法安装或更新软件包。 解决方案(…...
在Linux中备份msyql数据库和表的详细操作
目录 前情提要 一、备份mysql数据库 原库展示 (一)新建一个数据库 (二)在linux根目录下找个位置暂时存放 (三)临时sql还原真正存放到库中 (四)查看是否备份成功 备份库成功展示 二、备份表的操作 编辑 原表emp展示 (一)快速新建一个原结构相同的表 (二)原表所…...
实时数仓Kappa架构:从入门到实战
引言 随着大数据技术的不断发展,企业对实时数据处理和分析的需求日益增长。实时数仓(Real-Time Data Warehouse, RTDW)应运而生,其中Kappa架构作为一种简化的数据处理架构,通过统一的流处理框架,解决了传统…...
【老白学 Java】Warship v2.0(四)
Warship v2.0(四) 文章来源:《Head First Java》修炼感悟。 上一篇文章中,老白仔细分析了 v2.0 的设计思路以及实现手段,如果大家有好的设计方案也可以自行尝试。 本篇文章的主要内容是对 Warship 类进行最后的修改&a…...
LLM之学习笔记(一)
前言 记录一下自己的学习历程,也怕自己忘掉了某些知识点 Prefix LM 和 Causal LM区别是什么? Prefix LM (前缀语⾔模型)和 Causal LM(因果语言模型)是两者不同类型的语言模型,它们的区别在于生…...
C# 反射详解
反射是C#中的一个强大特性,允许程序在运行时检查和操作类型和对象的信息。 通过反射,你可以获取类型的属性、方法、构造函数等信息,并可以动态创建对象、调用方法或访问属性,甚至可以实现某些框架或库的核心功能。 反射的基本概念…...
别再只盯着GPU了!聊聊华为昇腾310/910芯片在AI推理和训练中的实战选型心得
华为昇腾芯片实战选型指南:如何用310/910构建高性价比AI计算方案 当你在深夜调试一个即将上线的图像识别模型时,服务器机房的轰鸣声和不断攀升的电费账单可能比代码bug更让人焦虑。三年前,我们团队就面临这样的困境——用8块NVIDIA V100训练的…...
CAD_Sketcher终极指南:如何在Blender中实现精准约束绘图
CAD_Sketcher终极指南:如何在Blender中实现精准约束绘图 【免费下载链接】CAD_Sketcher Constraint-based geometry sketcher for blender 项目地址: https://gitcode.com/gh_mirrors/ca/CAD_Sketcher 你是否曾在Blender中尝试绘制精确的机械零件或建筑平面图…...
MambaAD实战:5分钟搞定工业缺陷检测的SoTA模型部署(附代码)
MambaAD工业缺陷检测实战:从模型原理到产线部署全指南 引言:当状态空间模型遇见工业质检 在液晶面板生产线上,一个0.1mm的亮点缺陷可能导致整批产品报废;在汽车零部件铸造车间,细微的表面裂纹可能引发严重的安全隐患。…...
Zotero终极指南:高效文献管理的开源解决方案
Zotero终极指南:高效文献管理的开源解决方案 【免费下载链接】zotero Zotero is a free, easy-to-use tool to help you collect, organize, annotate, cite, and share your research sources. 项目地址: https://gitcode.com/gh_mirrors/zo/zotero Zotero是…...
G-Helper:华硕笔记本电池健康管理的终极轻量化解决方案
G-Helper:华硕笔记本电池健康管理的终极轻量化解决方案 【免费下载链接】g-helper Lightweight Armoury Crate alternative for Asus laptops. Control tool for ROG Zephyrus G14, G15, G16, M16, Flow X13, Flow X16, TUF, Strix, Scar and other models 项目地…...
为什么很多人学 Django 会懵?因为没搞懂 MVC 和 MTV 的真正区别
很多刚接触 Django 的开发者,甚至包括不少测试工程师,在学习 Django 时都会遇到一个困惑:为什么 Django 不叫 MVC,而是 MTV?更奇怪的是:很多教程还会说:“Django 的 MTV 其实就是 MVC。”这句话…...
GaussDB JDBC SSL加密全攻略:从零配置到生产环境最佳实践
GaussDB JDBC SSL加密全攻略:从零配置到生产环境最佳实践 在数据驱动的时代,数据库连接的安全性已成为企业级应用不可忽视的生命线。作为华为云推出的分布式关系型数据库,GaussDB在金融、政务等对安全性要求极高的场景中广泛应用。而JDBC作为…...
Python异步I/O终极调优手册(含strace+py-spy+asyncio debug mode三重追踪链路图)
第一章:Python异步I/O性能瓶颈的本质洞察Python的async/await语法虽大幅简化了异步编程模型,但其底层性能瓶颈并非源于语法糖本身,而根植于事件循环调度机制、GIL对CPU密集型任务的制约,以及I/O等待与协程切换之间的隐式开销。事件…...
3步搞定Google Drive受保护PDF:高效下载完整指南
3步搞定Google Drive受保护PDF:高效下载完整指南 【免费下载链接】Google-Drive-PDF-Downloader 项目地址: https://gitcode.com/gh_mirrors/go/Google-Drive-PDF-Downloader 你是否曾遇到过这样的情况?在Google Drive中找到一个急需的技术文档或…...
保姆级教程:MogFace人脸检测模型-large快速上手,无需代码轻松体验
保姆级教程:MogFace人脸检测模型-large快速上手,无需代码轻松体验 1. 认识MogFace人脸检测模型 1.1 什么是MogFace MogFace是目前最先进的人脸检测方法之一,在Wider Face六项榜单上长期保持领先地位。这个模型通过三个创新点显著提升了检测…...
