零基础学习书生.浦语大模型-入门岛

devtools/2025/2/5 0:30:12/

第一关:Linux基础知识

任务一:Cursor连接SSH运行代码

使用Remote - SSH插件即可

运行指令

python hello_world.py

 端口映射

ssh -p 46561 root@ssh.intern-ai.org.cn -CNg -L 7860:127.0.0.1:7860 -o StrictHostKeyChecking=no

注:46561:服务器端口号

进入127.0.0.1:7860访问资源

第二关:Python基础知识

任务一:Leetcode383题

代码

from collections import Counterclass Solution(object):def canConstruct(self, ransomNote, magazine):""":type ransomNote: str:type magazine: str:rtype: bool"""ransom_counter = Counter(ransomNote)magazine_counter = Counter(magazine)for char, count in ransom_counter.items():if magazine_counter[char] < count:return Falsereturn True

任务二:Vscode连接InternStudio debug

登录书生.浦语API官网,获取API token

将API token输入到实例代码中,并运行该代码

可以发现此代码存在错误

由于Bug提示信息得json数据格式存在问题,于是在第30行打断,查看res数值情况。

res数值为'根据提供的模型介绍文字,以下是提取的关于该模型的信息,以JSON格式返回:\n\n```json\n{\n "模型名字": "书生浦语InternLM2.5",\n "开发机构": "上海人工智能实验室",\n "提供参数版本": ["1.8B", "7B", "20B"],\n "上下文长度": "1M"\n}\n```\n\n这些信息准确地反映了模型名称、开发机构、提供的参数版本以及支持的上下文长度。如果还有其他需要补充或调整的信息,请随时告知。'

因此需要提取JSON格式的代码

res = internlm_gen(prompt,client)json_pattern = r'json\s*({[\s\S]*?})\s*'
match = re.search(json_pattern, res)
res = match.group(1) res_json = json.loads(res)
print(res_json)

运行成功

第三关:Git基础知识

任务1: 破冰活动:自我介绍

fork项目 InternLM/Tutorial

执行指令

git clone https://github.com/Aaronzijingcai/Tutorial.git
git checkout -b class origin/class
git checkout -b class_7745git add .
git commit -m "add git_camp4_7745_introduction"
git push origin class_7745

添加Pull requests

add git_7745_introduction by Aaronzijingcai · Pull Request #2952 · InternLM/Tutorial · GitHub

任务2: 实践项目:构建个人项目

dock408项目

介绍:Dock408 是基于 InternLM 书生浦语大模型开发的多智能体项目。"Dock"(码头)寓意着帮助考生顺利抵达成功的彼岸——即考研成功。该项目旨在为408考生提供高效的学习支持和知识掌握工具。 当学生上传题目后,Dock408 不仅会提供详细的解答,还会列举相关的知识点,帮助学生查漏补缺。此外,Dock408 还会生成与该题目相关的练习题,通过“举一反三”的方式强化学生的理解和应用能力,从而更好地掌握知识。 更重要的是,Dock408 根据学生的历史刷题记录和知识点查阅情况,利用艾宾浩斯遗忘曲线理论,智能生成个性化的复习提醒,确保学生能够有效地巩固所学内容,避免遗忘。

地址:https://github.com/Aaronzijingcai/dock408

第四关:玩转HF/魔塔/魔乐社区

任务一:模型下载

在自己的conda环境中安装transformer

# 安装transformers
pip install transformers==4.38
pip install sentencepiece==0.1.99
pip install einops==0.8.0
pip install protobuf==5.27.2
pip install accelerate==0.33.0

从HF中下载internlm2_5-7b-chat模型

touch hf_download_josn.py

其中hf_download_json.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)


http://www.ppmy.cn/devtools/156129.html

相关文章

《HelloGitHub》第 106 期

兴趣是最好的老师&#xff0c;HelloGitHub 让你对编程感兴趣&#xff01; 简介 HelloGitHub 分享 GitHub 上有趣、入门级的开源项目。 github.com/521xueweihan/HelloGitHub 这里有实战项目、入门教程、黑科技、开源书籍、大厂开源项目等&#xff0c;涵盖多种编程语言 Python、…

用Python替代OpenMV IDE显示openmv USB 图像

原理是利用openmv的usb模仿串口&#xff0c;然后用Python代码打开串口接收 能替代openmv ide 跑48帧图像 Python端需要的依赖&#xff1a; 需要的是&#xff1a; from ultralytics import YOLO import cv2 import numpy as np from serial import Serial import time from co…

Immutable设计 SimpleDateFormat DateTimeFormatter

专栏系列文章地址&#xff1a;https://blog.csdn.net/qq_26437925/article/details/145290162 本文目标&#xff1a; 理解不可变设计模式&#xff0c;时间format有线程安全要求的注意使用DateTimeFormatter 目录 ImmutableSimpleDateFormat 非线程安全可以synchronized解决&a…

人机交互系统实验三 多通道用户界面

实验目的和要求 1)了解常见的多通道用户界面 2)查找资料&#xff0c;熟悉一种多通道用户界面并写出综述 实验环境 Windows10 实验内容与过程 (一) 实验内容: 要求上网查找资料&#xff0c;熟悉一种多通道用户界面并写出综述&#xff0c;可以是眼动跟踪、手势识别、 三维…

论文阅读(七):贝叶斯因果表型网络解释遗传变异和生物学知识

1.论文链接&#xff1a;Bayesian Causal Phenotype Network Incorporating Genetic Variation and Biological Knowledge 摘要&#xff1a; 在分离群体中&#xff0c;数量性状基因座&#xff08;QTL&#xff09;定位可以确定对表型有因果效应的QTL。这些方法的一个共同特点是Q…

初始Linux(7):认识进程(下)

1. 进程优先级 cpu 资源分配的先后顺序&#xff0c;就是指进程的优先权&#xff08; priority &#xff09;。 优先权高的进程有优先执行权利。配置进程优先权对多任务环境的 linux 很有用&#xff0c;可以改善系统性能。 还可以把进程运行到指定的CPU 上&#xff0c;这样一来…

Spring Boot基本项目结构

要写一个Spring Boot 项目对于新手小白来说&#xff0c;首先要了解Spring Boot 的基本架构&#xff0c;学会如何创建一个简单的spring boot项目。 springboot 基于maven做的&#xff08;前提保证maven是装好并且IDEA配置好的&#xff09;&#xff08;面向接口编程&#xff09;…

【Linux】解决 apt-key 弃用问题:GPG 直接管理密钥代替 apt-key

引言 在 Linux 系统&#xff0c;尤其是 Debian 和 Ubuntu 中&#xff0c;APT&#xff08;Advanced Package Tool&#xff09;是广泛使用的包管理工具&#xff0c;负责安装、更新和管理系统软件包。历史上&#xff0c;apt-key 命令一直被用来管理 GPG 密钥&#xff0c;验证软件…