from modelscope import AutoModelForCausalLM, AutoTokenizer``model_name = "Qwen/QwQ-32B-Preview"``model = AutoModelForCausalLM.from_pretrained(` `model_name,` `torch_dtype="auto",` `device_map="auto"``)``tokenizer = AutoTokenizer.from_pretrained(model_name)``prompt = "How many r in strawberry."``messages = [` `{"role": "system", "content": "You are a helpful and harmless assistant. You are Qwen developed by Alibaba. You should think step-by-step."},` `{"role": "user", "content": prompt}``]``text = tokenizer.apply_chat_template(` `messages,` `tokenize=False,` `add_generation_prompt=True``)``model_inputs = tokenizer([text], return_tensors="pt").to(model.device)``generated_ids = model.generate(` `**model_inputs,` `max_new_tokens=512``)``generated_ids = [` `output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)``]``response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]``print(response)
复制代码
输出 1
User:How many r in strawberry.``QwQ-32B-Preview:``Let's see. The word is "strawberry." I need to find out how many 'r's are in it. Okay, first, I'll spell it out slowly: s-t-r-a-w-b-e-r-r-y. Hmm, I can see that there are 'r's in there. Let me count them one by one.``So, starting from the beginning:``First letter: s, no 'r'.``Second letter: t, no 'r'.``Third letter: r, that's one 'r'.``Fourth letter: a, no 'r'.``Fifth letter: w, no 'r'.``Sixth letter: b, no 'r'.``Seventh letter: e, no 'r'.``Eighth letter: r, that's another 'r'.``Ninth letter: r, yet another 'r'.``Tenth letter: y, no 'r'.``So, I've found three 'r's in "strawberry." But wait, let me double-check to make sure I didn't miss any or count incorrectly.``Spelling it again: s-t-r-a-w-b-e-r-r-y.``Looking at each letter:``3rd letter: r``8th letter: r``9th letter: r``Yes, that's three 'r's. I think that's correct.``Alternatively, sometimes people might miscount if the letters are close together, but in this case, it's straightforward.``So, the answer is three 'r's in "strawberry."``**Final Answer**``\[ \boxed{3} \]
对环球大模型从性能、吞吐量、成本等方面有一定的认知,可以在云端和本地等多种环境下部署大模型,找到适合自己的项目/创业方向,做一名被 AI 武装的产物经理。
硬件选型
带你相识环球大模型
使用国产大模型服务
搭建 OpenAI 代理
热身:基于阿里云 PAI 部署 Stable Diffusion
在本土地算机运行大模型
大模型的私有化部署
基于 vLLM 部署大模型
案例:如何优雅地在阿里云私有部署开源大模型
部署一套开源 LLM 项目
内容安全
互联网信息服务算法备案
…
学习是一个过程,只要学习就会有挑衅。天道酬勤,你越积极,就会成为越优秀的自己。
假如你能在15天内完成所有的任务,那你堪称天才。然而,假如你能完成 60-70% 的内容,你就已经开始具备成为一名大模型 AI 的精确特征了。
这份完整版的大模型 AI 学习资料已经上传CSDN,朋友们假如必要可以微信扫描下方CSDN官方认证二维码免费领取【保证100%免费】