基础作业:
- 使用 InternLM-Chat-7B 模型生成 300 字的小故事(需截图)。
- 熟悉 hugging face 下载功能,使用 huggingface_hub python 包,下载 InternLM-20B 的 config.json 文件到本地(需截图下载过程)。
进阶作业(可选做)
- 完成浦语·灵笔的图文理解及创作部署(需截图)
创作文案:六朝古都南京
图片理解:上海陆家嘴
- 完成 Lagent 工具调用 Demo 创作部署(需截图)
计算极限出错了
图片处理问题也不明所以
其余笔记
- SSH的配置
本地的powershell生成SSH秘钥对
ssh-keygen -t rsa
使用cat ~\.ssh\id_rsa.pub查看秘钥
将秘钥赋值给服务器的SSH key
读取服务器上的SSH链接,读取开发机的端口
碰到的问题:端口报错
OSError: Cannot find empty port in range: 6006-6006. You can specify a different port by setting the GRADIO_SERVER_PORT environment variable or passing the server_port parameter to launch()
解决Linux的端口占用报错问题_6006端口被使用-CSDN博客
优先重启服务器把!实在不行通过netstat -tpl 查看端口占用后kill进程 sudo kill PID
(如果碰到Command ‘netstat‘ not found问题那就先apt install net-tools)
再次运行6006就不会再被占用了
- 代码阅读
InternLM-Chat-7B本地的代码
#引入包 import torch from transformers import AutoTokenizer, AutoModelForCausalLM #读取模型和预训练的token model_name_or_path = "/root/model/Shanghai_AI_Laboratory/internlm-chat-7b" tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='auto') model = model.eval()#模型使用 #跳过部分代码 while True: input_text = input("User >>> ") input_text = input_text.replace(' ', '') if input_text == "exit": break response, history = model.chat(tokenizer, input_text, history=messages)#通过魔性的chat模型进行回复 messages.append((input_text, response))#将这一次对话补充到message里,用作后续回复的资料 print(f"robot >>> {response}") |
- 一些基本的代码