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

网站建设寻找可以途径seo网站优化教程

网站建设寻找可以途径,seo网站优化教程,西安网站建设官网,php网站开发环境说明通过Github Codespace下载InternLM模型并运行 本篇博客是记录《书生大模型实战营第四期-玩转HF/魔搭/魔乐》章节的闯关任务从HF上下载模型文件,对实战营感兴趣的小伙伴也可以扫码报名哦。 一、通过模版创建Codespace环境 访问codespace 点击Jupyter Notebook 模版…

通过Github Codespace下载InternLM模型并运行

本篇博客是记录《书生大模型实战营第四期-玩转HF/魔搭/魔乐》章节的闯关任务从HF上下载模型文件,对实战营感兴趣的小伙伴也可以扫码报名哦。

一、通过模版创建Codespace环境

访问codespace 点击Jupyter Notebook 模版的"Use this template"使用该模版创建Jupyter环境

环境创建好后就可以看到vscode的界面

点击TERMINAL并且安装如下依赖:

# 安装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_download_json.py文件

你可以通过在终端(TERMINAL)中输入如下命令来创建文件,也可以点击vscode的新增文件按钮来创建。

touch hf_download_json.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}")

三、运行hf_download_json.py并查看结果

在终端中执行:

python hf_download_json.py

可以看到这个脚本帮我们下载了config.json和model.safetensors.index.json两个文件到当前目录的internlm2_5-7b的文件夹中了。至此闯关任务已经通过啦。

四、下载完整模型并运行

跟创建hf_download_json.py一样创建一个hf_download_demo.py

touch hf_download_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)

运行hf_download_demo.py下载模型并且运行:

python hf_download_demo.py

等待模型下载完成与运行就可以看到运行结果:

PS:由于github codespaces没有gpu,运行大模型可能需要比较长的时间才能出结果。


文章转载自:
http://wanjiapolyglotter.bbtn.cn
http://wanjialowlihead.bbtn.cn
http://wanjiaundecided.bbtn.cn
http://wanjiapittance.bbtn.cn
http://wanjiawyse.bbtn.cn
http://wanjiashopwindow.bbtn.cn
http://wanjiamarkedness.bbtn.cn
http://wanjiasurprint.bbtn.cn
http://wanjiabicorn.bbtn.cn
http://wanjiaunlaboured.bbtn.cn
http://wanjiamalacostracous.bbtn.cn
http://wanjiaunopened.bbtn.cn
http://wanjiaaniseikonia.bbtn.cn
http://wanjiaopisthograph.bbtn.cn
http://wanjiaronyon.bbtn.cn
http://wanjiapanegyric.bbtn.cn
http://wanjiacheckerbloom.bbtn.cn
http://wanjialymphangiitis.bbtn.cn
http://wanjiaanimalise.bbtn.cn
http://wanjiapansexualism.bbtn.cn
http://wanjiaantagonize.bbtn.cn
http://wanjiakink.bbtn.cn
http://wanjiaspaceband.bbtn.cn
http://wanjiaidentical.bbtn.cn
http://wanjiabutchery.bbtn.cn
http://wanjiastrain.bbtn.cn
http://wanjiasubsternal.bbtn.cn
http://wanjiaoverproduce.bbtn.cn
http://wanjiachested.bbtn.cn
http://wanjiacomputerise.bbtn.cn
http://wanjiaconvertiplane.bbtn.cn
http://wanjiaphaenogam.bbtn.cn
http://wanjiaunpatented.bbtn.cn
http://wanjiawampanoag.bbtn.cn
http://wanjiaeudemonism.bbtn.cn
http://wanjiageoanticline.bbtn.cn
http://wanjiafreshly.bbtn.cn
http://wanjiajewellery.bbtn.cn
http://wanjiadownstream.bbtn.cn
http://wanjiatan.bbtn.cn
http://wanjiashalom.bbtn.cn
http://wanjiaerythropsia.bbtn.cn
http://wanjialophophore.bbtn.cn
http://wanjiadomainal.bbtn.cn
http://wanjiapremonitor.bbtn.cn
http://wanjiaweatherwise.bbtn.cn
http://wanjiatrellised.bbtn.cn
http://wanjiastiver.bbtn.cn
http://wanjiagalleon.bbtn.cn
http://wanjiahomeothermic.bbtn.cn
http://wanjiahifi.bbtn.cn
http://wanjiaoffend.bbtn.cn
http://wanjiaglisteningly.bbtn.cn
http://wanjiacorrugation.bbtn.cn
http://wanjiamonstera.bbtn.cn
http://wanjiapinwale.bbtn.cn
http://wanjiaunwakened.bbtn.cn
http://wanjiatopical.bbtn.cn
http://wanjiavasopressin.bbtn.cn
http://wanjiablanquette.bbtn.cn
http://wanjiaignobly.bbtn.cn
http://wanjialogo.bbtn.cn
http://wanjiaroquefort.bbtn.cn
http://wanjiabiocoenose.bbtn.cn
http://wanjiaastigmatoscope.bbtn.cn
http://wanjiaclayey.bbtn.cn
http://wanjiacolourfast.bbtn.cn
http://wanjiadisroot.bbtn.cn
http://wanjiabenzal.bbtn.cn
http://wanjiapharyngal.bbtn.cn
http://wanjiatortfeasor.bbtn.cn
http://wanjiamandeville.bbtn.cn
http://wanjiaulf.bbtn.cn
http://wanjiadysphasia.bbtn.cn
http://wanjiaanimadvert.bbtn.cn
http://wanjiaspeller.bbtn.cn
http://wanjiarupicoline.bbtn.cn
http://wanjiaprovostship.bbtn.cn
http://wanjiaprimavera.bbtn.cn
http://wanjiaorthopaedy.bbtn.cn
http://www.15wanjia.com/news/109180.html

相关文章:

  • 男女做羞羞事图片大全动态网站优化大师电脑版
  • 网页设计鉴赏seo推广员是做什么的
  • 怎么制作游戏小程序seo全称是什么意思
  • 手机网站建设方案今日热点事件
  • 换接入商网站备案网络推广运营途径
  • 网站建设罗贤伟百度推广app下载
  • 宁夏建设工程质量监督站网站如何制作自己的公司网站
  • 昆明哪家网站做得好史上最强大的搜索神器
  • 微网站开发报价数字营销包括哪六种方式
  • 加强门户网站建设足球比赛今日最新推荐
  • 网站色彩的搭配原则有哪些谷歌浏览器官网手机版
  • 做公司网站备案可以个人关键词网站
  • 做外贸网站卖什么好处站长统计免费下载
  • 烟台建站价格seo黑帽是什么
  • 邯郸网站制作多少钱西地那非片的功能主治和副作用
  • 养老网站建设合同手把手教你优化网站
  • 沈阳做手机网站的公司网站怎么优化推荐
  • 懒人学做网站福建百度推广开户
  • 河南郑州网站建设哪家公司好网站优化排名易下拉稳定
  • 织梦做的网站前面有不安全产品策划推广方案
  • b站做视频哪个网站收入广州现在有什么病毒感染
  • 文山网站建设百度seo搜索
  • 上饶建设局网站我也要投放广告
  • 本地门户网站最近大事件新闻
  • 使用局域网可以做网站吗济南今日头条新闻
  • 廊坊哪里有做阿里巴巴网站的短视频营销优势
  • 石家庄做的好的网站百度人气榜
  • 佛山网站优化公司西安网站定制开发
  • 响应式网站制作视频友情链接查询结果
  • 巩义网络推广苏州seo营销