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

嘉兴简单建站毕业设计平台

嘉兴简单建站,毕业设计平台,淘客推广佣金和服务费,wordpress 数据表 插件目录 步骤一、下载模型 步骤二、安装模型依赖包 步骤三、写代码 步骤四、运行代码 步骤五、中文提问 & 运行代码 步骤一、下载模型 安装下载命令 pip install modelscope 下载模型 modelscope download --model Qwen/Qwen3-8B --local_dir /root/autodl-tmp/Qwen…

目录

步骤一、下载模型

步骤二、安装模型依赖包

步骤三、写代码

步骤四、运行代码

步骤五、中文提问 & 运行代码


步骤一、下载模型

安装下载命令

pip install modelscope
 

下载模型
modelscope download --model Qwen/Qwen3-8B --local_dir /root/autodl-tmp/Qwen/Qwen3-8B

步骤二、安装模型依赖包

pip install transformers peft diffusers

步骤三、写代码

from modelscope import AutoModelForCausalLM, AutoTokenizermodel_name = "/root/autodl-tmp/Qwen/Qwen3-8B"# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto"
)
# prepare the model input
prompt = "Give me a short introduction to large language model."
messages = [{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True,enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completion
generated_ids = model.generate(**model_inputs,max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking content
try:# rindex finding 151668 (</think>)index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:index = 0thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")print("thinking content:", thinking_content)
print("content:", content)

步骤四、运行代码

python startqw3.py

步骤五、中文提问 & 运行代码

from modelscope import AutoModelForCausalLM, AutoTokenizermodel_name = "/root/autodl-tmp/Qwen/Qwen3-8B"# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name,torch_dtype="auto",device_map="auto"
)
# prepare the model input
prompt = "1.我今年42岁是个程序员。2.我三高,高血压高血糖高血脂。3.不算工资收入,我如何在最短的时间内赚够一百万。请用中文思考和回复"
messages = [{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(messages,tokenize=False,add_generation_prompt=True,enable_thinking=True # Switches between thinking and non-thinking modes. Default is True.
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)# conduct text completion
generated_ids = model.generate(**model_inputs,max_new_tokens=32768
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist() # parsing thinking content
try:# rindex finding 151668 (</think>)index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:index = 0thinking_content = tokenizer.decode(output_ids[:index], skip_special_tokens=True).strip("\n")
content = tokenizer.decode(output_ids[index:], skip_special_tokens=True).strip("\n")print("thinking content:", thinking_content)
print("content:", content)

http://www.dtcms.com/a/567209.html

相关文章:

  • 如何开通免费网站企业常用的网络营销方法
  • 安徽华建建设工程公司网站建行手机银行app
  • 房屋设计装修网站行业网站推广
  • 网站建设调研论文抚顺网络推广
  • 昆明 五华 网站建设企业网站建设验收
  • 软件介绍网站模板贵州省公路建设有限公司网站
  • 企业网站推广名词解释dede 网站模板
  • 中国万网域名注册价格无锡做网站优化哪家好
  • 保护膜 东莞网站建设新闻资讯专业翻译公司
  • 招聘网站建设与开发要求设计师浏览网站
  • 做网站可以用php吗网络课程开发
  • 商务网站建设教学视频教程网页源代码中
  • 展示型网站源码境外电商网站建设
  • 购物网站英文介绍ui是做网站的吗
  • 南宁营销型网站建设公司哪家好工程建设概况
  • 怎么做进入网站js特效手机网站需要备案吗
  • 吴镇宇做的电影教学网站wordpress同步谷歌博客
  • 广告网站建设报价网站建设运维自查问题清单
  • 优秀网站建设排名公司网站的关键词库
  • 网络推广网站怎么做最好的dm单网站建设
  • 哈尔滨网站建设推广随州网站建站
  • 网站服务器哪里的好中国做的最好的网站
  • 南宁物流公司网站建设榆林免费做网站公司
  • 高明骏域网站建设零基础学it从哪方面学起
  • 网站友情链接自动上链装饰设计学校
  • 权威的手机网站建设怎么在百度建立自己的网站
  • 浅谈博物馆网站建设的意义企业为什么要做网站 作用是什么
  • 手机网站制作案例湖北海厦建设有限公司网站
  • 应价交易系统网站开发无极网站设计
  • 番禺网站建设技术wordpress栏目页面