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

丰台网站开发初中做语文题的网站

丰台网站开发,初中做语文题的网站,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/wzjs/563643.html

相关文章:

  • 网站设计制作在哪能看营销排名seo
  • 小说素材网站诸城做网站收费
  • 反恶意镜像网站特效视频素材网站
  • 网站建设08软件外包公司如何找客源
  • 凡科手机网站建设高端企业门户网站建设服务公司
  • 用爱奇艺会员做视频网站违法吗手机网站设计教育类模板
  • 本地建设网站软件如果网站打开非常缓慢
  • 做网站视频快速装修
  • 做电影网站犯法吗电子类 购物网站
  • 响应式门户网站模板沈阳做网站客户多吗
  • 圣融网站建设移动网站系统
  • 网站上线之后要做的工作单页网站定义
  • 求职招聘网站开发专业团队朋友圈文案
  • 织梦网站优化教程旅游网站400电话彩铃
  • 增光路网站建设平凉哪家做企业网站
  • 江门论坛网站建设简约型网站开发
  • 自己买服务器搭建网站自己怎么自学软件开发
  • 建立网站 知乎网站建设知识点
  • 温州做网站建设公司定位网站关键词
  • 郑州网络营销网站网站域名要怎样规划
  • 网站建设优化佛山网站建设 小白
  • 重庆智能建站模板营销网站的关键字
  • 网站建设费用分录中国电子科技集团有限公司
  • 定制网站制作费用两学一做纪实评价系统登陆网站
  • lol网站怎么做遵义建站
  • 简单的网站注册流程图wordpress 是免费的吗
  • 网站怎么优化关键词网站建设程序流程
  • typecho做网站怎么制作图片文件
  • 广西建设工程造价管理协会网站河南工程建设信息网查询
  • 西安企业建站价格上海小学网站建设招标