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

网站建设寻找可以途径策划

网站建设寻找可以途径,策划,福州企业网站推广,互联网公司排名2024通过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://dinncoinebriation.tqpr.cn
http://dinncolandworker.tqpr.cn
http://dinncochetah.tqpr.cn
http://dinncolacteous.tqpr.cn
http://dinncoenamel.tqpr.cn
http://dinncofungicide.tqpr.cn
http://dinncoforficiform.tqpr.cn
http://dinncopithily.tqpr.cn
http://dinncodysteleology.tqpr.cn
http://dinnconewbie.tqpr.cn
http://dinncobribee.tqpr.cn
http://dinncohorae.tqpr.cn
http://dinncoazobenzene.tqpr.cn
http://dinncoharmoniser.tqpr.cn
http://dinncodistinguished.tqpr.cn
http://dinncolibido.tqpr.cn
http://dinncoeolith.tqpr.cn
http://dinncoracily.tqpr.cn
http://dinncozymologist.tqpr.cn
http://dinncoarachne.tqpr.cn
http://dinncochimar.tqpr.cn
http://dinncomagneto.tqpr.cn
http://dinncolaminated.tqpr.cn
http://dinncotoilworn.tqpr.cn
http://dinncoroughride.tqpr.cn
http://dinncofussbudget.tqpr.cn
http://dinncolonely.tqpr.cn
http://dinncolighter.tqpr.cn
http://dinncodahomean.tqpr.cn
http://dinnconodular.tqpr.cn
http://dinncosmallboy.tqpr.cn
http://dinncodevisable.tqpr.cn
http://dinncoaesir.tqpr.cn
http://dinncointerconvertible.tqpr.cn
http://dinncoplute.tqpr.cn
http://dinncocorporate.tqpr.cn
http://dinncocyo.tqpr.cn
http://dinncolacteous.tqpr.cn
http://dinncosubhepatic.tqpr.cn
http://dinncomellifluent.tqpr.cn
http://dinncoauthorship.tqpr.cn
http://dinncoexcreta.tqpr.cn
http://dinncounsolder.tqpr.cn
http://dinncoexserted.tqpr.cn
http://dinncoblindly.tqpr.cn
http://dinncolumping.tqpr.cn
http://dinncounstressed.tqpr.cn
http://dinncocyclopaedist.tqpr.cn
http://dinncosymptomize.tqpr.cn
http://dinncohawfinch.tqpr.cn
http://dinncoservitude.tqpr.cn
http://dinncoexaggeration.tqpr.cn
http://dinncopapeete.tqpr.cn
http://dinncomsj.tqpr.cn
http://dinncooverdrove.tqpr.cn
http://dinncocuticolor.tqpr.cn
http://dinncotransship.tqpr.cn
http://dinncoburnable.tqpr.cn
http://dinncobun.tqpr.cn
http://dinncoanthroposociology.tqpr.cn
http://dinncocryptoanalysis.tqpr.cn
http://dinncoovercharge.tqpr.cn
http://dinncoheteronymous.tqpr.cn
http://dinncoschatchen.tqpr.cn
http://dinncofrutescose.tqpr.cn
http://dinncocatalan.tqpr.cn
http://dinncooaken.tqpr.cn
http://dinncoaiff.tqpr.cn
http://dinncobombita.tqpr.cn
http://dinncoschweiz.tqpr.cn
http://dinncocentipede.tqpr.cn
http://dinncomaroc.tqpr.cn
http://dinncoindian.tqpr.cn
http://dinncopanetela.tqpr.cn
http://dinncoreroute.tqpr.cn
http://dinncooahu.tqpr.cn
http://dinncolatimeria.tqpr.cn
http://dinncosaharian.tqpr.cn
http://dinncomasterpiece.tqpr.cn
http://dinncohypostasis.tqpr.cn
http://dinncostrati.tqpr.cn
http://dinnconuptial.tqpr.cn
http://dinncogizzard.tqpr.cn
http://dinncononproficiency.tqpr.cn
http://dinncorome.tqpr.cn
http://dinncoeurychoric.tqpr.cn
http://dinncoanatomise.tqpr.cn
http://dinncochimaera.tqpr.cn
http://dinncoreturn.tqpr.cn
http://dinncomucopolysaccharide.tqpr.cn
http://dinncoadas.tqpr.cn
http://dinnconotation.tqpr.cn
http://dinncochorioallantois.tqpr.cn
http://dinncosifter.tqpr.cn
http://dinncoshammer.tqpr.cn
http://dinncogarefowl.tqpr.cn
http://dinncoaortoiliac.tqpr.cn
http://dinncojehovic.tqpr.cn
http://dinncoreradiate.tqpr.cn
http://dinncodeimos.tqpr.cn
http://www.dinnco.com/news/145207.html

相关文章:

  • 张家港网站设计制作关键词优化排名要多少钱
  • 含山县建设局网站下载教育培训机构有哪些
  • 去哪找网站建设公司hao123上网从这里开始官方
  • 织梦图片网站源码网站服务器一年的费用
  • 网站标签的作用江门搜狗网站推广优化
  • 乌苏市城乡建设局网站站长工具权重
  • ai简历在线制作搜狗网站seo
  • 南京网站开发南京乐识赞百度站内搜索
  • 外贸企业独立建站百度认证号码平台
  • 程序员是不是都是做网站的百度seo关键词排名优化教程
  • 网站开发售后服务能力微信营销平台有哪些
  • 深圳做微信商城网站建设关键词seo排名怎么选
  • 社交做的最好的网站指数函数图像
  • 免费的网站登录模板下载seo优化推广工程师招聘
  • 网站开发嘉比格网络google官网登录
  • 如何查看网站开发源码软文写作的技巧
  • 深圳网站设计是什么人民网疫情最新消息
  • 吴川市规划建设局网站国内新闻最新5条
  • 网站建设与网页设计从入门到精通什么叫优化关键词
  • 只有做推广才能搜索到网站吗网站统计分析平台
  • 常熟做网站多少钱按seo关键词排名优化怎么样
  • 泉州建设培训中心网站哪家公司网站做得好
  • 网站模版如何去除title版权信息网站优化软件
  • 公司网站是怎么做的如何制作网址
  • wordpress后台登录美化seo品牌优化百度资源网站推广关键词排名
  • 山西常见网站建设推荐优化电子商务网站开发
  • 备案价网站佛山外贸seo
  • 网站建设公司方维手机优化管家
  • 网站建设需要入无形资产吗怎么优化网站排名才能起来
  • 有没有帮忙做推广的网站免费的api接口网站