当前位置: 首页 > news >正文

InternLM2-Chat-1.8B 模型测试

在interStudio进行InternLM2-Chat-1.8B模型访问,进入开发机后

  1. 配置基础环境
    新建conda环境并且进入
    conda create -n demo python3.10 -y
    conda activate demo
    下载pytorch等相关包
    conda install pytorch
    2.0.1 torchvision0.15.2 torchaudio2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia
    pip install huggingface-hub0.17.3
    pip install transformers
    4.34
    pip install psutil5.9.8
    pip install accelerate
    0.24.1
    pip install streamlit1.32.2
    pip install matplotlib
    3.8.3
    pip install modelscope1.9.5
    pip install sentencepiece
    0.1.99
    在这里插入图片描述
  2. 创建下载模型的文件,并下载模型
import os
from modelscope.hub.snapshot_download import snapshot_download# 创建保存模型目录
os.system("mkdir /root/models")# save_dir是模型保存到本地的目录
save_dir="/root/models"snapshot_download("Shanghai_AI_Laboratory/internlm2-chat-1_8b", cache_dir=save_dir, revision='v1.1.0')
  1. 创建执行文件
import torch
from transformers import AutoTokenizer, AutoModelForCausalLMmodel_name_or_path = "/root/models/Shanghai_AI_Laboratory/internlm2-chat-1_8b"tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, trust_remote_code=True, device_map='cuda:0')
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map='cuda:0')
model = model.eval()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 = [(system_prompt, '')]print("=============Welcome to InternLM chatbot, type 'exit' to exit.=============")while True:input_text = input("\nUser  >>> ")input_text = input_text.replace(' ', '')if input_text == "exit":breaklength = 0for response, _ in model.stream_chat(tokenizer, input_text, messages):if response is not None:print(response[length:], flush=True, end="")length = len(response)
  1. 测试模型demo
    在这里插入图片描述
    点评:能创作通话故事,但是故事主角有3个而不是2个,缺失了人物主角。

不知道是对齐的时候太严格了还是怎么样,能力有限
在这里插入图片描述

在这里插入图片描述

http://www.lryc.cn/news/332759.html

相关文章:

  • Flutter 关键字
  • Java常用API之Collections类解读
  • KV260 BOOT.BIN更新 ubuntu22.04 netplan修改IP
  • Android 代码自定义drawble文件实现View圆角背景
  • C#实现Word文档转Markdown格式(Doc、Docx、RTF、XML、WPS等)
  • 信息系统架构设计-以服务为中心的企业整合实践
  • mysql知识点梳理
  • 版本排序,(如果 版本 是 1,1a,1.1a, 2, 2c , 1c , 1.2a, 3 , 5b , 5)进行排序
  • Google视觉机器人超级汇总:从RT、RT-2到AutoRT、SARA-RT、RT-Trajectory
  • python笔记(9)Dictionary(字典)
  • 蓝桥杯嵌入式总结
  • 渗透测试:数据库UDF提权(linux)
  • java算法day45 | 动态规划part07 ● 70. 爬楼梯 (进阶) ● 322. 零钱兑换 ● 279.完全平方数
  • HuggingFace踩坑记录-连不上,根本连不上
  • 面试题:Spring Boot Starter的功能与使用场景
  • 上位机图像处理和嵌入式模块部署(qmacvisual之n点标定)
  • Francek Chen 的128天创作纪念日
  • PyTorch之Torch Script的简单使用
  • vscode 连接远程服务器 服务器无法上网 离线配置 .vscode-server
  • arm开发板移植工具mkfs.ext4
  • 某盾滑块拼图验证码增强版
  • 这个世界万物存在只有一种关系:博弈
  • c#让不同的工厂生产不同的“鸭肉”
  • 大数据分析与内存计算——Spark安装以及Hadoop操作——注意事项
  • 论文阅读RangeDet: In Defense of Range View for LiDAR-based 3D Object Detection
  • 3D模型格式转换工具HOOPS Exchange如何将3D文件加载到PRC数据结构中?
  • c# wpf Template ContentTemplate
  • 空和null是两回事
  • UNIAPP(小程序)每十个文章中间一个广告
  • pip包安装用国内镜像源